On Wed, 2007-05-30 at 10:58 -0400, Jason McVetta wrote:
> On 5/29/07, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote:
> Or you could subclass DatabrowseSite -- in your own code
> somewhere; no
> need to even modify the source -- and override the root()
> method to do
> an auth-check first and then call DatabrowseSite.root(). Then
> you
> replace databrowse.sites with an instance of your subclass.
>
>
> Didn't even need to subclass it. Instead, I took what seemed the
> least-invasive route, and made my urls.py look like this:
>
> from django.conf.urls.defaults import *
> from django.http import HttpResponseRedirect
> from django.contrib import databrowse
>
> def authorized_databrowse(request, url):
> if request.user.is_authenticated():
> return databrowse.site.root(request, url)
> else:
> return HttpResponseRedirect('/login/?next=%s' % request.path)
>
> urlpatterns = patterns('',
> (r'^databrowse/(.*)', authorized_databrowse),
> (r'^login/$', 'django.contrib.auth.views.login'),
> ...
> )
Looks very sensible and clean. Nice solution. :-)
Cheers,
Malcolm
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---