is response.menu cached?

50 views
Skip to first unread message

jim kaubisch

unread,
May 24, 2018, 11:49:41 PM5/24/18
to web2py-users
Hi,

I've never had this issue in the past, but when I change the definition of response.menu (.../models/menu.py),  the change is not reflected on the web page. 
I edit the definition (as many times before) and if I restart the app, or even web2py, the displayed menu displays as it was before the change.
If I print out the value of response.menu after I change it, I see the NEW update. When I "beautify" response.menu in the view, I see the OLD version

It has the feeling of the menu being cached?? I've looked in this forum and the manual and have not found an answer :-(

Thanks,
Jim

jim kaubisch

unread,
May 24, 2018, 11:57:05 PM5/24/18
to web2py-users
Sorry, the environment is - web2py version 2.16.1, Rocket 1.2.6python 2.7.14, macOS 10.13.4

黄祥

unread,
May 25, 2018, 12:05:04 AM5/25/18
to web2py-users
had you compile your app?
had you tried to remove the cache in browser or tried in incognito, and do load refresh (shift f5) the page?

best regards,
stifan

jim kaubisch

unread,
May 25, 2018, 12:51:19 AM5/25/18
to web2py-users
Yes to the first and third of your questions. Not sure what you mean by incognito or how to achieve it
Also, by the way, Chrome is my usual browser but tried a second (Safari) and third browser (FireFox). All identical results. Don't think I've EVER used Firefox with web2py before

黄祥

unread,
May 25, 2018, 1:34:11 AM5/25/18
to web2py-users
ok, target spotted, seems your webapp is compiled, so please uncompile your web app first (via web2py app admin), then change your code (menu), then refresh your browser.

best regards,
stifan

jim kaubisch

unread,
May 25, 2018, 12:11:15 PM5/25/18
to web2py-users
Only two "compile" options show, no "remove compiled" option. I assume that the app is NOT compiled?

Stumbled on the answer...
I'm using TextMate2 to edit. Once I not only saved but CLOSED the menu.py file and reopened it, it all worked like normal - presumably some corner case bug :-(

Thanks for coming to the rescue !

jim kaubisch

unread,
May 25, 2018, 1:36:20 PM5/25/18
to web2py-users

Its beginning to look like this problem IS in web2py - 

The actions I took -
  - duplicate menu.py (macOS names the copy "menu copy.py) and rename the original file something like menu_old.py and leave that renamed file in the models directory as reference backup
  - using the menu copy.py as a starting point, rename it menu.py  and experiment with the proposed changes, save the file and restart the app to see the result

  and the result seems, at least for me, to be that AS LONG AS THE MENU_OLD.PY file remains in the models directory, web2py continues to pick IT up as menu.py, rather than the modified file

It seems, if I remove the menu_old file from the models directory, web2py is then triggered to look for menu.py again and picks up the new file

At least that's the way it looks right now. Anyone seen something similar?

Nico de Groot

unread,
May 25, 2018, 2:18:08 PM5/25/18
to web2py-users
If you leave the copy in the model folder it still is active. .py files are all executed in alphabetical order at every request. If you want to keep a backup use another suffix.

Nico de Groot

Anthony

unread,
May 25, 2018, 3:07:14 PM5/25/18
to web2py-users
To further clarify, there is nothing special about the filename "menu.py" (or any of the files in the /models folder) -- all the files in the folder are executed (unless you explicitly specify response.models_to_run or use sub-folders to run model files conditionally).

Anthony

jim kaubisch

unread,
Jun 11, 2018, 4:27:07 PM6/11/18
to web2py-users
Embarrassing :( Yes, I read that a long time ago but forgot. Thank you both for your response - Jim
Reply all
Reply to author
Forward
0 new messages