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. --Roberto On Tuesday, July 15, 2014 9:15:17 PM UTC-4, Devin Ceartas wrote: > > Yeah, I'm staring from the Git clone because I am indeed a developer, and > will need to be making some significant extensions to the system for my > client. Django is obviously new to me, so I see I'll just have to take a > week off and learn that. Made it through the online documentation and > tutorials today and bought the "two scoops" book from Amazon. > > As it is, none of the instructions on the page you link to (or anywhere > else on the site) are quite complete enough to get me (a veteran developer > new to Django and relatively new to Python) past the initial setup without > struggle. Hopefully in a few weeks I'll be able to contribute some > significant additions to the documentation, perhaps linked off the existing > pages so as not to be in the way of those with Django experience, for new > comers such as myself. I do have full support from my employer to > contribute as much as I can from my work to the project and do the best we > can to be good citizens in the community. > > On Tuesday, July 15, 2014 5:45:33 PM UTC, Mathias Behrle wrote: >> >> * Devin Ceartas: " Re: [Mayan EDMS: 737] How do Settings Work?" (Tue, 15 >> Jul >> 2014 09:56:13 -0700 (PDT)): >> >> > post_install ? Is that a method I should call after doing the Git >> clone? >> >> No. If you are not familiar with running a Python app from a git clone, >> you are really better of to use the instructions on >> >> https://mayan.readthedocs.org/en/latest/intro/installation.html >> >> >> > On Tuesday, July 15, 2014 4:45:27 PM UTC, Roberto Rosario wrote: >> > > >> > > Agreed. >> > > >> > > The settings/local.py main purpose is to be able to create an >> automatic >> > > SECRET_KEY to increase security otherwise most users use the default >> > > SECRET_KEY. >> > > >> > > There is too much disparity better the PyPI and the local Git >> installation >> > > methods. Perhaps a startproject like management command for Mayan >> would be >> > > better than a post_install from setup.py as it would be available to >> both >> > > installation methods. >> >> I agree, that it would be nice to have the command separated from >> setup.py >> to be able to reuse it whenever it is needed. >> >> Basically I think the target audience of a git installation are >> developers, who >> anyway should be supposed to take care of their application paths and >> able to >> tweak their settings. Also it shouldn't be a great impact, when running >> dev >> installations from the default key. >> >> So separating the command would be nice, but a full fledged git install >> for me >> is not needed. >> >> >> >> > > >> > > On Tuesday, July 15, 2014 11:39:13 AM UTC-4, Mathias Behrle wrote: >> > >> >> > >> * Devin Ceartas: " Re: [Mayan EDMS: 733] How do Settings Work?" >> (Tue, 15 >> > >> Jul >> > >> 2014 08:14:06 -0700 (PDT)): >> > >> >> > >> > On Tuesday, July 15, 2014 10:00:28 AM UTC, Mathias Behrle wrote: >> > >> > > >> > >> > > * Devin Ceartas: " [Mayan EDMS: 731] How do Settings Work?" >> (Mon, 14 >> > >> Jul >> > >> > > 2014 >> > >> > > 14:24:19 -0700 (PDT)): >> > >> > > >> > >> > > > I'm afraid I'm going to have a number of ignorant questions as >> I >> > >> plow >> > >> > > into >> > >> > > > Mayan -- I have never worked with Django before, and am >> relatively >> > >> new >> > >> > > to >> > >> > > > Python, though I am anything but new to programming in >> general. >> > >> > > > >> > >> > > > It looks like there is some system of cascading .ini type .py >> files >> > >> > > which >> > >> > > > are parsed as settings files, and that Mayan has a long list >> of >> > >> them it >> > >> > > > adds on top of Django, documented >> > >> > > > at http://mayan.readthedocs.org/en/latest/topics/settings.html >> > >> > > > >> > >> > > > I see in the setup documentation, toward the end of the >> > >> > > > page >> > >> https://mayan.readthedocs.org/en/latest/intro/installation.html a >> > >> > > > mention of creating my own settings file. I presume this is >> one I >> > >> would >> > >> > > > create to layer on top of the others with my local >> modifications >> > >> and >> > >> > > > additions? The format seems relatively clear, such as adding: >> > >> > > > *WEB_THEME_VERBOSE_LOGIN = False* >> > >> > > > >> > >> > > > If I follow the docs here: >> > >> > > > https://docs.djangoproject.com/en/dev/topics/settings/ it >> looks >> > >> like I >> > >> > > need >> > >> > > > to add something to my wsgi setup to indicate where to find >> the >> > >> > > settings, >> > >> > > > and in mayan/wsgi.py I find the line: >> > >> > > > os.environ.setdefault("DJANGO_SETTINGS_MODULE", >> "mayan.settings") >> > >> > > > >> > >> > > > but I can't find any file named "mayan.settings". >> > >> > > >> > >> > > You find the file location and how to call it under Production >> use at >> > >> > > https://mayan.readthedocs.org/en/latest/intro/installation.html >> > >> > > >> > >> > > > Should there be one or do >> > >> > > > I only need one when I want to override defaults? >> > >> > > >> > >> > > The start command to use (bin/mayan-edms.py) refers to the >> local.py >> > >> file, >> > >> > > which >> > >> > > itself imports base.py containing all default settings. When >> running >> > >> from >> > >> > > defaults you don't need any additional configuration file at >> all. >> > >> > > >> > >> > > > Where should it be >> > >> > > > placed? Am I missing any other piece of this puzzle? >> > >> > > >> > >> > > Please look at the link above and feel free to ask again, if it >> > >> doesn't >> > >> > > solve >> > >> > > your problem. >> > >> > > >> > >> > > Cheers, >> > >> > > Mathias >> > >> > >> > >> > >> > >> > >> > >> > So far I'm more confused. I never ran bin/mayan-edms.py but the >> app is >> > >> > running fine >> > >> >> > >> How do you start the app? >> > >> >> > >> > -- the documentation for that command talks about creating >> > >> > folders etc. but those already exist, they came with what I cloned >> in >> > >> Git >> > >> > from the project. I added a line to local.py but that doesn't seem >> to >> > >> > effect anything. >> > >> >> > >> Cloning and running from git is different than installing from pypi. >> > >> >> > >> When you have *installed* the package via >> > >> >> > >> $ pip install mayan-edms==1.0.rc1 >> > >> >> > >> or some comparable command, then the configuration files in use are >> under >> > >> >> > >> venv/lib/python2.7/site-packages/mayan/settings/ (provided you used >> a >> > >> virtualenv as recommended and described). >> > >> >> > >> Probably you want also to adapt wsgi.py >> > >> (venv/lib/python2.7/site-packages/mayan/) to use the configuration >> file >> > >> of your >> > >> choice. >> > >> >> > >> @Roberto: I think it should point by default to the same >> configuration as >> > >> mayan-edms.py: >> > >> >> > >> os.environ.setdefault("DJANGO_SETTINGS_MODULE", >> "mayan.settings.local") >> > >> >> > >> ? >> > >> >> > >> >> > >> >> > >> -- >> > >> >> > >> Mathias Behrle >> > >> PGP/GnuPG key availabable from any keyserver, ID: 0x8405BBF6 >> > >> >> > > >> > >> >> >> >> -- >> >> Mathias Behrle >> PGP/GnuPG key availabable from any keyserver, ID: 0x8405BBF6 >> > -- --- You received this message because you are subscribed to the Google Groups "Mayan EDMS" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
