[Zope] PSFS or DTML
Stephane Tallard
tallard@sagem.fr
Fri, 12 Mar 1999 09:58:21 +0100
Il s'agit d'un message multivolet au format MIME.
--------------46BAC34F26042FC3E496775C
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
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)
--------------46BAC34F26042FC3E496775C
Content-Type: text/x-vcard; charset=us-ascii;
name="tallard.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Carte pour Stephane Tallard
Content-Disposition: attachment;
filename="tallard.vcf"
begin:vcard
n:;Stephane Tallard
x-mozilla-html:FALSE
org:Softeam
version:2.1
email;internet:tallard@urd24.sagem.fr
x-mozilla-cpt:;0
tel;work:01 34 30 57 89
fn:Stephane Tallard
end:vcard
--------------46BAC34F26042FC3E496775C--