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


Ignore:
Timestamp:
03/23/06 18:52:23 (13 years ago)
Author:
sean@…
Comment:

formatting

Legend:

Unmodified
Added
Removed
Modified
  • SQLObjectAutoUpdateField

    v1 v2  
    11= Automatic Update Field, with SQLObject = 
    22SQLObject 0.8 (which is currently still in SVN) will add a feature for capturing events. But those of us using the current release (0.7.1) will need to do a little hack to do something I find fairly common. 
    3 An example: take a comment system, where user's can edit their comments later on. You want to track when the comment was last modified, so you create a Modified field in your Comment class/table: 
     3 
     4An example: a comment system, where user's can edit their comments later on. You want to track when the comment was last modified, so you create a Modified field in your Comment class/table: 
    45{{{ 
    56#!python 
     
    1314Obviously this is a very simple example, and you could just do c.Modified = datetime.now() on the target of your Edit Comment form. 
    1415But, think about a case where there are many more fields, and several different places where your record could get modified (not just the Edit Comment form). Then it would be nice to have the Modified field updated automatically every time the record is changed. 
    15 Take the following example: 
     16 
     17Take the following: 
    1618{{{ 
    1719#!python 
     
    2931}}} 
    3032This 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. 
    31 ''- AcidReign'' 
     33 
     34''-AcidReign''