Hi all , We try to use DocumentTemplate not for HTML dynamic generation but for C++ generation. For convenience, and because we are familiar with Python we intend to use the Alternate Python String Format Syntax. The generation code is beautiful compared to our previous output.write("blah blah.... ") instructions. Reading the docs, looking at the Zope site, this behaviour doesn't seem to be shared by a lot of zope users. Moreover the Alternate Python String Format Syntax is poorly documented, and DTML features seems to be usable but the way they can be used seem very strange. Basically our needs are to use conditional structures, iterative structures and to call methods. The last point seems to be the hardest one. The following code shows a way to call python methods in python strings but 3 persons during half a day have been necessary to find it out. I suppose you can imagine my questions : Is there a natural and convenient way to find out PSFS expressions going from their DTML equivalent ? Is there a complete documentation on PSFS syntax ? Are the features of DTML and PSFS identical ? And the most important : Do you encourage us to keep on using PSFS instead of DTML ? Thank for your help Stephane my code ================================= import DocumentTemplate ########################################## class attr: def __init__(self,att): self.att = att def get_att(self): return self.att def get_num(self): return len(self.att) ########################################## l__list = [attr('aa'),attr('bb'),attr('cc')] l_str = DocumentTemplate.String(""" %(l_item fmt=get_att)s %(l_item fmt=get_num)3d %(in l_list)[ POUETPOUET %(sequence-var-get_att)s %(in)] """) dict = {'l_item':l__list[1], 'l_list':l__list} print l_str(None,dict)
participants (1)
-
Stephane Tallard