def __getattr__(self, name):
""" Handle unknown attribute lookups """
if name == "readonly":
return True
sname = name.split('_')
if sname[:2] == ['get', 'unfiltered']:
"""
Handle get_unfiltered calls. Return the name of the access
method for the base database object. Call setattr before
returning so that the lookup happens at most once for a given
method call and a given object.
"""
attr = getattr(self.basedb, 'get_' + sname[2] + '_from_handle')
setattr(self, name, attr)
return attr
# if a write-method:
if (name in DbWriteBase.__dict__ and
not name.startswith("__") and
type(DbWriteBase.__dict__[name]) is types.FunctionType):
raise AttributeError
# Default behaviour: lookup attribute in parent object
return getattr(self.db, name)
评论列表
文章目录