I assume you're using LOAD() with ajax=False (the default), correct? I
suppose the copying of request.env isn't likely to change, but it's not a
documented part of the API (in the past, we have talked about starting with
a fresh request environment instead of copying everything in the current
environment, which would make it more like an ajax component). I think
Massimo generally discourages use of non-ajax components, so that part of
the LOAD functionality might not tend to receive much further development
attention anyway.
Another option to consider is adding your variables as vars:
LOAD('default', 'mycomponent', vars=dict(rows=rows))
Then in the mycomponent() action, the rows object will be available as
request.vars.rows (as well as request.get_vars.rows). In a normal HTTP or
Ajax component request, the values in request.vars come from an HTTP GET or
POST request, so wouldn't be complex Python objects. However, when you call
LOAD() with ajax=False, whatever values you pass in the vars dict are
simply copied to the request.vars of the new LOAD request, so they can be
any kind of Python object. Give it a try and see if that works.
Anthony
On Sunday, August 19, 2012 7:58:36 PM UTC-4, spiffytech wrote:
>
> For efficiency and simplicity, I would like to pass Python variables (such
> as Rows objects) through LOAD() calls and have them accessible from the
> loaded component. After checking the LOAD() source code, I found I could do
> this by inserting the variables into request.env, since LOAD copies the
> original request.env into the component's new request.env.
>
> The copying of request.env doesn't seem to be an advertised part of how
> LOAD() works. Can I count on this to work, even through future
> modifications/rewrites of LOAD(), or is this an accidental feature I
> shouldn't rely on?
>
--