[Zope] Questions about DocumentTemplate.

Mark Hammond MHammond@skippinet.com.au
Tue, 23 Mar 1999 18:24:35 +1100


Ive started playing with DocTemplate for a project, but I will be
using it sans Zope.  I hope this is still the appropriate
place...

I want DocTemplate to expose an object model, and it seems
perfect for the task.  However, Im having trouble using "."
expressions.

Code speaks louder than words, so my code is:
##
class Spam:
	def eggs(self):
		return "Eggs"

spam=Spam()

from DocumentTemplate import *
ss=HTML('Eggs are <!--#var expr="spam.eggs()"-->')
print ss(spam=spam)

ss=String('Eggs are %(spam.eggs)s')
print ss(spam=spam)
##

What Im hoping to do should be quite obvious - I want to refer to
"spam.eggs" in the DTML.

With the HTML example, #var expr="spam.eggs()" is the best I can
get.  It seems ugly to me, and I feel there must be a better way.

Using the String example, I can't make _anything_ work.

Any I missing something?  Is there something I can do so that
String('Eggs are %(spam.eggs)s') does what I want?

Please CC me - Im not on the list (but did peruse the archives
before mailing...)

Thanks,

Mark.