Closed memilanuk closed 7 years ago
I'm running into the same problem: I've tried replacing this line
form = crud.create(db.note) if auth.user else "Login to Post to the Project"
with
form = SQLFORM(db.note).process()
which makes the error go away, but when I click on the "Note" link in the index page's project list, it takes me to a blank page (at http://127.0.0.1:8000/note/1
). Not sure why I'm not seeing anything inside the
(The "if" clause shouldn't be needed when the route is decorated with @auth.requires_login()
, should it...?)
Okay, the blank page was me being bone-headed: my note()
function was returning locals
rather than locals()
.
With the substitution of a call to SQLFORM()
for the call to crud.create()
described in my last comment, this works fine and I can proceed on from here.
Are you adding on the if
as well:
form = SQLFORM(db.note).process() if auth.user else "Login to Post to the Project"
No, not so far, but I haven't tested it extensively, either yet. Is the if
clause necessary when the route function is decorated with @auth.requires_login()
? I'd reckoned that if I tried to get to the note/
URL without being logged in, I'd have gotten tossed back to the login screen. Why would a check like that be required here but in none of the other route functions...?
Updated in v 2.0 of the courses. Coming week of 12/19/2016. https://github.com/realpython/about/blob/master/changelog.csv
Trying to update the controller
default.py
with a function for the note(s) page... my code looks (as far as I can tell) the same as shown here in the repo, line 26 but I am getting an error ticket when I try to actually access the page:Not sure if its a version thing; I'm using web2py 2.12.3 on pythonanywhere.com, vs. 2.8.2 as used in the book. Web2py is supposed to be pretty good about backwards compatibility, and I thought
crud
was a standard feature...?