>
> where do I have to write a function lib based on my models and call it from
> my controllers only when I need it? I mean without put it in models??
>
*This should go in /modules*
# Lets say you wrote a file in /modules/modulex.py
*<modulex.py>*
from gluon import *
class MyClass(object):
def __init__(self, value):
self.value = value
def my_method(self):
return self.value.upper()
*</modulex.py>*
# Now, in your controller (or model if you need) you can do:
*<controllers/default.py>*
def index():
from modulex import MyClass
myobject = MyClass("banana")
lower = myobject.value
upper = myobject.my_method()
return dict(u=upper, l=lower)
*</controllers>*
# Then in related view:
*<views/default/index.html>*
<html>
{{=u}}
{{=l}}
</html>
*</views>*
Hope it helps!
---
Bruno Rocha
[zerp.ly/rochacbruno]