how to debug function view error

30 views
Skip to first unread message

P T

unread,
Sep 10, 2015, 6:39:30 PM9/10/15
to web2py-users
Hello,

I have an existing application and defined new functions in the controller default.py  and also defined the corresponding views. The view includes {{extend 'layout.html'}}.  However, when the function is invoked, the page is displayed as if there is no view defined. It works fine for the functions and views that were created earlier. This problem occurs only for newly created functions/views.  I checked several times the function name and the view name are exactly the same.

How can I debug this problem?

version
2.8.2-stable+timestamp.2013.11.28.13.54.07
(Running on Apache/2.4.9 (Win64) OpenSSL/1.0.1g mod_wsgi/3.5-BRANCH Python/2.7.6, Python 2.7.6)

Thanks for your help,
PT

P T

unread,
Sep 10, 2015, 7:04:58 PM9/10/15
to web2py-users
When I tried to directly view the page, I am getting this error. Even though the URL uses correct controller "resource", web2py is looking for the function in he default.py controller




Auto Generated Inline Image 1

黄祥

unread,
Sep 10, 2015, 7:19:49 PM9/10/15
to web2py-users
i think it related with your routes configuration

best regards,
stifan

Leonel Câmara

unread,
Sep 10, 2015, 7:47:57 PM9/10/15
to web2py-users
If this only happens in production, is it possible you forgot to add the views to source control so they don't exist on the server where you are using a checked out version?

If not, where are the views you have created? Are they inside the views/default folder?

P T

unread,
Sep 10, 2015, 11:35:45 PM9/10/15
to web2py-users
Thank you Leonel and Stifan.

Initially, I had the function in default.py and the view in the default folder. But, this view behaved as if I didn't include the {{extend 'layout.html'}}. Then, I moved the function to a new control resource.py and also created a new view in the resource folder. Some how this did not work (see the screenshots I posted earlier).

But, I made a mistake in the function definition by returning the variable.

def resources_assigned():
    assign_form1
= SQLFORM.grid(db.assigned, maxtextlength=150, csv=True, details=True, editable=True, formstyle='bootstrap', paginate=100)
   
return assign_form1

Once I changed return assign_form1  to return locals() or return (assign_form1=assign_form1), its all working fine.

Thank you for your time and suggestions.

Best Regards,
PT
Reply all
Reply to author
Forward
0 new messages