David Fraser
davidf at sjsoft.com
Thu Sep 4 07:16:56 EST 2003
Guy Davis wrote: >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. > > If you're doing an almost-entirely mod-python based application like this (i.e. almost all your content is generated by mod_python rather than being static), you may find it better to have one handler in the main directory and let it choose which module to pass the other requests to. Then your directory structure is defined in Python code rather than by the file system. That's what we do David
|