mod_python help!
Olivier
om at oliviermigeon.com
Thu Feb 16 12:17:12 EST 2006
treelife a écrit :
> I'm getting and internal server error when | run the following
> mod_python script. I am actually trying to run Django.
>
> Script:
>
> from mod_python import apache
>
> def handler(req):
> req.content_type = 'text/plain'
> req.write("Under Construction")
> return apache.OK
You just cant't import mod_python.apache from the command line.
To run your scripts, you usually do things like (not tested):
try:
from mod_python import apache
APACHE = True
except ImportError:
# for when I'm outside Apache
APACHE = False
class DummyRequest:
"""Simulates a request object"""
def write(self, mstr):
print mstr
# you may need some other things...
def handler(req):
req.content_type = 'text/plain'
req.write("Under Construction")
if APACHE:
return apache.OK
######################
if __name__ == "__main__":
req = DummyRequest()
handler(req)
HTH,
Olivier
More information about the Python-list
mailing list