response.models_to_run in web2py 2.8.2

113 views
Skip to first unread message

rochacbruno

unread,
Dec 20, 2013, 6:53:26 AM12/20/13
to web...@googlegroups.com
Hi,

I use web2admin in some applications, I was running older version of web2py and them I decided to upgrade to 2.8.2 for testing.

I found an issue with response.models_to_run and reported a ticket in web2admin repo: https://github.com/rif/web2admin/issues/9

web2admin uses a conditional model running implemented as:

if request.controller == 'web2admin':
    request
.controller = 'plugin_web2admin'
    response
.view = response.view.replace('web2admin', 'plugin_web2admin')
    response
.models_to_run.append("^plugin_web2admin/\w+\.py")


This is used to get rid of "plugin" prefix in urls, so users can access using /welcome/web2admin instead of /welcome/plugin_web2admin (which is a bit ugly)

That practice of checking request.controller and change response.view and response.controller and models_to_run worked very well until version "2.2.1"

Is that changed?

Thanks.

rochacbruno

unread,
Dec 20, 2013, 7:04:18 AM12/20/13
to web...@googlegroups.com
If somebody can help ans test it there is an live app here:


password: 35c15f36


But if url is changed it works:

password: admin

note that the problem only occurs  when using the shortcut 'web2admin' instead of 'plugin_web2admin'

Paolo Valleri

unread,
Dec 20, 2013, 8:18:05 AM12/20/13
to web...@googlegroups.com
I am not able to debug it a little more but as you can see here: https://github.com/web2py/web2py/commits/master/gluon/compileapp.py
a few changes have been made on how models are handled, perhaps something broken backward compatibility ?
Have you already tried with 2.7.4 ?

Paolo

Anthony

unread,
Dec 20, 2013, 9:56:20 AM12/20/13
to web...@googlegroups.com
I have identified the problem and sent a patch to Massimo (attached). In the meantime, it should work if you change:

    response.models_to_run.append(...)

to:

    response.models_to_run = [...]

When mutating response.models_to_run, it doesn't recognize that it has changed, so you need to do a new assignment instead.

Anthony
models_to_run.patch

Massimo Di Pierro

unread,
Dec 20, 2013, 9:46:59 PM12/20/13
to web...@googlegroups.com
Thanks. It is in trunk!
Reply all
Reply to author
Forward
0 new messages