[mod_python] CSS not processed in PSP stylesheet

pit.grinja at gmx.de pit.grinja at gmx.de
Sun Jan 9 04:14:34 EST 2005

I have recently started to explore Server-side scripting with modpython, and
I am really impressed by its features. Without mod_python, things would have
been much more difficult.
However, I have a problem when applying a stylesheet to an XHTML page that
is dynamically generated via PSP. Here are the directives for my

DocumentRoot "C:/Programme/Apache/Apache2/htdocs"
<Directory />
    Options FollowSymLinks
    AllowOverride None
<Directory "C:/Programme/Apache/Apache2/htdocs">
    Options Indexes FollowSymLinks Multiviews ExecCGI
    AllowOverride None
    Order allow,deny
    Allow from all
<Directory "C:/Programme/Apache/Apache2/htdocs/pypublisher">
    AddHandler mod_python .py
    PythonHandler mod_python.publisher
    PythonDebug On
    Options Indexes FollowSymLinks Multiviews ExecCGI
    AllowOverride None
    Order allow,deny
    Allow from all
<Directory "C:/Programme/Apache/Apache2/htdocs/stylesheets">
    SetHandler None

In the directory /pypublisher, I have a html file with a form. This form
calls a *.py file which in turn uses the PSP module to generate the contents
from an XHTML template file.
The XHTML should be formatted via a CSS, but it is ignored. I browsed
through the archive and found that this error is caused by to main reasons:
1. The request for the CSS file is eaten up by a handler.
2. The CSS file is not found because the URI of a dynamically generated file
is not the same as that of a "static" one and thus the relative URI defined
in the template points to nothing.
For these reasons, I placed the stylesheets in my DocumentRoot and didn´t
define a handler. But it is still not working. What am I doing wrong?
The script contents are as follows:
#the file with the form
<form action="psptest.py/go" method="POST">
<input type="submit" width="200" height="50" value="Go"/>
#the python script psptest.py
from mod_python import psp

def go(req):
    req.content_type = 'text/html'
    template = psp.PSP(req,filename="template.xhtm")
#the xhtml template template.xhtm
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="/standard.css"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
<html xmlns="http://www.w3.org/1999/xhtml">
	<title>modpython Template test</title>
Hello World!
Additional comment:
When I copy-paste the content of the generated file into a new file,
it is correctly displayed in the browser.
Many thanks for your advice
(Mod_python, WinMe, Python 2.3.4, Apache 2.0.50)

+++ GMX - die erste Adresse für Mail, Message, More +++
1 GB Mailbox bereits in GMX FreeMail http://www.gmx.net/de/go/mail

More information about the Mod_python mailing list