Reputation: 123
I'm trying to implement this code on my localhost:
def form_a():
form = SQLFORM(db.registration, deletable=True, request.args(0), upload=URL(r=request, f='download'))
if form.accepts(request.vars, session):
if not form.record:
response.flash = "Your input data has been submitted."
else:
if form.vars.delete_this_record:
session.flash = "User record successfully deleted."
else:
session.flash = "User record successfully updated."
redirect(URL(r=request, f='form_a’))
records = db().select(db.registration.ALL)
return dict(form=form, records=records)
But I get a non-keyword arg after keyword arg error at this line:
form = SQLFORM(db.registration, deletable=True, request.args(0), upload=URL(r=request, f='download'))
And a EOL while scanning literal error at this line:
redirect(URL(r=request, f='form_a’))
I'm using Python 3 and Web2Py 2.4.6, thanks.
Upvotes: 0
Views: 476
Reputation: 19486
In:
form = SQLFORM(db.registration, deletable=True, request.args(0), upload=URL(r=request, f='download')),
You have deletable=True, request.args(0)
which is a non-keyword argument after a keyword argument. Which is not valid syntax..
And In redirect(URL(r=request, f='form_a’))
redirect(URL(r=request, f='form_a’))
^ This is not what you want..
redirect(URL(r=request, f='form_a'))
^ This IS what you want..
Upvotes: 0
Reputation: 251146
All positional arguments must come before keyword arguments, so here request.args(0)
is causing the error as deletable=True
a keyword argument was passed before it.
form = SQLFORM(db.registration, deletable=True, request.args(0), upload=URL(r=request, f='download'))
From the docs:
In a function call, keyword arguments must follow positional arguments. All the keyword arguments passed must match one of the arguments accepted by the function and their order is not important.
And in redirect(URL(r=request, f='form_a’))
you're using different types of opening and closing quotes.
It must be either f='form_a'
or f="form_a"
Upvotes: 1
Reputation: 298532
You have a non-keyword argument:
form = SQLFORM(db.registration, deletable=True, request.args(0), upload=URL(r=request, f='download'))
^^^^^^^^^^^^^^^
After a keyword argument:
form = SQLFORM(db.registration, deletable=True, request.args(0), upload=URL(r=request, f='download'))
^^^^^^^^^^^^^^
You either have to make deletable
a non-keyword argument or make request.args(0)
a keyword argument.
As for the second error, this quote right here isn't actually a closing quote:
redirect(URL(r=request, f='form_a’))
^
Notice how it's curly. Replace it with a regular single quote.
Upvotes: 2