Dave Britton
dave at davebritton.com
Tue Jul 14 21:31:35 EDT 2009
download TextPad (and optionally install python syntax highlighting) and look at your file with "show whitespace" on. Or, download and install python for windows win32 "Pythonwin" and open your file in its script editor and check it with "tab nanny" (the icon to the right of the little running figure). It will show you the bad indents. ----- Original Message ----- From: "Graham Dumpleton" <graham.dumpleton at gmail.com> To: "Matt McKenna" <mmckenna at esri.com> Cc: <mod_python at modpython.org> Sent: Tuesday, July 14, 2009 6:35 PM Subject: Re: [mod_python] python apache help It could be a problem with line endings in the file. Ie. inconsistent use of CR and LF. Quite hard to tell because as soon as you post the file, such detail is lost. If you were on a UNIX system I would suggest you post the output of 'od' run against the file, but you are on Windows and that is probably all too hard. Graham 2009/7/15 Matt McKenna <mmckenna at esri.com>: > > > I am not a programmer but I do want to learn how to create some web apps > for use in my admin role at work and I have just started learning > Python. I would really appreciate any help with this problem. > > I am just getting into using python and am trying to setup an apache > server to do some web testing and I cannot get past this error. > ************************************************************************ > **** > > MOD_PYTHON ERROR > > ProcessId: 5784 > Interpreter: 'localhost' > > ServerName: 'localhost' > DocumentRoot: 'C:/wamp20h/www/' > > URI: '/test/mptest.py' > Location: None > Directory: 'C:/wamp20h/www/test/' > Filename: 'C:/wamp20h/www/test/mptest.py' > PathInfo: '' > > Phase: 'PythonHandler' > Handler: 'mptest' > > Traceback (most recent call last): > > File "D:\Python25\Lib\site-packages\mod_python\importer.py", line > 1537, in HandlerDispatch > default=default_handler, arg=req, silent=hlist.silent) > > File "D:\Python25\Lib\site-packages\mod_python\importer.py", line > 1202, in _process_target > module = import_module(module_name, path=path) > > File "D:\Python25\Lib\site-packages\mod_python\importer.py", line 296, > in import_module > log, import_path) > > File "D:\Python25\Lib\site-packages\mod_python\importer.py", line 680, > in import_module > execfile(file, module.__dict__) > > File "C:\wamp20h\www\test\mptest.py", line 3 > > def handler(req): > > ^ > > IndentationError: unexpected indent > > > MODULE CACHE DETAILS > > Accessed: Fri Jul 10 16:34:52 2009 > Generation: 0 > > _mp_d776aaec0b7e9783709d848459898c4a { > FileName: 'C:\\wamp20h\\www\\test\\mptest.py' > Instance: 1 [IMPORT] > Generation: 0 [ERROR] > Modified: Fri Jul 10 15:36:55 2009 > } > > ************************************************************************ > **** > > I am using a simple index.html to get to mptest.py > > Content of index.html: > > <a href="mptest.py">python test</a> > > > Content of mptest.py: > > from mod_python import apache > > def handler(req): > req.log_error('handler') > req.content_type = 'text/plain' > req.send_http_header() > req.write('mptest.py\n') > return apache.OK > > (I have removed any tab in the code and made sure that there are only 4 > spaces before the code lines.) > > Here is the entry that I have in my httpd.conf file to access the > directory where mptest.py lives: > > <Directory "c:/wamp20h/www/test"> > AddHandler mod_python .py > PythonHandler mptest > PythonDebug On > </Directory> > > I have the LoadModule line: LoadModule python_module > modules/mod_python.so in the httpd.conf file. > > > Here is the contents of my apache_error.log: > > ************************************************************************ > **** > > Traceback (most recent call last):, referer: http://localhost/test/ > File "D:\\Python25\\Lib\\site-packages\\mod_python\\importer.py", > line 1537, in HandlerDispatch\n default=default_handler, arg=req, > silent=hlist.silent), referer: http://localhost/test/ > > File "D:\\Python25\\Lib\\site-packages\\mod_python\\importer.py", > line 1202, in _process_target\n module = import_module(module_name, > path=path), referer: http://localhost/test/ > > File "D:\\Python25\\Lib\\site-packages\\mod_python\\importer.py", > line 296, in import_module\n log, import_path), referer: > http://localhost/test/ > > File "D:\\Python25\\Lib\\site-packages\\mod_python\\importer.py", > line 680, in import_module\n execfile(file, module.__dict__), > referer: http://localhost/test/ > > File "C:\\wamp20h\\www\\test\\mptest.py", line 3, referer: > http://localhost/test/ > > def handler(req):, referer: http://localhost/test/ > ^, referer: http://localhost/test/ > > IndentationError: unexpected indent, referer: http://localhost/test/ > > ************************************************************************ > **** > > I am using Apache version 2.2.11 under WAmp Server install. > > > > > Matthew > > > _______________________________________________ > Mod_python mailing list > Mod_python at modpython.org > http://mailman.modpython.org/mailman/listinfo/mod_python > _______________________________________________ Mod_python mailing list Mod_python at modpython.org http://mailman.modpython.org/mailman/listinfo/mod_python
|