Hello, I realize this may not be the best place to ask a SQLobject question but there doesn't seem to be a group for SQLobject specifically correct me if I'm wrong.
Anyway, my question. I want to have columns for updateDate and createDate. I'm sure you can guess what the functionality would be. I saw this. http://www.sqlobject.org/module-sqlobject.events.html and this http://xentac.net/~jchu/blog/2005/Nov/14 I thought I understood things and came up with a base class class SQLBase(SQLObject): '''Hook some events for auditing(created/last updated)''' createDate = DateTimeCol(default=datetime.now,notNone=True) updateDate = DateTimeCol(default=datetime.now,notNone=True) def __init__(self,*args,**kwargs): SQLObject.__init__(self,*args,**kwargs) #hook events events.listen(self.event_CreateRow,self,events.RowCreateSignal) events.listen(self.event_UpdateRow,self,events.RowUpdateSignal) def event_UpdateRow(self,kwargs): print "updaterow: kwargs %s" % str(kwargs) setattr(self,'updateDate', datetime.now()) return def event_CreateRow(self,kwargs): print "updaterow: kwargs %s" % str(kwargs) setattr(self,'createDate', datetime.now()) setattr(self,'updateDate', datetime.now()) return and a class to test with class TestDateCols(SQLBase): data = UnicodeCol(notNone=True) def __init__(self,*args,**kwargs): SQLBase.__init__(self,*args,**kwargs) when created in tg-admin shell In [1]: import model In [2]: tobj = model.TestDateCols(data="goo") In [3]: tobj.data = "foo" In [4]: tobj.updateDate Out[4]: datetime.datetime(2007, 7, 7, 13, 57, 20) In [5]: tobj.createDate Out[5]: datetime.datetime(2007, 7, 7, 13, 57, 20) In [6]: Any guidance is appreciated. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "TurboGears" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/turbogears?hl=en -~----------~----~----~----~------~----~------~--~---

