[mod_python] problem using regular expressions in CGI scripts

Gregory Trubetskoy grisha at modpython.org
Thu May 18 09:15:50 EST 2000


Can you try running the same code in your own handler, and see where that
takes you, in other words:

httpd.conf:
AddHandler python-program .py
PythonHandler myhandler
PythonDebug

Then the myhandler.py file would have something like

--- snip ---

from mod_python import apache
import re, sys

def handler(req):

    req.content_type = 'text/plain'
    req.send_http_header()
    re.compile( r'foo(\(.+\))bar' )
    req.write('ok')
    return apache.OK

--- snip ---


Note that it is not necessary to print out the traceback - mod_python does
that for you if PythonDebug directive is specified.

Grisha


On Thu, 18 May 2000, Ralf Canis wrote:

> On Thu, May 18, 2000 at 02:39:46PM +0300, Erno Kuusela wrote:
> 
> Hello Erno,
> 
> > i haven't even installed mod_python yet, but a debugging idea
> > came to mind...
> > 
> > if you compile your regular expressions, they will have a .pattern
> > attribute that contains your regexp. it seem to me something
> > in mod_python may be munging/interpreting \-escapes, so if
> > you print the pattern out and it looks different from the
> > one you put in, you might be closer to figuring out what
> > is going on..
> 
> Yes, I thought so, too. Therefor I modified re.py in lib/python1.5
> at line 79 (re.compile) to print the pattern right before calling
> pcre_compile - it's the pattern I call it with :(
> Regarding this, I guess the problem is in prce_compile, but I did
> not investigate this further.
> 
> Ralf
> 
> -- 
> Ralf Canis            ralf at silicon.org
> Germany               canis at bigfoot.com
> _______________________________________________
> Mod_python mailing list
> Mod_python at modpython.org
> http://www.modpython.org/mailman/listinfo/mod_python
> 







More information about the Mod_python mailing list