I am tryin to build a web app where in i will be using the app to store some data info about electrical units consumed. I have three tables viz. dept,meter and reading. The problem here is i wrote a function in the default.py for the table meter where in the dept_id is a FK referencing id of the table dept. in the below code i get a syntax error on the line ' if form.process().accepted: ' I think the error is in some other line which im not able to debug., Kindly guide me thru the probllem. The code of func goes here.
def reg_meter(): form = SQLFORM.factory( Field('meter_num',requires=IS_IN_DB(db,db.meter)), Field('meter_type',requires=IS_IN_DB(db,db.meter)), Field('dept_id',requires=IS_IN_DB(db,db.dept.id,'%(dept_id)s')) if form.process().accepted: entered = db((db.entered.meter_num == form.vars.meter_num) & (db.entered.meter_type == form.vars.meter_type) & (db.entered.dept_id == form.vars.dept_id)).select().first() if entered: entered.update_record((meter_num = entered.meter_num+form.vars.meter_num) & (meter_type = entered.meter_type+form.vars.meter_type) & (dept_id = entered.dept_id+form.vars.dept_id) else: db.entered.insert(meter_num=form.vars.meter_num,meter_type=form.vars.meter_type, dept_id=form.vars.dept_id) response.flash = 'new record inserted' elif form.errors: response.flash = 'invalid values in form' records = SQLTABLE(db().select(db.meter.ALL),headers='fieldname:capitalize') return dict(form=form, records=records) -- 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.