2006/1/7, Ksenia Marasanova [EMAIL PROTECTED]:
Hey,
I am trying to construct template property of a widget based on widget
parameters, in __init__ method:
class MyWidget(Widget):
def __init__(self, *args, **kwargs):
# just use textarea template for testing
kwargs['template'] =
div xmlns:py=http://purl.org/kid/ns#; py:strip=True
textarea name=${widget.name} id=${widget.name}
class=textarea_field
py:attrs=widget.attrs${widget_value}/textarea
span class=field_error
py:if=widget_error${str(widget_error)}/span
/div
super(MyWidget, self).__init__(*args, **kwargs)
But it doesn't work, here is the end of the traceback that looks relevant:
File [...]/turbogears/widgets/base.py, line 129, in insert
self.template)
File [...]/turbogears/view.py, line 61, in transform
engine, template = _choose_engine(template)
File [...]/turbogears/view.py, line 32, in _choose_engine
raise KeyError, \
KeyError: 'Template engine div xmlns is not installed'
Okay, I see it finally. I was using widgets devcast as a manual, but
it looks like since changeset 437 template cannot be assigned to a
widget instance, it can only be declared as a class variable (and
processed in __classinit__).
Never mind.
--
Ksenia