[Zope] 2.3.2 - external method re module
Dieter Maurer
dieter@handshake.de
Tue, 8 Jul 2003 20:08:07 +0200
Florian Konnertz wrote at 2003-7-8 00:40 +0200:
> I have to change all stx links in a dtml doc to html which is not done
> for any reason. It's an old zope (2.3.2) :( python is 1.5.2
> I tried with string.find, but i get a "string object has no atribute
> 'find'" error.
In Python 1.5.2, you use the "find" function in the module "string".
The "string" module is exposed as "_.string" in DTML.
> ...
> Here are the most simple pattern i tried, the double quotes quoted with
> \ and not, in triple quotes and not etc. Everytime i add the double
> quotes, my pattern fails.
I cannot tell you why it does not work for you in Zope.
I can tell you that regular expressions in External Methods
are treated the same way as in external scripts (with one
notable exception: you should not use compile regular expressions
in default function arguments).
Especially, there is no problem with '"'.
> ....
> url = r'["=]?((about|gopher|http|https|ftp|mailto|file):%s'
> % urlendchar
>
> this is the pattern i need:
> link = r'(".+?"):%s' % (url)
Looks like unbalanced "()":
In the "url" definition, I see 2 opening but one closing parenthesis.
Dieter