Re: mod_python

2005-10-11 Thread Jim Gallacher
Python_it wrote:
> Today I was busy to install mod_python.
> 
> I have put the line
> 
> LoadModule python_module libexec/mod_python.so
> 
> into the httpd.conf file.
> It Works!
> Apache load mod_python /3.2.2.b Python2.4
> 
> But my problem is where I have to place te following code in de
> httpd.conf?
> 
> 
> AddHandler mod_python .py
> PythonHandler mptest
> PythonDebug On
> 
> 
> Because al the tutorials write this. But where?
> 
> If I try to put the code some where,
> apache give the following message by testing the configure:
> Multiple  arguments not (yet) supported
> But what i have to change or replace.

Your problem is not related to the location of the  section. 
Apache doesn't like spaces in , so try quoting your path. 
Also, the Apache docs state that "forward slashes should always be used 
as the path separator in Apache, even for Windows".

So try the following in your config file:
   .

> I test with the next file:
> 
> C:\Program Files\Apache Group\Apache2\htdocs\project\
> mptest.py
> 
> from mod_python import apache
> 
> def handler(req):
>req.content_type = 'text/plain'
>req.send_http_header()
>req.write('mptest.py\n')
>return apache.OK
> 
> Is this code enough for testing?
> 

Yes.

You are more likely to get timely help on the mod_python mailing list. 
See http://www.modpython.org/ for subscription information. Personally I 
only read c.l.p when I'm looking for cheap entertainment. Some people on 
this list just crack me up. :)

Regards,
Jim
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: mod_python and PHP sharing same session

2006-04-03 Thread Jim Gallacher
Scott wrote:
> I am trying to get a mod_python application to read an existing PHP
> session.  I need some data that was set in the session by the PHP
> application.  I am using the mod_python Session class but even when I
> specify the session id that PHP uses the Sesssion(req, sid) call
> returns a new session id.  The session file exists in /tmp as
> mp_sess.dbm and I have verified that PHP is reading/writing it and from
> what I have read mod_python will use the same file.  I have used the
> PythonOption session DbmSession in the Apache configuration to force
> this and specified the filename as well but to no avail.
> 
> Has anyone attermpted what I am trying to perform and if so a short
> snippet of code or explanation of how to interface to PHP session via
> mod_python would be great.  I am not an experiecne PHP users but have
> used mod_python extensively.
> Scott

It shouldn't be a suprise that this doen't work. Mod_python stores its 
session data as a python pickle. PHP stores its session data as... well 
I have no idea, but I'm pretty sure it won't be a python pickle. ;) 
Mod_python creates a new session if it can't load valid session data 
from the dbm file, which will always be the case here as that file 
contains PHP formatted session data.

You have 2 choices: Rewrite PHP session handling to write the data as a 
python pickle, or subclass mod_python BaseSession to read the PHP data 
format.  Once that's done you'll need to figure out how to handle 
session locking between the 2 modules, which may not be trivial.

I'd suggest joining the mod_python mailing list if you want to discuss 
this in detail.

Jim

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: mod_python + apache + winxp => nogo

2006-04-07 Thread Jim Gallacher
cyberco wrote:
> And I thought this would be trivial...getting mod_python to run within
> apache on windows XP.
> 
> =
> mod_python 3.2.8
> apache 2.0.55
> python2.4
> winxp
> =
> 
> After adding:
> "LoadModule python_module modules/mod_python.so"
> 
> to apache's httpd.conf, apache refuses to start, saying:
> "cannot load c://mod_python.so into server: the specified module
> could not be found"
> 
> 'mod_python.so' is in the modules folder under apache, though.
> 
> I've searched everywhere, but could not find a solution. Anybody here
> that has been successful in getting this combo to work?
> 

Surely not *everywhere*, since a similar question was posed on the 
mod_python mailing list just 3 days ago. ;)

For possible solutions see:
http://modpython.org/pipermail/mod_python/2006-April/020770.html

Jim
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: mod_python + apache + winxp => nogo

2006-04-07 Thread Jim Gallacher
Fuzzyman wrote:
> cyberco wrote:
> 
>>And I thought this would be trivial...getting mod_python to run within
>>apache on windows XP.
>>
>>=
>>mod_python 3.2.8
>>apache 2.0.55
>>python2.4
>>winxp
>>=
>>
>>After adding:
>>"LoadModule python_module modules/mod_python.so"
>>
> 
> 
> I'm no expert - having never tried that combination (but I have heard
> of it and you should try the mod_python mailing list).
> 
> However, if IIRC then a '.so' file is a UNIX type library file.
> (Possibly the equivalent of a dll on windows). This sounds awry to me.

It's an apache thing. Apache loadable modules have the same suffix on 
all platforms, so mod_python.so is correct.

Jim


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: mod_python + apache + winxp => nogo

2006-04-09 Thread Jim Gallacher
cyberco wrote:
> Thanks Jim, I indeed did not look in the mailinglist archive (you have
> to subscribe for that and Google didn't cache it yet).
> 
> The problem was indeed the missing .DLL's. After adding them to my
> 'PATH' variable apache was at least able to start. Unfortunately things
> still don't work. When I try to load a .py file I get the error:
> 
> ==
> [Sun Apr 09 14:03:46 2006] [error] make_obcallback: could not import
> mod_python.apache.\n
> [Sun Apr 09 14:03:46 2006] [error] python_handler: no interpreter
> callback found.
> [Sun Apr 09 14:03:46 2006] [error] [client 192.168.2.100]
> python_handler: Can't get/create interpreter., referer:
> http://myserver/test/
> ==

You are halfway there. Apache has found the mod_python loadable module, 
but now *it* can't find the correct mod_python lib files. This may 
happen when you have several different python versions installed on your 
system, and mod_python is trying to use the wrong one. If this is the 
case, adjust the path that apache sees so that the correct python 
appears first in the path.

> This seems more like a bug in mod_python. 

Not a bug - unless you consider poor documentation a bug ;). Your 
configuration is still not correct.

Any suggestions?

I'm not sure if our Windows guy reads c.l.p. on a regular basis and I'm 
rather clueless about Windows issues. Subscribe to the mod_python 
mailing list. You can always unsubscribe later. :).

Jim
-- 
http://mail.python.org/mailman/listinfo/python-list