[mod_python] Best way to use Session

Graham Dumpleton grahamd at dscpl.com.au
Mon Jun 13 01:03:14 EDT 2005


On 13/06/2005, at 1:31 PM, Adriano Monteiro wrote:

> Hi again Folks...
>
> Now I'm in trouble handling Sessions...
> I can't make it happen by anyway, and it also break my script
> sometimes... I just don´ t understand what is the matter with it.
>
> This is the way I'm importing it:
>
> from mod_python import apache, Session
>
> I was getting an error, saying that my page could not be found. When I
> took of the Session from the import, the error disapeared and the
> script worked.
>
> Is there another way like session = apache.import_module ('xxxx') to
> avoid this problem? I'm almost getting crazy with these bugs... :-/

You are going to have to provide the code for a complete, but small
example if you can, which exhibits the problem. You will need to be
clear about how any files are laid out in the directory hierarchy in
respect of each other and the steps to cause the problem to occur.

Your postings at the moment suggest you have both publisher handlers
and psp pages, plus within the publisher handlers you are explicitly
using the psp module to render pages. Are your problems when using
publisher by itself, or when you are also using the psp module from
within that publisher function? Are you using the same named publisher
code file, eg. index.py, in multiple directories at the same time?

You might want to read:

   http://issues.apache.org/jira/browse/MODPYTHON-9
   http://issues.apache.org/jira/browse/MODPYTHON-10
   http://issues.apache.org/jira/browse/MODPYTHON-11

if you are using the same named publisher file in multiple places. It
can in some circumstances explain why things aren't being found.

Don't know about ".pyc" files. Normally you wouldn't even have these
being created as Apache user would have permission to write to document
directory. If they are being delivered up for no reason when you aren't
even accessing them, can only surmise that it is perhaps in combination
with not found error above, use of Apache MultiViews and use of files
with the same basename and different extensions in the same directory.
ie., index.py and index.psp, with index.pyc file also existing.

You can turn off MultiViews using:

   Options -MultiViews

in your Apache configuration for your directory, but then you will need
to make sure you always use ".py" extension in your URLs.

Graham



More information about the Mod_python mailing list