Graham Dumpleton
graham.dumpleton at gmail.com
Thu Mar 8 19:38:48 EST 2007
Sorry, didn't read it properly. Thought you were talking about including PSP snippets within other PSP files which were in same directory as publisher file. I shouldn't rush to respond when most of my attention is actually on something else. :-) I'll read your emails again properly later, but you may want to read the following in the interim: http://www.modpython.org/pipermail/mod_python/2006-March/020501.html This talks about problems with determining base URLs when using publisher and some code to help in this area. Graham On 09/03/07, PETER BARKER <newbarker at btinternet.com> wrote: > > Graham, > > 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... > > INDEX.PSP: > <html> > <head> > <title>Test</title> > </head> > <body> > <img src="AnImage.jpg"/> > <br> > <a href="ClientArea.py/entryPoint">Clients' Area</a> > </body> > </html> > > CLIENTAREA.PY: > from mod_python import psp > def entryPoint(req): > req.content_type='text/html' > return psp.PSP(req,filename='index.psp').run() > > APACHE CONFIGURATION: > <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 > </Directory> > > Regards, > > Pete > > 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: > > os.path.dirname(req.filename) > > 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. > > Graham > >
|