[Zope] Problem with a python script

Andreas Pakulat ap125@informatik.uni-rostock.de
Fri, 23 May 2003 17:30:37 +0200


--IJpNTDwzlM2Ie8A6
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On 23.Mai 2003 - 10:16:40, Passin, Tom wrote:
> [Andreas Pakulat]
> > got a really weird problem here:
> > Error Type: ValueError
> > Error Value: unsupported format character '"' (0x22) at index 45
> >=20
> > testing the following python script:
> >=20
> >....
> > fmtstr +=3D ' href=3D"index_html?activetab=3D%d">%s</a></td>'=20
> > %(lastelem,tabs[lastelem])
> > fmtstr +=3D '<td class=3D"headerborderwhite"><img src=3D"%s" ' %(isrc)
> > fmtstr +=3D ' width=3D"10" height=3D"10"=20
> > style=3D"display:block;width:2em;height:2em"></td></tr></table></td>'
> > fmtstr +=3D '<td=20
> > style=3D"background-color:#FFFFFF;width:95%"><img src=3D"%s"' %(spsrc)
> >=20
> > fmtstr +=3D ' width=3D"3" height=3D"3"></td></tr>'
> >=20
> > return fmtstr
>=20
> Even though Andreas is happy to have found the error, I would like to
> urge that Python scripts not be used to return markup at all.  Instead,
> return a data structure to the calling page and let the page format the
> data - either with dhtml or zpt, it doesn't matter in this regard.

I'm relatively new to Zope and ZPT and that way was the easiest to
accomplish the task. But I think I'll have a look again and try to get
that markup out of the scripts...

> 1)  They are designed exactly for taking data and formatting it into
> markup, so it is much easier to get the markup right and to spot errors.

But that can make the code very large. The same thing in ZPT has twice
the number of lines (and they were longer). And that was the reason for
putting it in a script, as I started with vi as editor, but that's
history now ;)

> 2) Page maintenance and changes in appearance are easy to do and do not
> affect the logic used in the scripts that create the data.

ACK

Andreas

--=20
Executive ability is prominent in your make-up.

--IJpNTDwzlM2Ie8A6
Content-Type: application/pgp-signature
Content-Disposition: inline

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

iD8DBQE+zj6duekl0h+nrMIRAqwEAJ9O6PVxqUaE64ZUP4dSsZmtD9bHKACgw9lK
7+vnjLCo6WEZwmFFbW5fLcM=
=tbV+
-----END PGP SIGNATURE-----

--IJpNTDwzlM2Ie8A6--