forked from cdleary/coffin
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
26 changed files
with
176 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,4 @@ | |
Coffin.egg-info | ||
/dist | ||
.*.swp | ||
/docs/_build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from django.contrib.auth.admin import * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from django.contrib.auth.backends import * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from django.contrib.auth.decorators import * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from django.contrib.auth.forms import * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from django.contrib.auth.handlers import * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from django.contrib.auth.middleware import * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from django.contrib.auth.models import * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from django.contrib.auth.tokens import * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import inspect | ||
|
||
from django.contrib.auth import urls | ||
|
||
exec inspect.getsource(urlpatterns)\ | ||
.replace('django.contrib.auth.views', 'coffin.contrib.auth.views') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import inspect | ||
|
||
from django.contrib.auth.views import * | ||
|
||
# XXX: maybe approach this as importing the entire model, and doing string replacements | ||
# on the template and shortcut import lines? | ||
|
||
from coffin.shortcuts import render_to_response | ||
from coffin.template import RequestContext, loader | ||
|
||
exec inspect.getsource(logout) | ||
exec inspect.getsource(password_change_done) | ||
exec inspect.getsource(password_reset) | ||
exec inspect.getsource(password_reset_confirm) | ||
exec inspect.getsource(password_reset_done) | ||
exec inspect.getsource(password_reset_complete) | ||
|
||
exec inspect.getsource(password_change.view_func) | ||
password_change = login_required(password_change) | ||
|
||
# XXX: this function uses a decorator, which calls functools.wraps, which compiles the code | ||
# thus we cannot inspect the source | ||
def login(request, template_name='registration/login.html', redirect_field_name=REDIRECT_FIELD_NAME): | ||
"Displays the login form and handles the login action." | ||
redirect_to = request.REQUEST.get(redirect_field_name, '') | ||
if request.method == "POST": | ||
form = AuthenticationForm(data=request.POST) | ||
if form.is_valid(): | ||
# Light security check -- make sure redirect_to isn't garbage. | ||
if not redirect_to or '//' in redirect_to or ' ' in redirect_to: | ||
redirect_to = settings.LOGIN_REDIRECT_URL | ||
from django.contrib.auth import login | ||
login(request, form.get_user()) | ||
if request.session.test_cookie_worked(): | ||
request.session.delete_test_cookie() | ||
return HttpResponseRedirect(redirect_to) | ||
else: | ||
form = AuthenticationForm(request) | ||
request.session.set_test_cookie() | ||
if Site._meta.installed: | ||
current_site = Site.objects.get_current() | ||
else: | ||
current_site = RequestSite(request) | ||
return render_to_response(template_name, { | ||
'form': form, | ||
redirect_field_name: redirect_to, | ||
'site': current_site, | ||
'site_name': current_site.name, | ||
}, context_instance=RequestContext(request)) | ||
login = never_cache(login) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
========================== | ||
:mod:`coffin.contrib.auth` | ||
========================== |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
===================== | ||
:mod:`coffin.contrib` | ||
===================== | ||
|
||
Coffin includes replacements for several Django contrib modules. | ||
|
||
To use this, simply change your import line from:: | ||
|
||
from django.contrib.<module> | ||
|
||
To the following:: | ||
|
||
from coffin.contrib.<module> | ||
|
||
----------------- | ||
Supported Modules | ||
----------------- | ||
|
||
The following drop-in replacements are available: | ||
|
||
.. toctree:: | ||
:maxdepth: 2 | ||
|
||
auth | ||
markup | ||
syndication |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
============================ | ||
:mod:`coffin.contrib.markup` | ||
============================ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
================================= | ||
:mod:`coffin.contrib.syndication` | ||
================================= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
Installation | ||
============ | ||
|
||
Install the package through PyPi:: | ||
|
||
easy_install Coffin | ||
|
||
Or alternatively, get the source:: | ||
|
||
git clone git://github.com/dcramer/coffin.git | ||
cd coffin | ||
python setup.py install | ||
|
||
Once installed, you will need to add Coffin to several places throughout your projects. | ||
|
||
First, open up ``settings.py`` and add Coffin to your ``INSTALLED_APPS``:: | ||
|
||
INSTALLED_APPS = ( | ||
'coffin', | ||
... | ||
) | ||
|
||
The easiest way to enable Jinja2, rather than Django, is to change your import paths. For example, if we're using the ``render_to_response`` shortcut, we simply need to tweak our import line:: | ||
|
||
from django.shortcuts import render_to_response | ||
|
||
To the following:: | ||
|
||
from coffin.shortcuts import render_to_response | ||
|
||
Coffin includes drop in replacements for the following Django modules: | ||
|
||
* :mod:`django.shortcuts` | ||
* :mod:`django.views.generic.simple` | ||
* :mod:`django.contrib.auth` | ||
* :mod:`django.contrib.markup` | ||
* :mod:`django.contrib.syndication` | ||
* :mod:`django.template` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
-e svn+http://code.djangoproject.com/svn/django/trunk#egg=django | ||
Jinja2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters