__getattr__ OD
This commit is contained in:
@ -382,8 +382,6 @@ class StorageOptionDescription(object):
|
||||
session.commit()
|
||||
|
||||
def impl_get_options_paths(self, bytype, byname, _subpath, only_first):
|
||||
#FIXME tester si 1er est un descr ...
|
||||
#FAIRE UN JOIN pour only_first
|
||||
sqlquery = session.query(Cache).filter_by(descr=self.id)
|
||||
if bytype is None:
|
||||
sqlquery = sqlquery.filter(not_(Cache.opt_type == 'OptionDescription'))
|
||||
@ -415,6 +413,16 @@ class StorageOptionDescription(object):
|
||||
ret.append((opt.path, option))
|
||||
return ret
|
||||
|
||||
def __getattr__(self, name):
|
||||
if name.startswith('_') or name.startswith('impl_'):
|
||||
return object.__getattribute__(self, name)
|
||||
ret = session.query(_Base).filter_by(_parent=self.id, _name=name).first()
|
||||
if ret is None:
|
||||
raise AttributeError(_('unknown Option {0} '
|
||||
'in OptionDescription {1}'
|
||||
'').format(name, self.impl_getname()))
|
||||
return ret
|
||||
|
||||
|
||||
class StorageBase(_Base):
|
||||
@declared_attr
|
||||
|
Reference in New Issue
Block a user