* Roberto Rosario: " Re: [Mayan EDMS: 741] How do Settings Work?" (Tue, 15 Jul
  2014 20:49:50 -0700 (PDT)):

> Previously Mayan looked for a file called settings_local.py in the top 
> directory (same directory as manage.py), and this is was the only file 
> users needed to edit to change settings. This was fine for a while, but 
> allowed only one settings profile (production settings and development 
> settings were in the same while and needed conditional execution using the 
> DEBUG flag) and for users of the new pip package from PyPI created the 
> situation where there was no easy way to determine the location to put the 
> settings_local.py file. The settings_local method relied of customizing 
> Django's default settings.py and adding a try-except block to try to import 
> the settings_local.py and fail silently if it wasn't found.
> 
> Paul Whipp submitted changes based on the examples from Two scoops of 
> Django 
> (https://github.com/twoscoops/django-twoscoops-project/tree/develop/project_name/project_name/settings)
>  
> that turned Django's default settings.py file into a directory with an 
> __init__.py file (/mayan/settings/__init__.py) which allows to keep doing
> from mayan import settings and everything will still work indistinguishable
> from the rest of the code. The original the old settings.py file was cleaned
> and placed in /mayan/settings/base.py and a sample development settings file 
> was added in /mayan/settngs/development.py which shows how to import the 
> base settings and then extend or override your own. To use the new extended 
> settings file you would have to call the manage.py file with the --settings 
> parameter or else by default it would look only for the mayan.settings 
> file, for example ./manage.py runserver 
> --settings=mayan.settings.development, a very clean solution.
> 
> Django projects use a setting called SECRET_KEY that is used internally to 
> sign cookies and other cryptographic chores, this setting has to be 
> different for each install or it could be a security problem. In the past 
> Mayan assumed users would update this setting and not much though was 
> placed on the issue. Now we have a pip installer it is expected that Mayan 
> would be more available to users with no prior knowledge of Django so an 
> effort was made to create this random SECRET_KEY setting automatically 
> after Mayan was installed via pip.  This is the post_install method 
> mentioned before and here is where it happens 
> (https://github.com/mayan-edms/mayan-edms/blob/master/setup.py#L26). 
> Because this process creates a new setting, instead of pasting it at the 
> end of the mayan/settings/base file, (which is part of the git repository, 
> and not ideal for update) a new settings file specific only to the local 
> install is created, and this file is called local.py and located in 
> /mayan/settings/local, it imports everything from the /mayan/settings/base 
> file and just extends a new random SECRET_KEY. To avoid having users to 
> manually change to the /venv/lib/python2.7/site-packages/ directory and 
> look for the manage.py, a copy of this file is created called in 
> bin/mayan-edms.py and set to point by default to /mayan/settings/local so 
> that is just works out of the box and yet allows users to customize their 
> settings.
> 
> Hope this clear things up a bit.

Thanks, Roberto, for your exhaustive answer. Bookmarked internally for
integration in the dev part of the docs.


-- 

    Mathias Behrle
    PGP/GnuPG key availabable from any keyserver, ID: 0x8405BBF6

Attachment: signature.asc
Description: PGP signature

Reply via email to