I saw in another thread you still need this. If I'm not wrong what you
are pretending is to somehow render zpt on the fly. So, here is my idea:
I think you could perhaps create a new class to store the tal expression
attributes, let's say you called it ExpressionAttribute. This class
must be callable and be able to evaluate tal expressions. This is a
small sketch of how I think it should look like:
I would like to write things like:
object.property = 'here/anotherproperty'
object.anotherproperty = 'Barcelona'
and ask it like:
print object.property -> 'Barcelona'
<tal:city tal:replace='here/property' /> -> 'Barcelona'
Is this possible?
from Products.PageTemplates.ZopeTemplate import ZopeTemplate
#Here I also assume that you only enter the expressions
#without html and the tal part, like: 'here/property'
#Please also noticed that all sintax errors in your zpt
#code must be catched somewhere
def __init__(self, id, talExpr):
self.talExpr = '<span tal:replace="%s"/>' % talExpr
#I'm not sure about this, but I think it will create a Template on
self.zpt = ZopePageTemplate(id, text = self.talExpr)
#Note: I really don't know if you have to pass other parameters to
#pt_render, ie: the container of your property. You will have to test
Then, in the __init__ of your zope product you will need to do things
#This is a normal property
self.prop1 = prop1
#This two are tal expression properties
self.prop2 = ExpressionAttribute(prop1)
self.prop3 = ExpressionAttribute(prop1)
Then, I guess you can call it as:
yourProdObj.prop3 or in tal: here/prop3
I'm not sure about what I wrote and if this is what you are looking for.
I just hope it helps.
Zope maillist - Zope@zope.org
** No cross posts or HTML encoding! **
(Related lists -