#12112: Allow terminal colors to be customized or disabled --------------------------------------+------------------------------------- Reporter: russellm | Owner: nobody Status: closed | Milestone: Component: django-admin.py | Version: 1.1 Resolution: fixed | Keywords: Stage: Accepted | Has_patch: 0 Needs_docs: 0 | Needs_tests: 0 Needs_better_patch: 0 | --------------------------------------+------------------------------------- Comment (by hunteke):
It's going to be hard to change momentum since [12009], nor do I necessarily think the Django devs should, but I offer this as a suggestion or "data point" in response to [comment:5 nbv4]. This is all by way of saying that one could (and I currently do) use a variable set in a settings file to decide whether to color the console output, that does not affect anyone but me. Further, I can store it in the repo so others can learn about a setting (or anything) they may not typically use. I typically develop on my laptop, for a server environment. Meaning: settings need to be both global and local (for example, I have a different DB setup, nor do I personally need to load some modules of code that I'm not actively developing). Until we're educated to the Better Way, this is the logic that enables us to have per-machine knobs twisted while maintaining global settings. Our solution was to use a {{{settings/}}} directory. This allows us to have multiple settings files that don't pollute the directory structure, and allows us to have to-the-point settings files for different environments. Once we did that, the {{{__init__.py}}} was mandatory, and the rest fell into place. {{{ NB: asterisks (*) put in to perhaps make the command line actions bold in some email clients. *$ find proj_dir/ -print | grep settings | grep -v ".pyc$"* proj_dir/settings proj_dir/settings/__init__.py proj_dir/settings/common_settings.py proj_dir/settings/kevin_hani.py proj_dir/settings/kevin_lina.py proj_dir/settings/passwords.py proj_dir/settings/passwords-sample.py *$ cat proj_dir/settings/__init__.py* import getpass, socket, sys, logging try: user = getpass.getuser() # or $ whoami (cmdline) host = socket.gethostname() # or $ hostname (cmdline) import_settings = 'from %s_%s import *' % (user, host) exec( import_settings ) # Load machine-specific settings except ImportError, e: logging.error( ' Could not import necessary file:\n---\n %s' % e ) try: from passwords import * # ... then load sensitive, non-Git-watched pwds. except ImportError, e: msg = ' Could not import passwords.py.\n---\n' msg += 'Have you set up a database account?\n' msg += 'Have you copied settings/passwords-sample.py to\n' msg += 'settings/passwords.py, with appropriate DB credentials?\n' logging.error( msg ) sys.exit() *$ cat kevin_hani.py* from common_settings import * # First, import all shared settings ... [... then do any further specific machine settings necessary ...] }}} -- Ticket URL: <http://code.djangoproject.com/ticket/12112#comment:6> Django <http://code.djangoproject.com/> The Web framework for perfectionists with deadlines. -- You received this message because you are subscribed to the Google Groups "Django updates" group. To post to this group, send email to django-upda...@googlegroups.com. To unsubscribe from this group, send email to django-updates+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-updates?hl=en.