response._view_environment

39 views
Skip to first unread message

Paolo Valleri

unread,
Sep 24, 2016, 12:53:59 PM9/24/16
to web2py-d...@googlegroups.com
A views is executed in a copy of the environment in which models are executed.
Same approach is for the controller.
Which are the reasons for not running the view in the same environment in which the controller has been executed?
The relevant code is here: https://github.com/web2py/web2py/blob/master/gluon/main.py#L178 (it's part of the initial commit made in November 2011)

In addition, as far as I understood, at least this could be removed: https://github.com/web2py/web2py/blob/master/gluon/compileapp.py#L447
otherwise, it is copied two times: one in build_environment and one in serve_controller

Paolo

Massimo DiPierro

unread,
Sep 24, 2016, 1:31:52 PM9/24/16
to web2py-d...@googlegroups.com

because it is polluted by too many variables including actions


--
-- mail from:GoogleGroups "web2py-developers" mailing list
make speech: web2py-developers@googlegroups.com
unsubscribe: web2py-developers+unsubscribe@googlegroups.com
details : http://groups.google.com/group/web2py-developers
the project: http://code.google.com/p/web2py/
official : http://www.web2py.com/
---
You received this message because you are subscribed to the Google Groups "web2py-developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to web2py-developers+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Anthony

unread,
Sep 24, 2016, 1:53:58 PM9/24/16
to web2py-developers
But Paolo has a good point -- why is response._view_environment assigned in build_environment and then again in serve_controller? Assuming we don't need both, I would opt for the later one (i.e., in serve_controller) -- that way we can skip that step in cases where responses are returned directly from models (e.g., redirect from a model).

Anthony

Massimo DiPierro

unread,
Sep 25, 2016, 10:51:45 AM9/25/16
to web2py-d...@googlegroups.com
Actually Anthony is right. The copy made in build_environment is not necessary.

On Sep 24, 2016, at 1:50 PM, Massimo DiPierro <massimo....@gmail.com> wrote:

will check

Paolo Valleri

unread,
Sep 25, 2016, 11:18:01 AM9/25/16
to web2py-d...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages