simonseyer / ZUKS-Website

The official ZUKS Website
http://www.zuks.org
GNU General Public License v3.0
0 stars 1 forks source link

Split settings #2 #5

Closed simonseyer closed 10 years ago

simonseyer commented 10 years ago

See django example: https://code.djangoproject.com/wiki/SplitSettings#Multiplesettingfilesimportingfromeachother

It is very dangerous to change a versioned settings file to the local environment. You have to merge changes every time and you have to care that you don't push your local settings.

simonseyer commented 10 years ago

@monofox please review these changes

monofox commented 10 years ago

Seems to be fine. There is just one issue which is really not beautiful. If you've not created the local configuration file, there is no error handling and the corresponding administrator sit in front of long error messages with stack trace:

Traceback (most recent call last): (...) ImportError: No module named 'local_settings'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): (...) ImportError: Could not import settings 'zuks.settings' (Is it on sys.path? Is there an import error in the settings file?): No module named 'local_settings'

Could be more helpful to define it in the settings.py. I just prepared something. Will add it. Just a second.

monofox commented 10 years ago

See my last commit: Result:

$ python3.3 manage.py syncdb Could not load the local configuration settings!

monofox commented 10 years ago

Test failed. Get always the error message, that the local configuration could not be load.

simonseyer commented 10 years ago

@monofox I could not reproduce your problem. Could you describe it in more detail?

monofox commented 10 years ago

@Eldorado234 Yeah i can say the exact reason - i'm using Python 3 and the things have a little bit changed regarding the import. Import inside of a package differs to import outside of a package. If you make imports of another file inside of a package, than you have to use the complete module (e.g. from zuks.local_settings import ). This is not possible here - it is not resolvable - "local_settings" has first to be imported before using the corresponding import . There is ONE solution here: to use relative import (e.g. from . import local_settings). This leads to another problem: inside of the local_settings you cannot refer back to settings (obviously it's a great example of recursive dependency).

That's the problem. I'm pretty sure that the current solution will work on old python version. But it is not very fine to break the support of newer python versions.

monofox commented 10 years ago

Got it. Can you please check it for the old python 2.x version?

simonseyer commented 10 years ago

Everything works fine in python 2.x. But it is not such beautiful, that some of the settings are defined in the module file. Is there really no other solution?

monofox commented 10 years ago

Ha! After your messages i wonder, that it worked with the MIDDLEWARE_CLASSES. Because it was done in the same way as it was done with the project paths and dirs. I made the constants import now separate (for each constant one import). Now it works.

Fine in this way?

simonseyer commented 10 years ago

Perfect!