[Zope] how do i make a python script ?

Dieter Maurer dieter@handshake.de
Fri, 29 Jun 2001 22:44:28 +0200 (CEST)


Sven Fischer writes:
 > i have this z-class with a text element and i'd like to parse this text
 > before displaying it ? say, evrytime there is "zope" written in it i'd like
 > to replace it on the fly with <b>zope</b>.
 > 
 > i think the right direction to look at is a script (a pythonscript ?) that
 > would be called as a method on this element. am i right or a i wrong ? what
 > would the best starting point be ?
Python Script and the "re" module:

  *  you search the mailing list archive on how you enable "re"
     for use in Python Scripts ("import re" raises "Unauthorized"
     by default)

  *  you look in the Python library reference about regular
     expressions and the "sub" method.

If you want to just replace words, you can use "string.replace"
instead of "re". You would not need to learn how to
make "re" available in Scripts.


Dieter