Warning: Can't synchronize with repository "(default)" (Unsupported version control system "svn": No module named svn). Look in the Trac log for more information.

Changes between Version 5 and Version 6 of SQLObjectAutoUpdateField


Ignore:
Timestamp:
07/13/06 14:28:22 (13 years ago)
Author:
sean@…
Comment:

Fixed improper use of super() (can't use self.class, this was my mistake I was still learning)

Legend:

Unmodified
Added
Removed
Modified
  • SQLObjectAutoUpdateField

    v5 v6  
    2626     
    2727    def __setattr__( self, name, value ): 
    28         super( self.__class__, self ).__setattr__( name, value ) 
     28        super( Comment, self ).__setattr__( name, value ) 
    2929        if name in self.sqlmeta.columns.keys(): 
    30             super( self.__class__, self ).__setattr__( 'Modified', datetime.now() ) 
     30            super( Comment, self ).__setattr__( 'Modified', datetime.now() ) 
    3131}}} 
    3232This will update the Modified field every time an assignment is made on any of the other fields (actually, including the Modified field, but doing that would be silly). In place of self.sqlmeta.columns.keys(), you could use a list of the field names you want to catch and update the Modified field for. 
     
    3838{{{ 
    3939    def __setattr__( self, name, value ): 
    40         super( self.__class__, self ).__setattr__( name, value ) 
     40        super( Comment, self ).__setattr__( name, value ) 
    4141        if name.startswith("_SO_val_"): 
    4242            if name[8:] in self.sqlmeta.columns.keys(): 
    43                 super( self.__class__, self ).__setattr__( '_SO_val_Modified', datetime.now() ) 
     43                super( Comment, self ).__setattr__( '_SO_val_Modified', datetime.now() ) 
    4444}}} 
    4545