Django-urldecorators is a reusable Django application which allows apply view decorators and middleware components depending on requested url.
Project description
Django-urldecorators is a reusable Django application which allows apply view decorators and middleware components based on requested URL.
The application is compatible with Django versions from 1.0 to 1.4.
Installation and usage
Run python setup.py install or add urldecorators directory to your PYTHONPATH (or use pip or easy_install).
In urls.py file replace from django.conf.urls import * by from urldecorators import *
Pass a list of decorators and/or middleware_classes as an argument to the url function.
Example urls.py file:
from urldecorators import * urlpatterns = patterns('', url(r'^private/$', include('example.private.urls'), decorators=['django.contrib.auth.decorators.login_required']), url(r'^articles/$', include('example.articles.urls'), middleware_classes=['django.middleware.cache.CacheMiddleware']), )
For the example configuration and usage see the example project included in the repository. It can be run using django-admin.py utility from the repository root:
$ django-admin.py syncdb --settings=example.settings --pythonpath=`pwd` $ django-admin.py runserver --settings=example.settings --pythonpath=`pwd`
Testing
Application tests can be simply run using django-admin.py utility:
$ django-admin.py test --settings=urldecorators.tests.settings --pythonpath=`pwd`
Alternatively you can include urldecorators in INSTALLED_APPS so that all the tests will be run automatically with your project test suite.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file django-urldecorators-0.4.tar.gz
.
File metadata
- Download URL: django-urldecorators-0.4.tar.gz
- Upload date:
- Size: 7.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b1e2948dd95de64fe8670226664aece576b575ea5dd105b441f299f065ac726a |
|
MD5 | 0aeab23437ce1f4e3fc09c9c72349275 |
|
BLAKE2b-256 | 52f3183fdf380b73ba8afca8d004fc9b2719cfb749d513b731644c1da2ce4383 |