Here is some sample code to produce the behavior I'm trying to
describe. Note that in the controller, there are 2 lines commented out
because they return an error ("TypeError: unsupported operand type(s)
for -: 'str' and 'str'")
db.define_table('timetest',
db.Field('starttime','datetime',default=request.now),
db.Field('endtime','datetime',default=request.now),
)
def timetest():
form=FORM(TABLE(
TR("Start time (Epoch Seconds UTC):",INPUT
(_type="text",_name="start_time_es")),
TR("End time (Epoch Seconds UTC):",INPUT
(_type="text",_name="end_time_es")),
TR("",INPUT(_type="submit",_value="Submit"))
))
rowtoinsert = {}
if form.accepts(request.vars):
response.flash="form accepted input"
startdatetime = datetime.datetime.utcfromtimestamp(float
(form.vars.start_time_es))
enddatetime = datetime.datetime.utcfromtimestamp(float
(form.vars.end_time_es))
# make the database insertion
rowtoinsert={
'starttime':startdatetime,
'endtime':enddatetime,
}
idinserted = db.timetest.insert(**rowtoinsert)
elif form.errors:
response.flash="form is invalid"
existing_rows = db(db.timetest.id>0).select().as_list()
# for r in existing_rows:
# r['time_difference'] = r['endtime'] - r['starttime']
return dict(form=form,
rowtoinsert=rowtoinsert,
existing_rows=existing_rows)
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"web2py Web Framework" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---