[mod_python] When I try to use include directive an SyntaxError error occurs

Андрей Долин androdol at yandex.ru
Mon Apr 10 10:12:39 EDT 2006


Salut, everybody.

When I try to use include directive an SyntaxError error occurs.
For example:

Mod_python error: "PythonHandler index::index"

Traceback (most recent call last):

  File "/usr/local/lib/python2.4/site-packages/mod_python/apache.py", line 299, in HandlerDispatch
    result = object(req)

  File "/home/mik/proj/python/pysite01/htdocs/index.py", line 8, in index
    template = psp.PSP(req, filename)

  File "/usr/local/lib/python2.4/site-packages/mod_python/psp.py", line 111, in __init__
    self.load_from_file()

  File "/usr/local/lib/python2.4/site-packages/mod_python/psp.py", line 179, in load_from_file
    code = compile(source, filename, "exec")

  File "/home/mik/proj/python/pysite01/htdocs/tst3.psp", line 8

    req.write("""
""",0); include file="tst4.psp";req.write("""

                 
                   ^

SyntaxError: invalid syntax


index.py content:

#
# there's some stuff here that the handler doesn't actually use....

from mod_python import apache, psp, util, Cookie, Session

def index(req):
    filename = "tst3.psp"
    template = psp.PSP(req, filename)
    return apache.OK


tst3.psp content:

<html>
<%
import time
%>
Hello world, the time is: <%=time.strftime("%Y-%m-%d, %H:%M:%S")%><br>
<%
%>
<% include file="tst4.psp"%>
</html>

tst4.psp content:

hello from tst4.psp

Apache config:
Alias /pysite01 "/home/mik/proj/python/pysite01/htdocs"
<Directory "/home/mik/proj/python/pysite01/htdocs">
    SetHandler mod_python
    PythonHandler index:index
    PythonPath "sys.path + ['/home/mik/proj/python/pysite01/htdocs']"
    PythonDebug On

    Order Deny,Allow
    Allow From All
</Directory>

system: FreeBSD 5.4, Apache 2.0.55, mod_python 3.2.8


I wonder why the error occurs.

---
Mik



More information about the Mod_python mailing list