anything defined in models is visible everywhere, including views. You
just call

{{=myfunction(....)}}

On May 13, 10:39 am, carlo <syseng...@gmail.com> wrote:
> thank you Massimo for your "lesson", I realized I had no reason to
> call the function in the view and now I call it in the controller.
>
> By the way if I had the function in a model file how should I call it?
>
> mymodel.myfunction() ? Or by an import as for modules?
>
> carlo
>
> On 13 Mag, 17:01, mdipierro <mdipie...@cs.depaul.edu> wrote:
>
> > Not sure I understand. By definition functions defined in controllers
> > are not visible to views unless:
>
> > - the function is passed to the view "return dict(myfunc=__myfunc)"
> > - the function is defined in a model file
> > - the function is defined in the view itself {{...}} or a view that is
> > {{include '...'}}.
>
> > If the function is to be used in views only I suggest the third
> > approach.
>
> > Massimo
>
> > On May 13, 9:26 am, carlo <syseng...@gmail.com> wrote:
>
> > > I put some private functions in a controller:
>
> > > def __myfunc():
> > > a=request.vars.a
> > > b=request.vars.b
> > > myvalue=a+b
> > > return myvalue
>
> > > What is the correct syntax to get "myvalue" in a view of a different
> > > controller?
>
> > > carlo
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to