jeads/datazilla — pull request #17 by carljm (2012-05-14 23:34:27+00:00)
Title: Make import paths more reliable by making the top-level datazilla package explicit in the repo.

There's also one other change here that may require some discussion/explanation. Python always puts the current directory of the script file that it is running onto `sys.path`. This means that in general, putting script files inside an import hierarchy can cause problems, because it means suddenly anything adjacent to or beneath that script file can be imported under two different names. For a specific example, if "manage.py" is located at "datazilla/webapp/manage.py" and is executed as a script (e.g. "python ./manage.py"), now the "settings.py" adjacent to it can be imported either as "datazilla.webapp.settings" or as just "settings", because sys.path has both `$TOPLEVEL` and `$TOPLEVEL/datazilla/webapp` on `sys.path`. This can cause subtle and difficult-to-debug problems like unexpectedly shadowed top-level module names, and module-level code that is only supposed to execute once being executed twice, so it's best avoided altogether by ensuring that only one top-level directory in the codebase is ever placed on sys.path, and any scripts intended for direct execution are placed in that directory as well.

So in this pull request, I've yanked `manage.py` out to the top level, which solves this potential problem and also allows removing the `--python-path` directive from the `runfcgi` invocation (because the directory `manage.py` is in automatically goes on `sys.path`). We also have the same problem with the scripts in `admin/controller` - we may want to move those out as well, though I didn't do that yet.

If you'd like to keep these scripts separated deeper in the file-structure, we may want to talk about some alternative approaches; let me know.