I'm really liking the ability to automatically timestamp when records are 
updated, but I'm wondering if there's a simple way of suppressing this 
behaviour when needed:

I have these signature fields appended to a number of tables, automatically 
recording when users update records:
signature_fields = idb.Table(
    idb, 'signature_fields', #Dummy table, not actually in the db
    Field('created_on', 'datetime',
          default=request.now,
          writable=False, readable=False,
          label='Created on'),
    Field('created_by', 'string',
          default=auth.user.username
          writable=False, readable=False,
          label='Created by'),
    Field('modified_on', 'datetime',
          update=request.now, default=request.now,
          writable=False, readable=False,
          label='Modified on'),
    Field('modified_by', 'string',
          default=auth.user.username, update=signature_username,
          writable=False, readable=False,
          label='Modified by'),
    )

For example:

idb.define_table(
    'address',
    Field('id', 'id', readable=False),
    Field('student', idb.student, readable=False, writable=False),
    Field('line1', 'string'),
    Field('line2', 'string'),
    Field('line3', 'string'),
    Field('town', 'string'),
    Field('countystate', 'string'),
    Field('country', 'string'),
    Field('postcode', 'string'),
    signature_fields
    )       

But I have an admin routine that allows me to move addreses to another 
student, and I don't want the timestamping to occur when I run:
idb.student(source.id).address.update(student=target.id)        

Is there a simple way to suppress automatic update values? e.g.:
idb.student(source.id).address.update(student=target.id, _update=False)     
   

I know I can disable them one by one before running the queries, but it'll 
add lots of boilerplate a la:
idb.address.modified_on.update = idb.address.modified_by.update = None



-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to