iain duncan schrieb:
> My question is whether I could instead add a custom helper function to
> the widget class definition and somehow have the template be able to
> call this function. [...]
>
> If I add a method to the widget the template does not have access to it.
Override the update_params method in the widget and add the function to the
params dictionary. This will give the template access to the function.
def foo():
return "Hello, World!"
class MyWidget(widgets.Widget):
template = """
<div xmlns:py="http://purl.org/kid/ns#" id="mywidget">
<p py:content="foo()" />
</div>"""
def update_params(self, params)
super(MyWidget, self).update_params(params)
params['foo'] = foo
HTH, Chris
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---