A enhanced permission system which enable logical permissionsystems to complex permissions
Project description
- Author
Alisue <lambdalisue@hashnote.net>
- Supported python versions
Python 2.6, 2.7, 3.2, 3.3
- Supported django versions
Django 1.2 - 1.6
An template based the flatpages like app. Not like django’s flatpages app, django-roughpages render a template file which determined from the accessed URL. It is quite combinient when you want to render simple static page. You do not need to prepare urls.py or views.py anymore for that kind of simple static page.
django-roughpages call roughpages.views.roughpage view with the accessed URL when django raise Http404 exception. The view automatically find the corresponding template file from roughpages directory in one of your template directories. Assume if the user accessed http://localhost/foo/bar/hoge/. If there is no urls pattern patched with the URL, django-roughpages try to find corresponding template file such as templates/roughpages/foo/bar/hoge.html. If django-roughpages find the corresponding template file, it will render the template and return the HttpResponse, otherwise it re-raise Http404 exception.
You can complicatedly select the corresponding template file. django-roughpages determine the filename with a backend system. The default backend is roughpages.backends.AuthTemplateFilenameBackend and it prefer hoge_anonymous.html or hoge_authenticated.html than hoge.html depends on the accessed user authentication state. Thus you can simply prepare the page for authenticated user as <something>_authenticated.html and for anonymous user as <something>_anonymous.html.
You can control the backend behavior with making a custom backend. To make a custom backend, you need to inherit roughpages.backends.TemplateFilenameBackendBase and override prepare_filenames(self, filename, request) method. The method receive an original filename and HttpRequest instance and must return a filename list. The django-roughpages then try to load template file from the beginning of the list, thus the order of the appearance is the matter.
Documentation
Installation
Use pip like:
$ pip install django-roughpages
Usage
Configuration
Add roughpages to the INSTALLED_APPS in your settings module
INSTALLED_APPS = ( # ... 'roughpages', )
Add our extra fallback middleware
MIDDLEWARE_CLASSES = ( # ... 'roughpages.middleware.RoughpageFallbackMiddleware', )
Create roughpages directory in one of your template directories specified with settings.TEMPLATE_DIRS
Quick tutorial
Create roughpages/foo/bar/hoge.html as follow
<html> <body> This is Hoge </body> </html>
Run syncdb and Start development server with python manage.py syncdb; python manage.py runserver 8000
Access http://localhost:8000/foo/bar/hoge/ and you will see “This is Hoge”
Create roughpages/foo/bar/piyo_anonymous.html as follow
<html> <body> This is Piyo Anonymous </body> </html>
Create roughpages/foo/bar/piyo_authenticated.html as follow
<html> <body> This is Piyo Authenticated </body> </html>
Access http://localhost:8000/foo/bar/piyo/ and you will see “This is Piyo Anonymous”
Access http://localhost:8000/admin/ and login as admin user.
Access http://localhost:8000/foo/bar/piyo/ and you will see “This is Piyo Authenticated”
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-roughpages-0.1.0.tar.gz
.
File metadata
- Download URL: django-roughpages-0.1.0.tar.gz
- Upload date:
- Size: 10.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 71547569faafd0c9848212baa1f82cff29aa760e7278b4a438d550e60628bf40 |
|
MD5 | e4766ecdd0222c978581dff3116a2ccd |
|
BLAKE2b-256 | 9f9523bf9cac83491b2a5974c5925719357d58a43d30f9b1ee91f7b10ccb6665 |