[mod_python] Code directory layout recommendations?

Guy Davis davis at guydavis.ca
Wed Sep 3 21:18:38 EST 2003


Hi all, 

Thanks for the answers to my previous question.  I'm now looking into
reorganizing our current directory layout of Python code.  I was
wondering what your Python web apps use for directory structures?

One idea was to have a directory for "page" modules (generate HTML
mostly), another for library modules, and another for unit tests.

Another possibility is to have a directory per major functional area. 
For example:
	
   functionA/
	-->  functionA_page.py
        -->  functionA_lib1.py
        -->  functionA_lib2.py
        -->  functionA_test.py

   functionB/
        -->  etc...

Both of the examples above are of the CVS workspace.  I'm also debating
whether the actual deploy (web-accessible) directories will be a one to
one mapping of the CVS workspace dirs or whether I'll just dump all the
Python files into one deployment directory.  Python files will be
installed into the web dirs using 'make' on a developer's workstation.

Either approach above would require some tweaks to sys.path.  Is the
standard way to do this is to stick all the required imports into a
single file and then have all other Python modules import it (appending
a relative path like ../../ to sys.path as needed)?  Any other
approaches?

It would be great to hear how you choose to layout your web app
directories and how it has worked out for you.

Thanks.
 



More information about the Mod_python mailing list