{ "info": { "author": "Matthew Tretter", "author_email": "m@tthewwithanm.com", "bugtrack_url": null, "classifiers": [ "Environment :: Web Environment", "Framework :: Django", "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Operating System :: OS Independent", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3.4", "Topic :: Utilities" ], "description": "This project allows you to define your Django project's settings using classes\ninstead of modules. Among other things, this allows you to use inheritance and\ncalculated properties.\n\n.. image:: https://secure.travis-ci.org/matthewwithanm/django-classbasedsettings.png?branch=develop\n :target: http://travis-ci.org/matthewwithanm/django-classbasedsettings\n\n\nInstallation\n============\n\nThe easiest way to install is by using pip:\n\n.. code-block:: sh\n\n pip install django-classbasedsettings\n\nHowever you can also just drop the \"cbsettings\" folder into your pythonpath.\n\n\nSetup\n=====\n\nThe places where you're currently setting ``DJANGO_SETTINGS_MODULE``, you'll have\nto instead call ``cbsettings.configure``. So your manage.py will look something\nlike this:\n\n.. code-block:: python\n\n #!/usr/bin/env python\n import os\n import sys\n import cbsettings\n\n if __name__ == \"__main__\":\n os.environ.setdefault('DJANGO_SETTINGS_FACTORY', 'path.to.MySettings')\n cbsettings.configure()\n\n from django.core.management import execute_from_command_line\n\n execute_from_command_line(sys.argv)\n\nYou'll have to make a similar modification to your wsgi file:\n\n.. code-block:: python\n\n import os\n import cbsettings\n from django.core.wsgi import get_wsgi_application\n\n os.environ.setdefault('DJANGO_SETTINGS_FACTORY', 'path.to.MySettings')\n cbsettings.configure()\n\n application = get_wsgi_application()\n\n\nUsage\n=====\n\n\nBasic\n-----\n\nThe only real change you need to make to the settings.py file that Django\ncreates for you is to nest all the variables in a class:\n\n.. code-block:: python\n\n from cbsettings import DjangoDefaults\n\n class MySettings(DjangoDefaults):\n\n ADMINS = (\n # ('Your Name', 'your_email@example.com'),\n )\n\n MANAGERS = ADMINS\n\n DATABASES = {\n 'default': {\n 'ENGINE': 'django.db.backends.',\n 'NAME': '',\n 'USER': '',\n 'PASSWORD': '',\n 'HOST': '',\n 'PORT': '',\n }\n }\n\n # etc, etc\n\nNotice that the class extends ``DjangoDefaults``. By inheriting from this class,\nyou get all the default settings values that Django normally composites your\nsettings with. (These are pulled in from ``django.conf.global_settings`` so\nthey'll track with your version of Django, not classbasedsettings.) You can\nalso do stuff like this:\n\n.. code-block:: python\n\n class MySettings(DjangoDefaults):\n\n STATICFILES_FINDERS = DjangoDefaults.STATICFILES_FINDERS + (\n 'my.custom.StaticFileFinder',\n )\n\n # etc\n\nThese are just normal Python classes, so you can do anything you normally can:\n\n.. code-block:: python\n\n class MySettings(DjangoDefaults):\n\n @property\n def TEMPLATE_DEBUG(self):\n # Now a subclass can override DEBUG and TEMPLATE_DEBUG will be changed accordingly\n return self.DEBUG\n\n # etc\n\nCallable properties are automatically called:\n\n.. code-block:: python\n\n class MySettings(DjangoDefaults):\n\n TEMPLATE_DEBUG = lambda s: s.DEBUG\n\n...unless you don't want them to be:\n\n.. code-block:: python\n\n from cbsettings import callable_setting\n\n class MySettings(DjangoDefaults):\n\n @callable_setting\n def SOME_SETTING(self, *args, **kwargs):\n # This setting is actually a callable. The decorator tells cbsettings\n # not to invoke it to get a settings value.\n .\n .\n .\n\n # You can also use the decorator with functions defined elsewhere\n SOME_OTHER_SETTING = callable_setting(my_function)\n\nYou can also prevent your callable settings from receiving a \"self\" argument:\n\n.. code-block:: python\n\n from cbsettings import callable_setting\n\n class MySettings(DjangoDefaults):\n\n @callable_setting(takes_self=False)\n def SOME_SETTING(*args, **kwargs):\n .\n .\n .\n\n SOME_OTHER_SETTING = callable_setting(takes_self=False)(my_function)\n\n\nPer-App Mixins\n--------------\n\nTwo classes are provided to save you from having to type out long setting names:\n``PrefixedSettings`` and ``Appsettings``. These are meant for declaring subsets\nof your settings which share a prefix. The classes can then be mixed into your\nreal settings class.\n\n``PrefixedSettings`` will apply an arbitrary prefix, which can be provided via\na Meta class. If none is specified, it will extract the prefix from the class\nname:\n\n.. code-block:: python\n\n from cbsettings import PrefixedSettings\n\n class MyFancySettings(PrefixedSettings):\n VALUE = 5\n\nThe above will result in a setting named ``MY_FANCY_VALUE``. (You would get the\nsame result by naming the class ``MyFancy``\u2014without the \"Settings\" suffix.) If a\nprefix is specified, it will be used without manipulation. In other word:\n\n.. code-block:: python\n\n class MyFancySettings(PrefixedSettings):\n VALUE = 5\n\n class Meta:\n prefix = 'hello'\n\nwill result in a setting named ``helloVALUE``.\n\n``AppSettings`` is similar, but it uses a different Meta attribute and does a\nlittle extra formatting. In most cases, you'll want to use ``AppSettings`` and\nnot ``PrefixedSettings``:\n\n.. code-block:: python\n\n from cbsettings import AppSettings\n\n class MyAppSettings(AppSettings):\n VALUE = 5\n\nwill result in a setting named ``MY_APP_VALUE``. (You would get the same result\nby naming the class ``MyApp``\u2014without the \"Settings\" suffix.) If an app name is\nprovided explicitly, it will be uppercased and an underscore will be appended:\n\n.. code-block:: python\n\n class MyAppSettings(AppSettings):\n VALUE = 5\n\n class Meta:\n app_name = 'somebody_elses_app'\n\nwill result in a setting named ``SOMEBODY_ELSES_APP_VALUE``.\n\n\nUsing a Settings Factory\n------------------------\n\nYou might be thinking that hardcoding your settings class into files is just as\nbad as Django's hardcoding of the settings module. That's true. Which is why\n``configure()`` can be passed the path to any callable that returns a settings\nobject instance. So your manage.py might instead look like this:\n\n.. code-block:: python\n\n #!/usr/bin/env python\n import sys\n import cbsettings\n\n if __name__ == \"__main__\":\n cbsettings.configure('path.to.my.settings.factory')\n\n from django.core.management import execute_from_command_line\n\n execute_from_command_line(sys.argv)\n\nThen, in ``path/to/my/settings.py``:\n\n.. code-block:: python\n\n def factory():\n if 'DEV' in os.environ:\n return MyDebugSettings()\n else:\n return MyProductionSettings()\n\nNow you can easily change which settings class you're using based on whatever\nconditions you want without having to make modifications to multiple files.\n\n\nUsing Switcher\n--------------\n\nUsing a factory method to determine which settings class to use is a powerful\nfeature! But usually you'll want to switch settings classes based on the same\nkinds of conditions, so django-classbasedsettings comes with a factory that'll\nhandle these common cases, and allow you to easily define simple conditions of\nyour own. It also uses a more declarative syntax, which makes it more organized\nthan a factory method. Here's how you use it in your settings file:\n\n.. code-block:: python\n\n from cbsettings import DjangoDefaults, switcher\n\n class MyProductionSettings(DjangoDefaults):\n DEBUG = False\n # etc\n\n class MyDevSettings(DjangoDefaults):\n DEBUG = True\n # etc\n\n class MyTestingSettings(MyProductionSettings):\n SOME_VAR = 'whatever'\n\n # You can use one of the preregistered conditions by passing kwargs. The\n # first class whose conditions are all met will be used.\n switcher.register(MyTestSettings, testing=True)\n switcher.register(MyDevSettings, hostnames=['mycompuer.home', 'billscomputer.home'])\n switcher.register(MyProductionSettings, hostnames=['theserver.com'])\n\n # ...or you can define your own simple checks as positional arguments. If\n # all of the values are truthy (and any kwarg checks pass), the class will\n # be used.\n switcher.register(MyDevSettings, 'dev.mysite.com' in __file__)\n switcher.register(MyDevSettings, os.environ.get('DEV'))\n\n # Callable positional arguments will be called, then checked for truthiness.\n switcher.register(MyDevSettings, lambda: randint(1, 2) == 2)\n\nYou can also use ``switcher.register`` as a class decorator:\n\n.. code-block:: python\n\n @switcher.register(hostnames=['theserver.com'])\n class MyProductionSettings(DjangoDefaults):\n DEBUG = False\n # etc\n\nThen, wherever you're calling ``configure``, pass it your module's ``switcher``\nvariable:\n\n.. code-block:: python\n\n cbsettings.configure('path.to.my.settings.switcher')", "description_content_type": null, "docs_url": null, "download_url": "http://github.com/matthewwithanm/django-classbasedsettings/tarball/master", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://github.com/matthewwithanm/django-classbasedsettings", "keywords": "settings,classbased,class-based", "license": "UNKNOWN", "maintainer": null, "maintainer_email": null, "name": "django-classbasedsettings", "package_url": "https://pypi.org/project/django-classbasedsettings/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/django-classbasedsettings/", "project_urls": { "Download": "http://github.com/matthewwithanm/django-classbasedsettings/tarball/master", "Homepage": "http://github.com/matthewwithanm/django-classbasedsettings" }, "release_url": "https://pypi.org/project/django-classbasedsettings/1.5.0/", "requires_dist": null, "requires_python": null, "summary": "Use classes to define settings.", "version": "1.5.0" }, "last_serial": 1924976, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "1201f70e8cee8f661f8adb5d98593acc", "sha256": "8a429b78992a09261e128c23b54dc8db6ac1f42b79fdc7e0e304bfbe01c2a370" }, "downloads": -1, "filename": "django-classbasedsettings-0.1.0.tar.gz", "has_sig": false, "md5_digest": "1201f70e8cee8f661f8adb5d98593acc", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4905, "upload_time": "2012-04-27T16:17:03", "url": "https://files.pythonhosted.org/packages/bf/31/a5cd11f370d351ed578ee7dc338938bdc538d2b79ff75d9186eb21fcd25f/django-classbasedsettings-0.1.0.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "2ffb0b25a013aed7cfbe1dde79a011ae", "sha256": "afa305154bf733f768805238aae46408783a9ce51523d5d19decb70a76788843" }, "downloads": -1, "filename": "django-classbasedsettings-0.1.1.tar.gz", "has_sig": false, "md5_digest": "2ffb0b25a013aed7cfbe1dde79a011ae", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5352, "upload_time": "2012-04-27T16:34:12", "url": "https://files.pythonhosted.org/packages/25/04/8866325ab305a7ffb2cadef146625eff545d256724e6a8f888254aecc44b/django-classbasedsettings-0.1.1.tar.gz" } ], "0.1.2": [ { "comment_text": "", "digests": { "md5": "6452e4f85e2fb2a51df16c0165a3b2a6", "sha256": "1fa92d9afe3d940eaed052783ad761c94395296b857bdbad3c32ddeb3d5b2917" }, "downloads": -1, "filename": "django-classbasedsettings-0.1.2.tar.gz", "has_sig": false, "md5_digest": "6452e4f85e2fb2a51df16c0165a3b2a6", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5324, "upload_time": "2012-04-27T16:40:36", "url": "https://files.pythonhosted.org/packages/77/b5/f11d57e3e6045ab575f376648b58c0b7814bac87fb834a5deb9ca7d5b470/django-classbasedsettings-0.1.2.tar.gz" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "2fe07ef2a4ca554b24aeb1b16d1dd1c9", "sha256": "33697ea48704058a554b6065ff889146ac83d9e115afd49edc423d9aa7c3fe6d" }, "downloads": -1, "filename": "django-classbasedsettings-0.2.0.tar.gz", "has_sig": false, "md5_digest": "2fe07ef2a4ca554b24aeb1b16d1dd1c9", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5836, "upload_time": "2012-05-11T00:52:23", "url": "https://files.pythonhosted.org/packages/fb/4a/6d349665b254f82f9dd2b847699ae5055d8704702336156f86663a457d71/django-classbasedsettings-0.2.0.tar.gz" } ], "1.0b.0": [ { "comment_text": "", "digests": { "md5": "77cec66874c0f3fee1305538e4d68ae8", "sha256": "7b312c74aee8520d4eaa0eee8088f78b594fcab2e717be26b2099007a5f651ef" }, "downloads": -1, "filename": "django-classbasedsettings-1.0b.0.tar.gz", "has_sig": false, "md5_digest": "77cec66874c0f3fee1305538e4d68ae8", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6981, "upload_time": "2012-05-31T04:19:20", "url": "https://files.pythonhosted.org/packages/de/25/8875ddd7c86c32c15adbb03bcc61dcf53a13ad04ba1ac84baa331ea73d86/django-classbasedsettings-1.0b.0.tar.gz" } ], "1.0b1": [ { "comment_text": "", "digests": { "md5": "1444977461882f05309f4800855bae74", "sha256": "c496efe2e591131bbdcdc66abb7f880232da64dad52423ef0b05e750d2ee3f6a" }, "downloads": -1, "filename": "django-classbasedsettings-1.0b1.tar.gz", "has_sig": false, "md5_digest": "1444977461882f05309f4800855bae74", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6992, "upload_time": "2012-06-16T22:03:13", "url": "https://files.pythonhosted.org/packages/76/c7/e02bc5b12decd6155eba10969b0529579d42f3d173657c4e33b3d584ea42/django-classbasedsettings-1.0b1.tar.gz" } ], "1.0b2": [ { "comment_text": "", "digests": { "md5": "32a6de4ec5710cb24a3f718da2d82721", "sha256": "a70405640294b5d5399c11ba039f56ea8c0bfa8f3531e7f2c971e4aa9d64ce7e" }, "downloads": -1, "filename": "django-classbasedsettings-1.0b2.tar.gz", "has_sig": false, "md5_digest": "32a6de4ec5710cb24a3f718da2d82721", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6998, "upload_time": "2012-06-16T22:20:45", "url": "https://files.pythonhosted.org/packages/03/28/bcbd0bbd73a6f1f2f7dbd5a47c8f95cfa3ca56eaf3c534ff0ebac8fd2ba2/django-classbasedsettings-1.0b2.tar.gz" } ], "1.0b3": [ { "comment_text": "", "digests": { "md5": "6941f37dd3a40c64b35d1f1c29a21db4", "sha256": "41f885f79ba7e42de7993f290a21f547ca3a9c1c0c24f0367d0d5b144938ce39" }, "downloads": -1, "filename": "django-classbasedsettings-1.0b3.tar.gz", "has_sig": false, "md5_digest": "6941f37dd3a40c64b35d1f1c29a21db4", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7127, "upload_time": "2012-10-25T15:46:56", "url": "https://files.pythonhosted.org/packages/9d/f2/1aa797262130ec727a224f1947afc27fd435db7e8d40b45f598e71947c73/django-classbasedsettings-1.0b3.tar.gz" } ], "1.0b4": [ { "comment_text": "", "digests": { "md5": "eeacde0c8ee6c48180d9baca1477e0a0", "sha256": "70a6d077532ec0505d4ece362c9162045270c416a597d5b89b1a4c0c6185756e" }, "downloads": -1, "filename": "django-classbasedsettings-1.0b4.tar.gz", "has_sig": false, "md5_digest": "eeacde0c8ee6c48180d9baca1477e0a0", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7129, "upload_time": "2013-01-10T20:21:48", "url": "https://files.pythonhosted.org/packages/9f/3a/84b150787af1d228bcc5b7ae9cc45cb016b6c68cb1f28f37b66d89ad905d/django-classbasedsettings-1.0b4.tar.gz" } ], "1.1.0": [ { "comment_text": "", "digests": { "md5": "fcda6d4668838e1c0d627b434ae7aa25", "sha256": "aaff19df7ea9dbef555a5c4e7cb5a59cc11c7dec3ed91348a679ed9a7f2212f4" }, "downloads": -1, "filename": "django-classbasedsettings-1.1.0.tar.gz", "has_sig": false, "md5_digest": "fcda6d4668838e1c0d627b434ae7aa25", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7773, "upload_time": "2013-02-11T15:38:45", "url": "https://files.pythonhosted.org/packages/98/4a/59b8d9368b365a242ee480cf6ac5c958a878e8aa8bfef9cc13cc12890345/django-classbasedsettings-1.1.0.tar.gz" } ], "1.2.0": [ { "comment_text": "", "digests": { "md5": "d14b35684dea848b42d550e70f021f5e", "sha256": "dbc43d1c3574fcc35624949ecf1487d137a8d4d9deb84c8d277bf500cd9ff104" }, "downloads": -1, "filename": "django-classbasedsettings-1.2.0.tar.gz", "has_sig": false, "md5_digest": "d14b35684dea848b42d550e70f021f5e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9147, "upload_time": "2013-02-12T18:25:01", "url": "https://files.pythonhosted.org/packages/d3/95/63dd0b8be91ee1f6cbba473d6368c803969bf1fdf7a3c09219b655999ff1/django-classbasedsettings-1.2.0.tar.gz" } ], "1.2.1": [ { "comment_text": "", "digests": { "md5": "8468ed4ee8e917a1031abad06b31eae3", "sha256": "d68f5b3b6406d80c87b65b591b16f316229fda023d520b28e1041f2911cefdfe" }, "downloads": -1, "filename": "django-classbasedsettings-1.2.1.tar.gz", "has_sig": false, "md5_digest": "8468ed4ee8e917a1031abad06b31eae3", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9216, "upload_time": "2013-02-15T20:44:46", "url": "https://files.pythonhosted.org/packages/44/cb/6834bd36760674eb4bdcf7eab190a33a64cc1906b7aeac41c7569eb5c482/django-classbasedsettings-1.2.1.tar.gz" } ], "1.3.0": [ { "comment_text": "", "digests": { "md5": "43b5dc45c40c0facb3626540826288d3", "sha256": "c752fd0cb4f951fde20f6b66629df49537b8df6d4c24ceda19e57ac1b7aa103d" }, "downloads": -1, "filename": "django-classbasedsettings-1.3.0.tar.gz", "has_sig": false, "md5_digest": "43b5dc45c40c0facb3626540826288d3", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9678, "upload_time": "2013-05-21T05:03:01", "url": "https://files.pythonhosted.org/packages/fb/df/46307f1c28819e658db69634eb7db1a39e90a39e85d79713a97d81efcace/django-classbasedsettings-1.3.0.tar.gz" } ], "1.4.0": [ { "comment_text": "", "digests": { "md5": "fb8742912653cbe128c9c85ee5020272", "sha256": "37e73111115e6877f30328fc2193fac973d363e27f932d7dd7d6d3b41ae42c7b" }, "downloads": -1, "filename": "django-classbasedsettings-1.4.0.tar.gz", "has_sig": false, "md5_digest": "fb8742912653cbe128c9c85ee5020272", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10335, "upload_time": "2016-01-18T05:07:28", "url": "https://files.pythonhosted.org/packages/a1/94/9bcac46b57711a31beb4130c9eacde3c182069bfca2e7a1181049c6607e6/django-classbasedsettings-1.4.0.tar.gz" } ], "1.5.0": [ { "comment_text": "", "digests": { "md5": "1350d904a5757d25453d6ee48353ea12", "sha256": "c85708a85614c671e81d75e8781691c0e69a173ea6d25e54b366d6004dd8c5ee" }, "downloads": -1, "filename": "django-classbasedsettings-1.5.0.tar.gz", "has_sig": false, "md5_digest": "1350d904a5757d25453d6ee48353ea12", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10490, "upload_time": "2016-01-27T05:58:40", "url": "https://files.pythonhosted.org/packages/0a/74/fc3277e99781cdf624f1aaaf7c6c2ac2a6c82618a1c75b2ad1b0c2e8ba14/django-classbasedsettings-1.5.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "1350d904a5757d25453d6ee48353ea12", "sha256": "c85708a85614c671e81d75e8781691c0e69a173ea6d25e54b366d6004dd8c5ee" }, "downloads": -1, "filename": "django-classbasedsettings-1.5.0.tar.gz", "has_sig": false, "md5_digest": "1350d904a5757d25453d6ee48353ea12", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10490, "upload_time": "2016-01-27T05:58:40", "url": "https://files.pythonhosted.org/packages/0a/74/fc3277e99781cdf624f1aaaf7c6c2ac2a6c82618a1c75b2ad1b0c2e8ba14/django-classbasedsettings-1.5.0.tar.gz" } ] }