Python super() behavior not dependable
Are you reloading modules somehow in the middle of things? If so, that may explain this error.
isinstance(self,DBAdminConnection)
may become false after reloading modules because of the changes to memory references, apparently.
Edit: if you're running your web.py app under mod_wsgi, make sure you're disabling autoreload:
app = web.application(urls, globals(), autoreload=False)
If you are using reload() as part of your workflow, you apparently need to also use super(self.__class__, self).__init__
for inheritance initialization.
I suspect you will find this bug coincides with id(self.__class__) ==id(Retrieval)
failing.
I'm not sure why the error is happening, but as an aid to debugging you could wrap the call to super
in a try/except
block and do a data dump when the exception is raised. Something like this:
class Retrieval(DBConnection.DBAdminConnection): def __init__(self, username=None, password=None, unique_key=None): try: super(Retrieval,self).__init__() except TypeError, e: print "Failure initialising Retrieval --> self: %r" raise if username and password: self.username = username self.user.login(username,password, config.DATABASE) if self.user.error: raise UserLoginError(username) self.unique_key = unique_key