{ "info": { "author": "Joe Jasinski", "author_email": "jjasinski@imagescape.com", "bugtrack_url": null, "classifiers": [ "Framework :: Django", "License :: OSI Approved :: BSD License", "Programming Language :: Python :: 2.6", "Programming Language :: Python :: 2.7", "Topic :: Utilities" ], "description": "## ABOUT ##\n\n[![Build Status](https://travis-ci.org/ImaginaryLandscape/django_site_config.svg?branch=master)](https://travis-ci.org/ImaginaryLandscape/django_site_config)\n[![Downloads](https://pypip.in/download/site_config/badge.svg)](https://pypi.python.org/pypi/site_config/)\n\nThis module provides you an API that lets you code django\napplications such that those apps can segment themselves \ninto multiple sections and have different settings for each\nsection. \n\nFor example, say I want to use the same app under two different\nurl paths and have different behavior (different settings) for both. \n\n /mysite1/myapp/\n /mysite2/myapp/\n\nAlso, say I want to enable or disable individual apps on those different \nurls, via an admin interface. \n\nAlso, say I want to have a consistent way to define settings for those apps.\n\n\nThis module helps you to accomplish those things. \n\n## INSTALL ##\n\nInstall from pip\n\n pip install site_config\n\nInstall from Github\n\n git clone https://github.com/ImaginaryLandscape/django_site_config.git\n\n\n## CONFIGURATION ##\nThis application allows you to specify different siteconfig backends. \nThe siteconfig backend is responsible for getting and setting settings\nfrom/to a persistent location. \n\nCurrently, two backends are present in this module:\n\n - model_backend\n - settings_backend\n \nThe model_backend stores configuration settings in a set of database\nmodels. It allows for customizing the settings for a given app inside\nof the admin interface and allows for different settings for different\n'websites' inside an app. Choosing this backend enables an Django\nadmin module for setting these settings.\n\nThe settings_backend is a simple backend that uses settings.py. This\nis not dynamic; when an application needs a setting, this backend just\nlooks it up from settings.py.\n\n\nAdd to INSTALLED_APPS in settings.py\n\n 'site_config',\n \n # If using model_backend\n 'site_config.backends.model_backend',\n \n # if using settings_backend\n 'site_config.backends.settings_backend',\n\nIf the model backend is used, the Website, Application, and\nWebsiteApplication models defined in models.py should appear in the\nDjango admin. If the settings backend is used, they should not appear.\n\nSite specific base templates may also be used if the following context\nprocessor is add to `TEMPLATE_CONTEXT_PROCESSORS` in settings.py\n\n 'site_config.context_processors.decide_base_template'\n\nThis sets a new context variable `base_template` so that the contents\nof your `base.html` template can extend a variable. Instead of\nincluding all template logic in your projects `base.html` template,\nyou can move this logic to another template (`base_site.html`, for\ninstance) and have `base.html` be:\n\n {% extends base_template|default:\"base_site.html\" %}\n\nNow in much the same way you can override templates (explained later\nin this document), you can create a `base_site.html` template inside\nyour site's template folder that will be used if present.\n\n### GLOBAL SETTINGS in settings.py ###\n\nSITECONFIG_BACKEND_DEFAULT (optional) = This specifies the default\nbackend that is to be used. If this setting is not defined, it\ndefaults to the model_backend.\n\nValid values for this are as follows:\n\n \"site_config.backends.model_backend.DatabaseBackend\" # model_backend\n \"site_config.backends.settings_backend.SettingsBackend\" # settings_backend\n\n\nSITECONFIG_BASE_TEMPLATE (optional) = This specifies what the default\nbase template should be when using the `decide_base_template` context\nprocessor. If this context processor is not used, this setting has no\neffect.\n\n\n### CONFIGURING THE settings_backend ###\n\nSet the following in settings.py\n\n- SITECONFIG_SITEAPP_STATUS (optional) - This sets whether or not apps\n using this module should be marked as active or not. Valid values\n are: \"disabled\", \"curtained\", or \"enabled\" The default is \"enabled\"\n\n- SITECONFIG_CURTAIN_MESSAGE (optional) = This sets the curtain\n message string when SITECONFIG_SITEAPP_STATUS is set to\n \"curtained\".\n\n\n### CONFIGURING THE model_backend ###\n \nYou need to run the following if using the model_backend:\n\n ./manage.py syncdb\n ./manage.py migrate \n\n\n## USAGE ##\n\nIn order to use this system, you have to implement several things \nin your application. \n\n1. Create a configuration class \n\t\n Create add the following class in a django app's __init__.py,\n models.py or some other location that is called when django first\n executes. Define \"application_short_name\" and\n \"application_verbose_name\" attributes.\n \n Implement the \"get_default_configs()\" method. This must return a\n configuration dictionary where the keys are the configuration\n variables for the application, and the values are nested metadata\n dictionaries.\n \n Each nested dictionary must contain 3 keys:\n - default = the default value that the key will take\n - field = a django Field instance used to validate the value\n - help (optional) = a help text entry that describes the key \n - choices (optional) = a list of tuples constraining the input.\n Only works with fields that are like ChoiceField that take\n choices as part of the constructor\n i.e. (('a_short_name','A text'),('b_short_name', 'B text'))\n \n You also need to register the config class with the \"register()\"\n method.\n \n See the example below:\n \n /path/to/myproject/myapp/__init__.py\n\t \n import site_config\n \n class FooSiteConfig(site_config.SiteConfigBase):\n \n application_short_name = \"foo\"\n application_verbose_name = \"Foo Application\"\n \n # Optionally override if you want to customize the backend\n # used for a given config.\n def get_backend(self):\n backend = getattr(settings, 'SITECONFIG_BACKEND_DEFAULT',\n 'site_config.backends.model_backend.DatabaseBackend')\n return backend\n \n def get_default_configs(self):\n return {'TEST_A':{'default':\"Test A default\", \n 'field':'django.forms.CharField', \n 'help':'Test A help text.'}, \n \"TEST_B\":{'default':1, \n 'field':'django.forms.IntegerField', \n 'help':'Test B help text.'}}\n \n site_config.registy.config_registry.register(MyAppSiteConfig)\n\n2. Enable and disable urls via enable_disable_website() decorator\n \n In order to make use django_site_config's ability to enable and\n disable particular views, you need to wrap your urls as follows.\n In order to use this website switching functionality, you need to\n pass in the \"website\" kwarg as part of the url string.\n \n /path/to/myproject/myapp/urls.py\n\n from django.conf.urls import patterns, include, url\n from site_config.decorators import enable_disable_website, decorated_includes\n from example.app_foo import FooConfig\n from .views import IndexView\n \n # Wrap a single url \n \n urlpatterns = [\n url('^(?P[\\w-]+)/foo/$', \n enable_disable_website(IndexView.as_view(\n template_name='index.html'), FooConfig), \n {}, \n name=\"app_foo_index\"\n )\n ]\n \n # OR you can decorate an entire include\n \n urlpatterns += decorated_includes(lambda func: enable_disable_website(func, BarConfig),\n patterns('', url(r'^(?P[\\w-]+)/bar/', include('example.app_bar.urls')))\n )\n \n Note: You can also use this enable_disable_website() function to decorate\n a django CBV or FBV according to the django documentation. \n \n Note: Your views must accept the 'website' keyword argument. \n \n3. Allow template overrides \n\n This module also provides a means to override templates for a\n specific site.\n \n FOR FUNCTION BASED VIEWS \n \n Normally, if a FBV defines a template_name parameter in the url,\n say \"index.html\", the view will lookup that template file via the\n normal template loader chain.\n \n However, the website_template_override() decorator will first try\n to lookup a url at \"[website]/index.html\" and then fall back to\n using the \"index.html\".\n\n /path/to/myproject/myapp/urls.py\n \n # Wrap a single url \n \n urlpatterns = [\n url('^(?P[\\w-]+)/foo/$', \n website_template_override(IndexView.as_view(\n template_name='index.html')), \n {}, \n name=\"app_foo_index\"\n )\n ]\n \n # OR you can decorate an entire include\n \n urlpatterns += decorated_includes(website_template_override,\n patterns('', url(r'^(?P[\\w-]+)/bar/', \n include('example.app_bar.urls')))\n )\n \n # OR you can use both decorators at once on an entire include.\n urlpatterns += decorated_includes(\n (\n lambda func: enable_disable_website(func, BarConfig),\n website_template_override,\n ),\n patterns('', url(r'^(?P[\\w-]+)/bar/', \n include('example.app_bar.urls')))\n )\n \n You then need to accept the website variable as a keyword argument\n to your view function. The website variable can be used in your\n view logic.\n \n /path/to/myproject/myapp/views.py\n \n # Function based view example\n def index(request, template_name, website=None, *args, **kwargs):\n config = BarConfig(website=website)\n return render_to_response(template_name,\n {'config':config,},\n context_instance=RequestContext(request))\n\n FOR CLASS BASED VIEWS\n \n You should use the WebsiteOverrideTemplateViewMixin to allow for\n the template override behavior.\n \n /path/to/myproject/myapp/views.py\n \n\t\tfrom site_config.utils import WebsiteOverrideTemplateViewMixin\n\t\tfrom site_config.decorators import website_template_override\n\t\tfrom example.app_bar import BarConfig\n\t\t\n\t\tclass IndexView(WebsiteOverrideTemplateViewMixin, TemplateView):\n\t\t \n\t\t def dispatch(self, request, *args, **kwargs):\n\t\t self.website = kwargs.get('website', None)\n\t\t self.config = BarConfig(website=self.website)\n\t\t return super(IndexView, self).dispatch(request, *args, **kwargs)\n\t\t \n\t\t def get_context_data(self, **kwargs):\n\t\t kwargs['config'] = self.config\n\t\t kwargs['website'] = self.website\n\t\t return kwargs\n \n4. You can access settings in the view or template by calling the settings\n like you would an attribute on the config class. \n \n Here is a usage example:\n\n\t from example.app_foo import FooConfig\n\t c = FooConfig(website=\"joesite\")\n\t c.TEST_A\n\t c.TEST_B\n\t \n Note:\n in order for the settings to be looked up dynamically (on each request), the\n config class must be instantiated inside the view with the proper\n website passed to the constructor (or None) on every request to the view.\n\n\n## TEMPLATE OVERRIDES ##\n\nYou can override the template below to customize the curtain\npage that displays when a Website Application as marked as\n\"curtained\". Note, the default template extends \"base.html\"\nso this will need to be present in your application. \n\n site_config/curtained.html\n\n \n## TESTING ##\n\n pip install -e .[testing]\n cd example/\n ./manage.py test site_config\n", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/ImaginaryLandscape/django_site_config", "keywords": "django site config configuration", "license": "", "maintainer": "", "maintainer_email": "", "name": "site_config", "package_url": "https://pypi.org/project/site_config/", "platform": "", "project_url": "https://pypi.org/project/site_config/", "project_urls": { "Homepage": "https://github.com/ImaginaryLandscape/django_site_config" }, "release_url": "https://pypi.org/project/site_config/0.1.3/", "requires_dist": null, "requires_python": "", "summary": "Django configuration Utility to manage multiple \"websites\" in a project. ", "version": "0.1.3" }, "last_serial": 2804501, "releases": { "0.0.11": [ { "comment_text": "", "digests": { "md5": "06d0d2b798c8e823494e14b5a1ac63ad", "sha256": "1c49c29f588bcec7647b4c67f35abe27bb6f41d8a6ee1f7d07ecaa48fe041bb1" }, "downloads": -1, "filename": "site_config-0.0.11.tar.gz", "has_sig": false, "md5_digest": "06d0d2b798c8e823494e14b5a1ac63ad", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 25693, "upload_time": "2015-01-08T22:11:35", "url": "https://files.pythonhosted.org/packages/51/24/786612291eabcf0f1a18477bca909cf25abf621f5b35ae1f89df25fe89d0/site_config-0.0.11.tar.gz" } ], "0.0.13": [ { "comment_text": "", "digests": { "md5": "a90eb6c451afeeab005b3875a0b69e0e", "sha256": "5451b768a7e4785bdfb8e5f9f62b68dd2c1947f70ccb56aa33706fb09b2cf44c" }, "downloads": -1, "filename": "site_config-0.0.13.tar.gz", "has_sig": false, "md5_digest": "a90eb6c451afeeab005b3875a0b69e0e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 25165, "upload_time": "2015-01-09T21:30:13", "url": "https://files.pythonhosted.org/packages/16/40/2f3dc9143b97cc31e73054899d37b72b54363d06fc28d205c910686cbb51/site_config-0.0.13.tar.gz" } ], "0.0.14": [ { "comment_text": "", "digests": { "md5": "762fd503814da75ec9b2119472a4e584", "sha256": "dc8a294a5d81c691ef8471098af3c45abdaca55197d69952b3e8780bb9dba57f" }, "downloads": -1, "filename": "site_config-0.0.14.tar.gz", "has_sig": false, "md5_digest": "762fd503814da75ec9b2119472a4e584", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 26108, "upload_time": "2015-02-27T18:23:13", "url": "https://files.pythonhosted.org/packages/d6/50/8569517ea756817ff5984e93d5521290be67832785b3cf04a4f3c62b2baf/site_config-0.0.14.tar.gz" } ], "0.0.15": [ { "comment_text": "", "digests": { "md5": "173623942bd79fa5da0e074b4bdc1324", "sha256": "95273cd5d6208cf8abb7b2d5c8818d9ff83709a70619908876f25710d497a7e8" }, "downloads": -1, "filename": "site_config-0.0.15.tar.gz", "has_sig": false, "md5_digest": "173623942bd79fa5da0e074b4bdc1324", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 28728, "upload_time": "2015-08-27T14:52:41", "url": "https://files.pythonhosted.org/packages/f9/a6/026c05ed42298f2c580efc24025f7f013ba7a6a622845d970402605fa262/site_config-0.0.15.tar.gz" } ], "0.0.2": [ { "comment_text": "", "digests": { "md5": "7c96be17cd30e899527b62f0f435b2a8", "sha256": "15e8bfac2ba683821025396b93295156bfd87cb2d2f4d9c0f0929630d08f443b" }, "downloads": -1, "filename": "site_config-0.0.2.tar.gz", "has_sig": false, "md5_digest": "7c96be17cd30e899527b62f0f435b2a8", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 817, "upload_time": "2014-08-13T19:01:40", "url": "https://files.pythonhosted.org/packages/62/c9/0b2d2a957b8509f366a9ecc2ccd46b4e64455aae7dd1c74b12fdddc8efd0/site_config-0.0.2.tar.gz" } ], "0.0.3": [ { "comment_text": "", "digests": { "md5": "c158e7fcfac5f922f75ef8272f379e99", "sha256": "09e2745ab322c44f1fc834bb699fdcf02e10bcf4b7fae20254d1dfd39479b7c4" }, "downloads": -1, "filename": "site_config-0.0.3.tar.gz", "has_sig": false, "md5_digest": "c158e7fcfac5f922f75ef8272f379e99", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 818, "upload_time": "2014-08-13T19:20:00", "url": "https://files.pythonhosted.org/packages/14/f5/6e24dd87daa1740ad5d26b45d6ac4e7caaaf49d2d44dcc031f01c86535f3/site_config-0.0.3.tar.gz" } ], "0.0.4": [ { "comment_text": "", "digests": { "md5": "408acba72e62dc686578e2b301b85aa6", "sha256": "9762fa6390c788b74c6376e22b31eec875e1c2889169b8a9c92b72cd311dc331" }, "downloads": -1, "filename": "site_config-0.0.4.tar.gz", "has_sig": false, "md5_digest": "408acba72e62dc686578e2b301b85aa6", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4727, "upload_time": "2014-08-13T19:37:01", "url": "https://files.pythonhosted.org/packages/b5/f6/b73f40df85df4a8e06465e8911f54196364f9a3cc175c6a24fd8abd83714/site_config-0.0.4.tar.gz" } ], "0.0.5": [ { "comment_text": "", "digests": { "md5": "f5e8931e64cff6bf84e709d70d28103d", "sha256": "83e7b9bae807464f2ae0f3047141caa3675bc8cc3e1a21c0ccccdc432453ecef" }, "downloads": -1, "filename": "site_config-0.0.5.tar.gz", "has_sig": false, "md5_digest": "f5e8931e64cff6bf84e709d70d28103d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4721, "upload_time": "2014-08-14T20:50:45", "url": "https://files.pythonhosted.org/packages/dd/83/8810db71677433c0559865f2ea2fc7221ec046e8d94f108d25a58d354bcd/site_config-0.0.5.tar.gz" } ], "0.0.6": [ { "comment_text": "", "digests": { "md5": "7518547ee7467552023baaae48739f83", "sha256": "d30e8e5ef733508b9985e4388ff786a1719fc2fc746ffed9cf7d284750964003" }, "downloads": -1, "filename": "site_config-0.0.6.tar.gz", "has_sig": false, "md5_digest": "7518547ee7467552023baaae48739f83", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4724, "upload_time": "2014-08-14T21:44:57", "url": "https://files.pythonhosted.org/packages/55/28/318d656d03b52baa230317cbc003afcb8387e44645f28c74d5dbd9f840ed/site_config-0.0.6.tar.gz" } ], "0.0.8": [ { "comment_text": "", "digests": { "md5": "6c60a89b40f249cb1722f4ddbb71164a", "sha256": "db525369a1727f5b600b5e8c9a782843cce52b826aac95f472ca99eba2e53b59" }, "downloads": -1, "filename": "site_config-0.0.8.tar.gz", "has_sig": false, "md5_digest": "6c60a89b40f249cb1722f4ddbb71164a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 23883, "upload_time": "2014-09-12T23:04:08", "url": "https://files.pythonhosted.org/packages/17/c8/eadeca9cf59034bac204d6f743f15a512e8fcde3f9674c35df480c08a2f8/site_config-0.0.8.tar.gz" } ], "0.0.9": [ { "comment_text": "", "digests": { "md5": "d3a7fba78220003b3b9a9fb48e10302c", "sha256": "7ec5b0e55ed9829bffad21e15b780741668d7c045f800c320a70567b81fd9fac" }, "downloads": -1, "filename": "site_config-0.0.9.tar.gz", "has_sig": false, "md5_digest": "d3a7fba78220003b3b9a9fb48e10302c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 24828, "upload_time": "2014-10-02T14:18:51", "url": "https://files.pythonhosted.org/packages/63/e0/9bb6e78c498d79e84348ebfef39829c4960352b71495b1ee7e60e1773511/site_config-0.0.9.tar.gz" } ], "0.1.0a3": [ { "comment_text": "", "digests": { "md5": "97cac00ffbd3ba9bbd5985985911b5b9", "sha256": "cd78c99341d7114ee60b6a9e82b4b4cb3f5e39ee65a367971daab9e558a0175a" }, "downloads": -1, "filename": "site_config-0.1.0a3.tar.gz", "has_sig": false, "md5_digest": "97cac00ffbd3ba9bbd5985985911b5b9", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 22099, "upload_time": "2017-01-05T15:15:48", "url": "https://files.pythonhosted.org/packages/ef/98/fc869337772a33090e6161834e40efae6d2391469c1eeff0b99e92b31922/site_config-0.1.0a3.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "4fa1e2b75117c656383804ee45e81347", "sha256": "aec607e2f7eef6e95e2af83016961c3c99fc0dee9a41623a26f8697fb1cf0391" }, "downloads": -1, "filename": "site_config-0.1.1.tar.gz", "has_sig": false, "md5_digest": "4fa1e2b75117c656383804ee45e81347", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 22080, "upload_time": "2017-01-05T15:18:59", "url": "https://files.pythonhosted.org/packages/75/d7/e63dbe122964529c32e0a55498d56f6eb53839a3542b85c8b3292cf37852/site_config-0.1.1.tar.gz" } ], "0.1.2": [ { "comment_text": "", "digests": { "md5": "3454bfd23c89399ee374c5b4f1dbb36d", "sha256": "3f2465430cb2bdb02d0090eab435f6efa982d5c63fad37129b5cbaa64653878c" }, "downloads": -1, "filename": "site_config-0.1.2.tar.gz", "has_sig": false, "md5_digest": "3454bfd23c89399ee374c5b4f1dbb36d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 22466, "upload_time": "2017-01-19T23:32:18", "url": "https://files.pythonhosted.org/packages/f9/73/e16aa3f146b451299c732c0a510e39dc994e3de90eb8820b2cffbf16b7e9/site_config-0.1.2.tar.gz" } ], "0.1.3": [ { "comment_text": "", "digests": { "md5": "87af50a282bd14dbaeefff29592011a9", "sha256": "4e1ef1917b2c191b0104314329093d15e2478113f23521f16227db3c8234e6b9" }, "downloads": -1, "filename": "site_config-0.1.3.tar.gz", "has_sig": false, "md5_digest": "87af50a282bd14dbaeefff29592011a9", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 23658, "upload_time": "2017-04-14T19:22:40", "url": "https://files.pythonhosted.org/packages/b3/6c/c7df9b925fe4d98f2f5bd802047d64ec615c5e5e7a42eb5ce94af105569f/site_config-0.1.3.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "87af50a282bd14dbaeefff29592011a9", "sha256": "4e1ef1917b2c191b0104314329093d15e2478113f23521f16227db3c8234e6b9" }, "downloads": -1, "filename": "site_config-0.1.3.tar.gz", "has_sig": false, "md5_digest": "87af50a282bd14dbaeefff29592011a9", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 23658, "upload_time": "2017-04-14T19:22:40", "url": "https://files.pythonhosted.org/packages/b3/6c/c7df9b925fe4d98f2f5bd802047d64ec615c5e5e7a42eb5ce94af105569f/site_config-0.1.3.tar.gz" } ] }