The view does not see objects created in the controller unless they are
returned in the dict from the controller function that was called. So, you
can do:
def view_func(arg1, arg2):
[do something]
return something
def index():
return dict(message='Hello World', func=view_func)
And in the view, you could call:
{{=func(arg1='this', arg2='that')}}
Note, functions defined in controllers are by default exposed for access
via HTTP requests unless they take arguments or start with a double
underscore, so be careful not to expose a function intended only for
internal purposes.
Another option is to define the function in a model file, in which case it
will be available in all views without needing to be passed from the
controller. You could also define the function in a module and import it in
the view.
Anthony
On Monday, August 13, 2012 8:34:41 PM UTC-4, dundee wrote:
>
>
> Hi All,
>
> Can I call custom functions in views? Functions that I have created in my
> controller/default.py.
>
>
>
> Thanks.
>
--