Hi all,

I'm using SqlAlchemy 0.5rc2 on a Windows Server 2003 system and I've got
a question about re-creating objects from a database. I'm building a
Windows Service using Python and the win32all modules and using SA to
save the state machine data for each of the Job objects I'm tracking in
a collection class. The Job objects look like this:

class Job(srsmanagerdb.Base):
    __tablename__ = "jobs"
    id            = Column(Integer, primary_key=True,
autoincrement=True)
    created       = Column(DateTime, default=None)
    job_id        = Column(String(32), default=None)
    srcpath       = Column(String(128), default=None)
    filesize      = Column(Integer, default=None)
    productType   = Column(String(1), default=None)
    contentType   = Column(String(10), default=None)
    priorityType  = Column(String(10), default=None)
    priority      = Column(Integer, default=None)
    press         = Column(Integer, default=None)
    assignedPress = Column(Integer, default=None)
    state         = Column(Integer, default=None)
    scheduled     = Column(Boolean, default=None)
         
    def __init__(self, srcpath=None):
        '''constructor - initializes the instance variables.
        '''
        self._config = __config__
        self._logger = __logger__
        self._fileops = __fileops__
        self.srcpath = srcpath
        self.filesize = os.stat(self.srcpath).st_size
        self.created =
datetime.datetime.fromtimestamp(os.stat(self.srcpath).st_ctime)
        self.state = 0
        self.oldState = None
        self.stateSS = singleshot.SingleShot()
        self._pressesStatus = PressesStatus()
        session = srsmanagerdb.Session()
        session.add(self)
        session.commit()
        self._logger.debug("job %s added" % self.filename)

I've got attributes that are saved in the database and some that aren't
(the ones that have _ prefix). If my server crashes I'd like it to read
the database and rebuild my collection class of Job objects. I do this
in the collection class constructor, and it works fine, but it doesn't
restore the atttributes that aren't in the database, the _ prefixed
ones. Does anyone have any suggestions about what is a good method to
re-create a collection of objects that are represented in a table that
also have attributes that aren't stored in the table?

Thanks in advance,
Doug

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to