You're probably better off with LOAD, but if you don't want to use Ajax,
maybe exec_environment would work:
http://web2py.com/book/default/chapter/04#Execution-Environment
Does options() have to be a controller action (i.e., does it ever need to be
called via a URL)? If not, you could also simply put it in a module and
import it wherever you need it. In that case, I suppose you'd have to
explicitly pass db to it as an argument.
Anthony
On Saturday, March 19, 2011 3:32:08 PM UTC-4, LightOfMooN wrote:
> Yes, I know it. I very like bluebream because of pull (it's not for
> propagation :)
> And it's too hard for me to develop without it, but I try.
>
> So, maybe is there a way to prepare some variables in some function
> and then use it by calling prepare-function from needed function?
>
> Something like:
>
> mycontroller/
> def options():
> a = ...
> b = db(...).select()
> return dict(a=a, b=b)
>
> othercontroller/
> def index():
> options = mycontroller/options()
> local_one = ...
> return dict(local_one=local_one, options=options)
>
> index.html:
> {{=local_one}}
> {{if options['a']==True:}}
> helloworld
> {{pass}}
>
> Is there a way to do something like this? ( >>> options =
> mycontroller/options() <<< )
>
> On 20 мар, 00:20, Massimo Di Pierro <[email protected]>
> wrote:
> > There are two types of frameworks: push and pull.
> >
> > In push once controller pushes variables to one view.
> >
> > In pull one view pulls variables from multiple controllers.
> >
> > Web2py, Django, TG, Pylons, Pyramid, Flask, are push frameworks. You
> > are trying to use a push framework as a pull one and that is not a
> > good idea.
> >
> > You can ask the browser to pull variables. You can do is via Ajax or
> > using the LOAD helper.
> >
> > massimo
> >
> > On Mar 19, 2:06 pm, LightOfMooN <[email protected]> wrote:
> >
> >
> >
> >
> >
> >
> >
> > > How can I get variables in view from other controller?
> >
> > > For example:
> > > mycontroller/
> > > def options():
> > > return dict(a='hello', b='world')
> >
> > > and in some view I need something like this:
> >
> > > {{ options = mycontroller/options() }}
> > > {{=a}} {{=b}}