[Zope] Problem with a python script

Andreas Pakulat ap125@informatik.uni-rostock.de
Thu, 22 May 2003 20:15:36 +0200


--/04w6evG8XlLl3ft
Content-Type: text/plain; charset=iso-8859-1
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

Hi,

got a really weird problem here:
Error Type: ValueError
Error Value: unsupported format character '"' (0x22) at index 45

testing the following python script:

## Script (Python) "create_tabheader"
##bind container=3Dcontainer
##bind context=3Dcontext
##bind namespace=3D
##bind script=3Dscript
##bind subpath=3Dtraverse_subpath
##parameters=3Dtabs=3D['tab1','tab2'],activetab=3D1
##title=3D
##
# Example code:

"""
Erzeugt den Tempalte-Code f=FCr die Karteikarten, damit wird der HTML-Code =
=FCbersichtlicher und ist nicht
statisch an die Anzahl an Karteikarten gebunden
"""

# Import a standard function, and get the HTML request and response objects.
=66rom Products.PythonScripts.standard import html_quote
request =3D container.REQUEST
RESPONSE =3D  request.RESPONSE

spsrc =3D context.getImage('spacer.gif')
wsrc =3D context.getImage('white-border-transp.gif')
ysrc =3D context.getImage('yellow-border-transp.gif')

fmtstr =3D '<tr><td style=3D"background-color:#006699;width:3px"><img src=
=3D"%s"' %(spsrc)
fmtstr +=3D ' style=3D"display:block" width=3D"3" height=3D"3"></td>'
fmtstr +=3D '<td style=3D"background-color:#FFFFFF"><table border=3D"0" cel=
lspacing=3D"0" cellpadding=3D"0"><tr>'

for i in range(0,len(tabs[:-1])):
	fmtstr +=3D '<td class=3D"tabborder"><img src=3D"%s" width=3D"3" height=3D=
"3"' %(spsrc)
	fmtstr +=3D '  style=3D"display:block"></td> '

fmtstr +=3D '<td style=3D"background-color:#FFFFFF"><img src=3D"%s" ' %(con=
text.getImage('border-begin.gif'))
fmtstr +=3D ' width=3D"3" height=3D"3" style=3D"display:block;width:2em;"><=
/td></tr><tr> '

lastelem =3D len(tabs)-1

for i in range(0,lastelem-1):
	if i =3D=3D activetab:
		fmtstr +=3D '<td class=3D"headernamewhite"><a class=3D"Karteikarte" '
		fmtstr +=3D ' href=3D"index_html?activetab=3D%d">%s</a></td>' %(i,tabs[i])
	else:
		fmtstr +=3D ' <td class=3D"headernameyellow"><a class=3D"Karteikarte"'
		fmtstr +=3D ' href=3D"index_html?activetab=3D%d">%s</a></td>' %(i,tabs[i])
=09
	if i+1 =3D=3D activetab:
		fmtstr +=3D '<td class=3D"headerborderwhite"><img '
	else:
		fmtstr +=3D '<td class=3D"headerborderyellow"><img'
=09
	if i =3D=3D activetab:
		fmtstr +=3D ' src=3D"%s"' %(wsrc)
	else:
		fmtstr +=3D ' src=3D"%s"' %(ysrc)
	=09
	fmtstr +=3D ' style=3D"display:block; width:2em; height:2em;" width=3D"10"=
 height=3D"10"></td>'

if activetab =3D=3D lastelem:
	fmtstr +=3D '<td class=3D"headernamewhite"><a  class=3D"Karteikarte" '
	isrc =3D wsrc
else:
	fmtstr +=3D '<td class=3D"headernameyellow"><a  class=3D"Karteikarte" '
	isrc =3D ysrc

fmtstr +=3D ' href=3D"index_html?activetab=3D%d">%s</a></td>' %(lastelem,ta=
bs[lastelem])
fmtstr +=3D '<td class=3D"headerborderwhite"><img src=3D"%s" ' %(isrc)
fmtstr +=3D ' width=3D"10" height=3D"10" style=3D"display:block;width:2em;h=
eight:2em"></td></tr></table></td>'
fmtstr +=3D '<td style=3D"background-color:#FFFFFF;width:95%"><img src=3D"%=
s"' %(spsrc)

fmtstr +=3D ' width=3D"3" height=3D"3"></td></tr>'

return fmtstr

The error is because of the last %(spsrc) on the third-last code-line
and I don't understand why it doesn't work there??

Andreas

--=20
You are so boring that when I see you my feet go to sleep.

--/04w6evG8XlLl3ft
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (GNU/Linux)

iD8DBQE+zRPIuekl0h+nrMIRAjAtAKCf1MPWrksz8pnQYIjZ1p4Dqdii+ACggQ0S
g5oiiEixqZgju0unCP+RN4o=
=C25L
-----END PGP SIGNATURE-----

--/04w6evG8XlLl3ft--