[mod_python] PSP templates within publisher module

PETER BARKER newbarker at btinternet.com
Thu Mar 8 19:27:33 EST 2007

  That doesn't work because it's the client (browser) that constructs the fully qualified path to the image based on the path of the current resource (now .../ClientArea.py), and the path in the link. I got a 404 when I tried this suggestion.
  Here's the code of a stripped down version of the problem...
<img src="AnImage.jpg"/>
<a href="ClientArea.py/entryPoint">Clients' Area</a>

  from mod_python import psp
  def entryPoint(req):
  return psp.PSP(req,filename='index.psp').run()
  <Directory "C:/Program Files/Apache Software Foundation/Apache2.2/htdocs/PSPExample">
    AddHandler mod_python .py .psp
    PythonHandler mod_python.publisher | .py
    PythonHandler mod_python.psp | .psp
    PythonDebug On


Graham Dumpleton <graham.dumpleton at gmail.com> wrote:
  On 09/03/07, PETER BARKER 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.  or About
> us. 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.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mm_cfg_has_not_been_edited_to_set_host_domains/pipermail/mod_python/attachments/20070309/29150fe8/attachment.html

More information about the Mod_python mailing list