[mod_python] PSP templates within publisher module

Graham Dumpleton graham.dumpleton at gmail.com
Thu Mar 8 19:05:44 EST 2007

On 09/03/07, PETER BARKER <newbarker at btinternet.com> wrote:
> I have a website composed of some simple Python Server Page files and images
> in the same directory. The images are referenced from the pages without any
> qualification e.g. <img src="theimage.jpg"/> or <a href="about.psp">About
> us</a>. If the page is on
> http://localhost/company_name/index.psp, this works as
> http://localhost/company_name/theimage.jpg or
> http://localhost/company_name/about.psp is accessible. So
> far so good!
> I am adding a section to the website using the mod_python publisher handler.
> This will be implemented in a module called ClientArea.py. As part of this
> module, I want to be able to use the existing PSP files as templates and
> insert only the content relevant to the module. Assume I'm calling a
> function called "entryPoint" within this module, then the browser is now
> pointing at
> http://localhost/company_name/ClientArea.py/entryPoint. I
> am now having problems with the internal links because the unqualified link
> seems to be referring to an entity withing ClientArea.py - e.g.
> http://localhost/company_name/ClientArea.py/theimage.jpg.
> This resource doesn't exist though!
> I don't really want to duplicate the PSP pages and have one version with
> "../" prefixed. I also don't want to fully qualify the links.
> I welcome suggestions on what I should be doing here!

When working out relative pathnames, PSP will do the equivalent of:


to determine the base directory. For mod_python.publisher this will
not be want you want.

Provided you are using a new enough version of mod_python, before you
invoke PSP template, set:

  req.filename = '/some/directory/containing/psp/files/'

Ie., set it name of directory where PSP files are located. Ensure it
has a trailing slash.

BTW, I haven't tried this, but I think it should work.


More information about the Mod_python mailing list