@@ -21,10 +21,10 @@ def __init__(self, db, user, password, authdb, max_lag_secs):
2121
2222 # Get a DB connection
2323 try :
24- if self .db . __class__ . __name__ == "DB" :
24+ if isinstance ( self .db , DB ) :
2525 self .connection = self .db .connection ()
2626 else :
27- raise Exception , "'db' field is an instance of %s, not 'DB'!" % self . db . __class__ . __name__ , None
27+ raise Exception , "'db' field is not an instance of class: 'DB'!" , None
2828 except Exception , e :
2929 logging .fatal ("Could not get DB connection! Error: %s" % e )
3030 raise e
@@ -147,17 +147,17 @@ def __init__(self, sharding, db, user, password, authdb, max_lag_secs):
147147 self .replset_conns = {}
148148
149149 # Check Sharding class:
150- if not self .sharding . __class__ . __name__ == " Sharding" :
151- raise Exception , "'sharding' field is an instance of %s, not 'Sharding'!" % self . sharding . __class__ . __name__ , None
150+ if not isinstance ( self .sharding , Sharding ) :
151+ raise Exception , "'sharding' field is not an instance of class: 'Sharding'!" , None
152152
153153 # Get a DB connection
154154 try :
155- if self .db . __class__ . __name__ == "DB" :
155+ if isinstance ( self .db , DB ) :
156156 self .connection = self .db .connection ()
157157 if not self .connection .is_mongos :
158158 raise Exception , 'MongoDB connection is not to a mongos!' , None
159159 else :
160- raise Exception , "'db' field is an instance of %s, not 'DB'!" % self . db . __class__ . __name__ , None
160+ raise Exception , "'db' field is not an instance of class: 'DB'!" , None
161161 except Exception , e :
162162 logging .fatal ("Could not get DB connection! Error: %s" % e )
163163 raise e
0 commit comments