Hello All, Just started to learn web2py and here is an idea that I am trying to implement. Users creates scenarios, which includes an uploaded file. After the new scenario is created, the uploaded file should be processed and computed values written to results table. So far, I am successful in creating the scenarios and uploading the files. But, I am not sure where I would write the controller form.process().accepted. By the way, I am using SQLFORM.grid and here is complete code. Any help and/or pointers is highly appreciated.
----------------- db.py from gluon.tools import * db=DAL("sqlite://storage.sqlite") auth = Auth(db) auth.define_tables(username=True) crud = Crud(db) db.define_table("scenario", Field('title'), Field('body', 'text'), Field('created_on', 'datetime', default=request.now), Field('created_by', 'reference auth_user', default=db.auth_user.id), Field('file', 'upload'), Field('file_status', default='file uploaded')) db.scenario.created_by.requires=IS_IN_DB(db, db.auth_user.id) db.scenario.title.requires = IS_NOT_EMPTY() db.scenario.created_on.readable = False db.scenario.created_by.readable = False db.define_table("results", Field('scenario_id', 'reference scenario'), Field('amps', 'double'), Field('volts', 'double')) default.py @auth.requires_login() def index(): query = (db.scenario.created_by == auth.user.id) grid = SQLFORM.grid(query, selectable=lambda ids: []) return dict(grid=grid) default/index.html {{extend 'layout.html'}} {{if auth.user.id:}} <h2>Your Current Scenarios</h2> {{=grid}} {{pass}} ------------------ I tested the following code and see that the "form accepted" is flashed. But, how do I link this form to the "Add" button in the SQLFORM.grid def scenario(): form = SQLFORM(db.scenario) if form.process().accepted: response.flash = "form accepted" ##get the uploaded file, process and write results return dict(form=form) Thanks, PT -- 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/groups/opt_out.