On Sep 20, 6:19 pm, Tzury <[EMAIL PROTECTED]> wrote:
> Graham,
> It works with the simple code.py that prints 'hello world'
> However, when I brought a 'real world' application which has sub
> directories and modules and it new errors appears. It seems like I am
> missing a core part of knowledge in order to make it works.
>
> !httpd.conf!
> <Directory "C:/Program Files/Apache Software Foundation/Apache2.2/
> htdocs/a">
>     SetHandler wsgi-script
>     Options ExecCGI
> </Directory>
>
> !error.log!
> [Thu Sep 20 09:55:49 2007] [error] [client 127.0.0.1]   File "C:/
> Program Files/Apache Software Foundation/Apache2.2/htdocs/a/code.py",
> line 4, in <module>
> [Thu Sep 20 09:55:49 2007] [error] [client 127.0.0.1]     import
> admin, ajax, mobex, snf
> [Thu Sep 20 09:55:49 2007] [error] [client 127.0.0.1] ImportError: No
> module named admin
> [Thu Sep 20 09:55:49 2007] [error] [client 127.0.0.1]     import
> admin, ajax, mobex, snf
> [Thu Sep 20 09:55:49 2007] [error] [client 127.0.0.1] ImportError: No
> module named adminu Sep 20 09:55:49 2007] [error] [client 127.0.0.1]
> ImportError: No module named admin
>
> I put all my files under directory named 'a' under htdocs
>
> At the top of the application's code.py I have:
> import copy, web, re
>
> from web import form, template
>
> import admin, ajax, mobex, snf
>
> admin, ajax, mobex and snf  are modules of the project and they all
> work fine with the built-in server.
> When trying to run the application under Apache I get Internal Server
> Error on the browser and Python Import Error on the log file see
> below:
> Would I have to install my modules at site-packages so they will be
> known across or is there a better way handling that issue?

The WSGI script files are not treated like standard modules. Read:

  http://code.google.com/p/modwsgi/wiki/ReloadingSourceCode

I would as a result highly recommend you not give them a .py file
extension but use .wsgi.

Also, don't put your code modules in your document root anywhere as a
misconfiguration of Apache means that anyone could see your source
code. Put them elsewhere and append to sys.path in your script file to
indicate where they are located. It is because the directory the
script file is in is not in sys.path that the modules can't be found.

Graham


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web.py" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/webpy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to