Hi! What is the best way to store runtime information in model? And is it good idea to store one in a model(like online/offline, etc)
for example: class User(Base): __tablename__ = 'users' id = Column(Integer, primary_key=True) username = Column(String, unique=True, nullable=False) fullname = Column(String, default='') password = Column(String, nullable=False) role = Column(String, nullable=False) status = {0: "Offline", 1: "Online", -1: "Unknown"} def __init__(self, **kwargs): Base.__init__(self, **kwargs) self.init_status() @orm.reconstructor def init_status(self): self._online = 0 @property def online(self): if self._online is None: self._online = 0 if self.enable: return self._online return -1 @online.setter def online(self, value): if value != self.online: dispatcher.send(sender=self, signal="state", value=value) self._online = value If I get object from session like user = session.query(User).get(1) change state user.online = 1 and after session.close() I have detached object Do I always have to do expunge(user) after commit() and before close() and then if I want to change it, I have to add it to new session and the again commit,expunge,close Is there any other ways? P.S. what is the most used practice, to create DAO layer or session it self work like DAO layer? Thanks. -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at http://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/groups/opt_out.