scipy / SciPyCentral

SciPy Central
http://scipy-central.org
BSD 3-Clause "New" or "Revised" License
16 stars 12 forks source link

MAINT: reorganize to a more Django 1.4+ style project layout #129

Closed pv closed 9 years ago

pv commented 11 years ago

The current project layout (e.g. location of manage.py, dealing with sys.path) is still somewhat Django <1.4 style. This fixes it up a bit.

The SPC site project is under spc_site. The SPC sub-apps are under scipy_central. Both of these directories contain only code and static files.

The run-time data directory is top-level data. Quickstart virtualenv goes to top-level env.

The settings is split to common + development settings.

ksurya commented 11 years ago

Some quick questions:

  1. Is development.py added to .gitignore (I havent found it)? Is it for general settings? Otherwise, it would be very to have a local_settings.py that does not appear in Git
  2. .gitignore seems to having lots of unwanted lines (may be we can clean that file too)

I have not run this code on my system but going through the code, it looks a lot cleaner! +1

Regarding this cleaning part, I have a small idea:

  1. remove scipy_central directory and placing all apps directly under main directory (this should be done very carefully)
  2. renaming 'spc_sitedirectory withspc`

What do you think about it?

pv commented 11 years ago

I think the idea would be to have development.py and production.py both checked in Git. But we might indeed still need the local_settings.py for passwords etc. that should not be checked in.

The default Django layout indeed places the apps directly on the top level. We have quite many of them, so this doesn't sound very attractive. Some people put them under an apps directory under the site project, but that seems to be mixing different things together. Or we could rename scipy_central -> apps and spc_site -> scipy_central or spc.

ksurya commented 11 years ago

If we have production.py its nice! and regarding local_settings.py, something like the below would be nice.. I am not sure the settings you configured would automatically search for local_settings.py in debug mode..

if debug:
   import .local_settings

This naming is also nice scipy_central -> apps, spc_site -> spc (these are short and simple).. We need to change all the namespaces in almost all files.. I wonder if it is even worth to put such an effort..

pv commented 11 years ago

Reorganization according to googling "django best practices layout"

The lack of local_settings.py is the idea that if you want something else than development, add a new file under settings/ and set the environment variable DJANGO_SETTINGS_MODULE. The tests however should be run against development.py.

Anyway, we shouldn't spend too much effort on optimizing this, if it looks sane I say it goes in, and I think everyone has a slightly different opinion anyway how this should look. :)

The advantages with this choice are (i) scipy_central is just an ordinary Python package that can in principle just be installed on the system, (ii) all dynamic content goes to a directory outside the package, (iii) this location can be adjusted by writing a suitable settings.py module and pointing DJANGO_SETTINGS_MODULE it it.

ksurya commented 11 years ago

Everythings looks good..

I am just not clear with config local settings (probably, I just don't know) oops.

To change the variable DJANGO_SETTINGS_MODULE pointing to different settings for production, development, are't we everytime changing manage.py I am just not able to understand how to load production settings and local settings automatically (if necessary) without adding into Git.

There Email variables, SPC dict, CDN Url variables are the main things that change!

PS: CI is not building (for some strange reasons its unable to download Whoosh)

pv commented 11 years ago

The systems gets the settings module name from os.environ, so on linux you can do

export DJANGO_SETTINGS_MODULE=scipy_central.settings.local
python manage.py

and on windows

set DJANGO_SETTINGS_MODULE=scipy_central.settings.local
python manage.py

and you can set it also on the Apache config.

(The Travis CI failure is probably just temporary random thing.)

ksurya commented 9 years ago

https://github.com/scipy/SciPyCentral/pull/191

addressed many of these changes.