Hi,
I would like to call a Python function from within a TG widget template. How
can I do this? I tried:
def myfunc(x):
return 'test'
class MyWidget(Widget):
params = {'myfunc': 'pass a function in'}
myfunc = myfunc
template = '''... ${myfunc(1)}...'''
But that caused "TypeError: 'str' object is not callable". I guess TG is
spotting the param is a callable and (in an attempt to be helpful) calling
it. So I tried:
def outer():
def myfunc(x):
return 'text'
return myfunc
class MyWidget(Widget):
params = {'myfunc': 'pass a function in'}
myfunc = outer
template = '''... ${myfunc(1)}...'''
Now this just gives me "TypeError: 'NoneType' object is not callable" for a
reason I cannot figure out.
This must be a fairly common requirement - how do I do it? Thanks,
Paul
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---