Getting "invalid view" when trying to access view as JSON

196 views
Skip to first unread message

John Drake

unread,
Jul 17, 2014, 6:13:46 AM7/17/14
to web...@googlegroups.com
This is odd.  On my local test server I can do something like:


and I get back a JSON document.  But when I try the same code on the same application running on Pythonanywhere I get:

invalid view (mycontroller/myfunction.json)


Just to make sure it wasn't something I coded wrong, I tried this with the built in "Welcome" app.


I get the above error message.  If I do:


I get the JSON doc I want.  What's going on here?

Niphlod

unread,
Jul 17, 2014, 6:21:41 AM7/17/14
to web...@googlegroups.com
directly from the book


  • If a view is not found, web2py tries to use a generic view. By default, generic views are disabled, although the 'welcome' app includes a line in /models/db.py to enable them on localhost only. They can be enabled per extension type and per action (usingresponse.generic_patterns). In general, generic views are a development tool and typically should not be used in production. If you want some actions to use a generic view, list those actions in response.generic_patterns (discussed in more detail in the chapter on Services).

lyn2py

unread,
Jul 17, 2014, 9:07:45 AM7/17/14
to web...@googlegroups.com
Because generic views are used on localhost. For security, production servers will not serve generic files. You either turn off that security (not recommended, do the next thing) or create the individual view files you need for the corresponding function/action in the controller.
Reply all
Reply to author
Forward
0 new messages