Element/LiveElement do not allow genshifile templates
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
txGenshi |
Fix Released
|
High
|
Unassigned |
Bug Description
Using docFactory = genshifile(..) in an Element or LiveElement doesn't work. txGenshi currently expects to be able to get a reference to the renderable by adapting the Nevow context object. Element and LiveElement don't use the context--that is pretty much the reason they exist.
Typical traceback that occurs when the rendering machinery finds an Element with a genshifile loader:
Traceback (most recent call last):
File "/usr/local/
element = state.next()
File "/usr/local/
raise FlattenerError(e, roots, extract_
nevow._
<chichimec.
File "/usr/local/
element = stack[-1].next()
File "/usr/local/
yield _flatten(request, renderable.
File "/usr/local/
document = tags.invisible[
File "/usr/local/
return docFactory.
File "/usr/local/
renderer = inevow.
TypeError: ('Could not adapt', None, <InterfaceClass nevow.inevow.
Related branches
- Duncan McGreggor: Approve
-
Diff: 235 lines (+117/-29)5 files modifiedtxgenshi/loader.py (+75/-27)
txgenshi/test/example.py (+11/-2)
txgenshi/test/test_example.py (+25/-0)
txgenshi/util.py (+1/-0)
txgenshidemo/templates/element.xhtml (+5/-0)
Changed in txgenshi: | |
importance: | Undecided → High |
status: | New → Confirmed |
I think I can implement this with PEP 252(?) descriptors:
class NiftyDateWidget (LiveElement) : genshifile( 'blah.xhtml' ) # as usual
docFactory = loader.
...
class genshifile(object):
self.filename = filename
def __init__(self, filename):
self._cache = NOCACHE
def __get__(self, instance, cls): filename)
gf. object = instance
self. _cache = gf
if self._cache is NOCACHE:
gf = _GenshiFile(
else:
gf = self._cache
return gf
Then, the class _GenshiFile is what genshifile used to be; but load is modified
to use self.object instead of the context.