[Zope] strange script behaviour
Marie Robichon
robichon at esrf.fr
Mon Jan 26 11:27:20 EST 2004
Hi everyone,
I have a script that loops thru' formulator and creates the insert sql
string (with a view to creating the sqlMethod on the fly). When I come to
multicheckbox fields I want enter the selected values into my db column by
separating them with a semi-colon. However when I want to do this part of
the script :
if field.meta_type=='MultiCheckBoxField':
sql=sql+"<dtml-in " + field.id + ">\n"
sql=sql+"<dtml-var sequence-item>;"
sql=sql+"</dtml-in>,"
the '/' of the </dtml-in> prevents the string from being rendered properly
and results in the following (and none of the line breaks appear):
....
values (, , , , , , , , , , , , , , , , ;,, ;,, , , , , ;, ;,, , , , , , ,
;,, , , , , )
However if I remove the '<' of the </dtml-in> and leave it '/dtml-in>, the
string renders ok:
....
values
(<dtml-sqlvar nom type=string >,
<dtml-in prestataire>
<dtml-var sequence-item>;/dtml-in>,
I don't understand at all since all I am doing is concatenating strings.
Thanks in advance for your help (full script below)
Marie Robichon
________________________________________________________
sql="insert into microtomo\n "
sql=sql+"("
for field in context.Formulator.get_fields():
if field.meta_type!='LabelField':
sql= sql+ field.id + ", \n"
sql=sql[:-3]
sql=sql+") \n values \n("
for field in context.Formulator.get_fields():
if field.meta_type!='LabelField':
if field.meta_type=='IntegerField':
type='int'
else:
type='string'
if field.is_required():
constraint=""
else:
constraint="optional"
if field.meta_type=='MultiCheckBoxField':
sql=sql+"<dtml-in " + field.id + ">\n"
sql=sql+"<dtml-var sequence-item>;"
sql=sql+"</dtml-in>,"
else:
sql=sql + "<dtml-sqlvar "+ field.id + " type="+type + " " +
constraint + ">,\n"
sql=sql[:-3]
sql=sql+">)"
return sql
More information about the Zope
mailing list