I'm trying to do the following:

>>> import ts_regex
>>> Z=ts_regex.compile('\(^\|[^%]\)%Z')
>>> ts_regex.gsub(Z, '\\1BAR', '%Z foo %Z')
Traceback (innermost last):
  File "<stdin>", line 1, in ?
  File "/usr/local/zope/SiteBox/lib/python/ts_regex.py", line 109, in
    try: return apply(self._f, args, kw)
  File "/usr//lib/python1.5/regsub.py", line 38, in gsub
    regs = prog.regs
AttributeError: regs

This works just fine if you don't compile the regex first:
>>> import ts_regex
>>> ts_regex.gsub('\(^\|[^%]\)%Z', '\\1BAR', '%Z foo %Z')
'BAR foo BAR'

The problem is that a ts_regex.compile instances do not expose the
attribute "regs" that the method gsub of lib/python1.5/regsub.py

I don't know the details of what is thread-safe and what is not in the
regsub module, so I won't hazard a patch here. Perhaps overriding
__getattr__ to return "regs" safely would help? I don't know.

I can also get it to work if I pass in the unwrapped compiled regular

>>> ts_regex.gsub(Z._r, '\\1BAR', '%Z foo %Z')
'BAR foo BAR'

Is doing this in Zope threadsafe?

Steve Alexander
Software Engineer
Cat-Box limited

Zope-Dev maillist  -  [EMAIL PROTECTED]
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope )

Reply via email to