cache
This commit is contained in:
@ -29,6 +29,10 @@ from sqlalchemy.orm import sessionmaker
|
||||
#FIXME
|
||||
engine = create_engine('sqlite:///:memory:')
|
||||
SqlAlchemyBase = declarative_base()
|
||||
#FIXME a voir:
|
||||
# # Organization.members will be a Query object - no loading
|
||||
# # of the entire collection occurs unless requested
|
||||
# lazy="dynamic",
|
||||
#____________________________________________________________
|
||||
#
|
||||
# require
|
||||
@ -51,7 +55,8 @@ class _RequireExpected(SqlAlchemyBase):
|
||||
class _RequireOption(SqlAlchemyBase):
|
||||
__tablename__ = 'requireoption'
|
||||
id = Column(Integer, primary_key=True)
|
||||
r_opt = Column(Integer)
|
||||
option = relationship('_Base', lazy='joined', cascade="all, delete-orphan")
|
||||
#option = relationship('_Base')
|
||||
expected = relationship("_RequireExpected")
|
||||
action = Column(String, nullable=False)
|
||||
inverse = Column(Boolean, default=False)
|
||||
@ -60,7 +65,8 @@ class _RequireOption(SqlAlchemyBase):
|
||||
|
||||
def __init__(self, option, expected, action, inverse, transitive,
|
||||
same_action):
|
||||
self.r_opt = option.id
|
||||
#self.r_opt = option.id
|
||||
self.option = option
|
||||
for expect in expected:
|
||||
self.expected.append(_RequireExpected(expect))
|
||||
self.action = action
|
||||
@ -175,7 +181,7 @@ class _Base(SqlAlchemyBase):
|
||||
_default = Column(PickleType)
|
||||
_default_multi = Column(PickleType)
|
||||
_requires = relationship('_RequireOption', secondary=require_table,
|
||||
backref=backref('option', enable_typechecks=False))
|
||||
backref=backref('self_option', enable_typechecks=False))
|
||||
_multi = Column(Boolean)
|
||||
_multitype = Column(String)
|
||||
_callback = Column(PickleType)
|
||||
@ -193,6 +199,7 @@ class _Base(SqlAlchemyBase):
|
||||
_choice_values = Column(PickleType)
|
||||
_choice_open_values = Column(Boolean)
|
||||
_type = Column(String(50))
|
||||
_r_option = Column(Integer, ForeignKey('requireoption.id'))
|
||||
__mapper_args__ = {
|
||||
'polymorphic_identity': 'option',
|
||||
'polymorphic_on': _type
|
||||
@ -268,7 +275,8 @@ class StorageOptionDescription(object):
|
||||
|
||||
def impl_get_path_by_opt(self, opt):
|
||||
try:
|
||||
return self._cache_paths[1][self._cache_paths[0].index(opt)]
|
||||
print opt, type(opt)
|
||||
return self._cache_paths[1][self._cache_paths[0].index(opt.id)]
|
||||
except ValueError:
|
||||
raise AttributeError(_('no option {0} found').format(opt))
|
||||
|
||||
|
Reference in New Issue
Block a user