txGenshi calls athena internal functions during rendering
Bug #502823 reported by
Cory Dodt
This bug affects 1 person
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
txGenshi |
Fix Released
|
High
|
Cory Dodt |
Bug Description
getObjectData avoids calling rendPageAttrs but will call athena LivePage attrs. Avoid doing so.
Related branches
lp:~corydodt/txgenshi/502823
Merged
into
lp:txgenshi
- Duncan McGreggor: Approve
-
Diff: 370 lines (+220/-48)5 files modifieddemo/templates/genshimix.xhtml (+7/-0)
txgenshi/loader.py (+91/-35)
txgenshi/test/example.py (+10/-8)
txgenshi/test/test_example.py (+22/-5)
txgenshi/test/test_loader.py (+90/-0)
Changed in txgenshi: | |
importance: | Undecided → High |
Changed in txgenshi: | |
status: | In Progress → Fix Committed |
To post a comment you must log in.
Yipes, really ugly one here. I'd like a code review on this please, when done.
There's a bit of a wtf for me in the original code:
rendPageAttrs = [x[0] for x in getmembers( rend.Page) ]
def getObjectData(obj):
...
if callable(member):
val = member()
...
return data
Wow, really? We call every callable member of the class during rendering, regardless of whether the template refers to it? To fix it for athena I had to do this, for starters:
class MyLivePage( athena. LivePage) :
"""
this evil hack is needed to work around a bug in getmembers+z.i
__provides__
Using zope.interface, you use __provides__ to discuss interfaces provided old.nabble. com/Problem- with-zope. interface- leaking- attributes- td25824576. html
by a class. However, see bug mentioned here: http://
This causes getmembers to blow up on LivePage. So this class exists so
that there is a class with the same members as LivePage, but which does
*not* have a broken __provides__ attribute, and now we can (ta-DA) use
getmembers on the subclass.
"""
__provides__ = None
livePageAttrs = [x[0] for x in getmembers( MyLivePage) ]
Then I'll also have to hide @renderer and @expose methods. But what about just.. application methods? They could do something with nasty side effects. Am I missing something here about how completely evil this isn't?