|
Brandon N
woodsman at gmail.com
Thu Oct 27 15:10:05 EDT 2005
Hello all,
I am new to mod_python and would like to switch some existing code of mine
away from php. I'd be very happy to get up and running with python.
Unfortunately, I've run into a snag or two. I currently have an apache
httpd.conf of the following:
<Directory /var/www/localhost/htdocs/py>
SetHandler mod_python .py
PythonPath "['/var/www/localhost/htdocs/py',
'/var/www/localhost/htdocs/py/Admin']+sys.path"
PythonHandler mptest
PythonDebug On
</Directory>
And a directory of:
/var/www/localhost/htdocs/py/
Admin/ LocalAdmin.py __init__.py mptest.py
__init__.py's contents:
__all__ = [ "Admin" ]
/var/www/localhost/htdocs/py/Admin/
Admin.py __init__.py
__init__.py's contents:
import sys
sys.path.insert( 0, '../' )
both Admin and LocalAdmin have similar code of:
class LocalAdmin( object ):
def __init__( self ):
self._var = -1
def var( self ):
return self._var
Though Admin defines the class as RemoteAdmin
mptest.py is:
from mod_python import apache
import LocalAdmin
import Admin
def handler(req):
req.content_type = 'text/plain'
req.send_http_header()
LA = LocalAdmin.LocalAdmin( )
#A = Admin.RemoteAdmin( )
req.write( "%s\n" % LA.var())
for l in dir( Admin ):
req.write( "%s\n" % l )
return apache.OK
This code works, with the output of
---
-1
__all__
__builtins__
__doc__
__file__
__name__
__path__
sys
---
So RemoteAdmin is not seen, though I can in fact import Admin...
Uncommenting the A = ... line throws an expected exception given the dir
results:
File "/var/www/localhost/htdocs/py/mptest.py", line 17, in handler
A = Admin.RemoteAdmin( )
AttributeError: 'module' object has no attribute 'RemoteAdmin'
Everything in the py and py/Admin have permissions:
rwxr-xr-x
Any clues as to what I'm missing?
Thanks in advance for any insight!
Cheers.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mm_cfg_has_not_been_edited_to_set_host_domains/pipermail/mod_python/attachments/20051027/6331dfe5/attachment.html
|