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 2 and Version 3 of SQLObjectAutoUpdateField


Ignore:
Timestamp:
03/27/06 23:36:59 (13 years ago)
Author:
Mike Kent <mrmakent@…>
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • SQLObjectAutoUpdateField

    v2 v3  
    3333 
    3434''-AcidReign'' 
     35 
     36This is a good recipe, exactly what I needed... but I had to modify is a bit to get it to work properly.  I don't know if this is because of changes to SQLObject or what.  What I found was that, in the case of the example above, when __setattr__ is called, for example, for the 'Body' column, what is actually passed as the name to __setattr__ is '_SO_val_Body'.  However, what's in the list of keys is 'Body'.  So my fix was as follows: 
     37 
     38{{{ 
     39    def __setattr__( self, name, value ): 
     40        super( self.__class__, self ).__setattr__( name, value ) 
     41        if name.startswith("_SO_val_"): 
     42            if name[8:] in self.sqlmeta.columns.keys(): 
     43                super( self.__class__, self ).__setattr__( '_SO_val_Modified', datetime.now() ) 
     44}}} 
     45 
     46''Mike Kent''