cd34
unread,Sep 21, 2010, 2:43:34 PM9/21/10Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Mako Templates for Python
I might be missing something somewhere:
models/cms.py:
class Element(Base):
__tablename__ = 'm_element'
id = Column(mysql.BIGINT(20, unsigned=True), primary_key=True,
autoincrement=True)
function = Column(Unicode(80))
lib/cms.py:
class CMS(object):
def article(self):
return render('element_article.mako')
So, Element.function = 'article' in this case, which required the
getattr since the function name is stored in a string.
${getattr(h.CMS(), element.function)()}
works, which removes the two lines. I'm not sure why I didn't see
that before. Too many hours staring at the code I guess. :)