olarcheveque / django-urldecorators

Django-urldecorators is a reusable Django application which allows apply view decorators and middleware components depending on requested url.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Django-urldecorators is a reusable Django application which allows apply 
view decorators and middleware components depending on requested url.


Installation and usage:

    1) Run python setup.py install or add urldecorators directory to 
       your PYTHONPATH

    2) In urls.py file replace `from django.conf.urls.defaults import *`
       by `from urldecorators.defaults import *`

    3) Pass list of decorators and/or middleware_classes as argument
       to url function


Example urls.py file:

    from urldecorators.defaults 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']),
    )


Testing:

    # Setup testing enviroment (uses zc.buildout)
    cd test
    python bootstrap.py
    python bin/buildout-script.py
    # Run tests using miscellaneous Django versions
    bin/test-django-1.0
    bin/test-django-1.1
    bin/test-django-1.2
    bin/test-django-1.3
    # Create database
    bin/manage-django-1.0 syncdb
    # Run server using miscellaneous Django versions
    bin/manage-django-1.0 runserver
    bin/manage-django-1.1 runserver
    bin/manage-django-1.2 runserver
    bin/manage-django-1.3 runserver

About

Django-urldecorators is a reusable Django application which allows apply view decorators and middleware components depending on requested url.

License:Other