[Zope-dev] Pb using Document Template

Stephane Tallard tallard@sagem.fr
Wed, 10 Mar 1999 14:31:49 +0100


Il s'agit d'un message multivolet au format MIME.
--------------CFA1A2F97CB153425563A282
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Hi all,


I have a problem using DocumentTemplate.String. I try to use the python
extended string syntax use it to generate C++ code .

I want DocumentTemplate to call a method for me and put the result in
the output file. But unfortunatly the doc is not that clear for that
particular use. I'm not sure that anyone here uses DocumentTemplate in
that way ...

Could you check my example code , where french people will recognize
typical  french idioms, and tell me where is the misuse  ?

The resulting error message is : Document Template Parse Error:
Document Template Parse Error: Invalid attribute name,
""_['toto'].myprint()"", for tag %(call  "_['toto'].myprint()")s, on
line 2 of <string><p>
Note that the first call doen't make an error, but is not interpreted as
a command.

Thanks
Stephane

my code
======================

import DocumentTemplate
l__att_type= "ATTTYPE"
l__att_name= "ATTTRIBUTE"
l__att_member_name = "ATTRIBUTEMEMBER"

results = """\
    %(call "coucou()")s
 %(call  "_['toto'].myprint()")s
"""

class TOTO:
 def __init__(self):
  self.coucou = "coucou"
  print self.coucou

 def myprint(self):
  print self.coucou

toto = TOTO()

def coucoucoucou():
    print coucoucou

dic =
{'is_date_att':1,'att_type':l__att_type,'att_name':l__att_name,'att_member':l__att_member_name,
'toto' : toto}

print dic
print dic['toto'].myprint()

print DocumentTemplate.String(results)(None, dic)








--------------CFA1A2F97CB153425563A282
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

--------------CFA1A2F97CB153425563A282--