I'm confused at how to implement automatic timestamps to tables.

So I want to know when each record was created (might have a separate
field for "last modified").

The form should either have an uneditable field with the current
timestamp xor—preferably—it shouldn't be present in the form.

Here's a test-case:

# Models

from datetime import datetime

db.define_table(
    'sometb',
    Field('name', requires=[IS_NOT_EMPTY(), IS_NOT_IN_DB(db, 'sometb.name')]),
    Field('date_created', 'datetime', requires=datetime.now,
default=datetime.now),
    format='%(name)s'
)

# Controllers

def sometb():
    return dict(tbform=crud.create(db.group_of_events))

# Views

{{if 'tbform' in globals():}}
{{=tbform}}
{{else:}}
<h5>Form not found :[</h5>
{{pass}}

# {{pass}}!

Thanks for your time,

Alec Taylor

-- 



Reply via email to