Looks like the way you were using it before wasn't supposed to work but did 
due to a bug. The purpose of the "record" argument is to enable a database 
record to be updated, and so it is expected that the record will have an 
"id" field (or a set of fields serving as a primary key). It appears you 
are instead using the "record" argument as a way of pre-filling the form 
with a set of previously used values. In that case, you should add a dummy 
"id" field to session.mydata (it shouldn't matter what value you assign to 
it, as it doesn't refer to a real record). Alternatively, you could use the 
values in session.mydata to set default values in the SQLFORM.factory 
fields.

Anthony

On Thursday, January 14, 2016 at 2:05:37 PM UTC-5, Silvan Marco Fin wrote:
>
> Hi!
>
> I just upgraded web2py to 2.13.4, and now some of my SQLFORM.factory-forms 
> stopped working as expected.
> Upon submission of the data entered, I get an error:
>
> <type 'exceptions.SyntaxError'> user is tampering with form's record_id: 
> != None
>
> here an example of code:
>
> def get_some_input():
>     if ('my_data' in session):
>         my_data = session.my_data
>     else:
>         my_data = None
>     my_form = SQLFORM.factory(
>         Field('schnorg'),
>         record=my_data,
>         showid=False
>     )
>     if (my_form.process().accepted):
>         session.my_data = my_form.vars
>         redirect(URL(get_some_input))
>     return dict(my_form=my_form)
>
> until I performed the update, most of my forms served well in retrieving 
> user input code similar to given sample. Now in case session contains 
> already my_data (e.g. previous submission) and the submit button is hit, 
> the following error is reported:
>
> Traceback (most recent call last):
>   File "/home/silvan/local/web2py/gluon/restricted.py", line 227, in 
> restricted
>     exec ccode in environment
>   File 
> "/home/silvan/local/web2py/applications/sff_sample/controllers/default.py", 
> line 92, in <module>
>   File "/home/silvan/local/web2py/gluon/globals.py", line 412, in <lambda>
>     self._caller = lambda f: f()
>   File 
> "/home/silvan/local/web2py/applications/sff_sample/controllers/default.py", 
> line 77, in get_some_input
>     if (my_form.process().accepted):
>   File "/home/silvan/local/web2py/gluon/html.py", line 2304, in process
>     self.validate(**kwargs)
>   File "/home/silvan/local/web2py/gluon/html.py", line 2241, in validate
>     if self.accepts(**kwargs):
>   File "/home/silvan/local/web2py/gluon/sqlhtml.py", line 1559, in accepts
>     '%s != %s' % (record_id, self.record_id))
> SyntaxError: user is tampering with form's record_id:  != None
>
> I found some changes to gluon/sqlhtml.py in 
> commit 948bd0c6715ff56ab6898b02cafaa827cb3e6ba2, that may be related to 
> this problem. I would appreciate, if someone with more knowledge of this 
> code than me would take a look into the problem.
>
>  Kind regards,
>   Silvan
>
>

-- 
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/d/optout.

Reply via email to