Mind web2py offers all of this out of the box:

   db.define_table('stuff',Field('name'), auth.signature)

auth.signature adds created_on, created_by, modified_on, modified_by and 
is_active. These fields can be used by auth for full auditing if enabled by

   auth.enable_record_versioning(db)

Anyway, if you want to do this at lower level:

   Field('mDate',default=f,update=g)

where f is a value or a a function that returns the value to be used when 
the record is created. g is a value or a function that returns a value to 
be used when the record is updated.

I would strongly suggest using auth.signature instead. 



On Thursday, 10 July 2014 11:00:23 UTC-5, Carl Hunter Roach wrote:
>
> I am using Web2py on an appengine project and each of my tables include 
> two 'datetime' fields cDate and mDate to record when the record was created 
> and modified respectively.
>
> Last time I used Web2py I'd check if  a record existed and call insert() 
> or update_record() appropriately.
>
> Now, I can potentially use update_or_insert() but I don't see how I can 
> pass in cDate and mDate for "insert" but mDate only for "update_record"
>
> Does web2py have create/modify fields like it adds an "id" to all tables 
> and handle this for me?
>

-- 
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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to