django forms + webapp framework or just django

18 views
Skip to first unread message

Jared

unread,
Jun 21, 2008, 12:09:15 AM6/21/08
to Google App Engine
I'm thinking about switching my app from webapp to django (both
running on app-engine). One thing that is tripping me up is creating
a decorator for requiring certain views be run by an admin user. (I
attempted to re-create a customized django admin interface for adding
data to the site, so there are a few views that would need admin
access for this.)

I tried gleaning from the reitveld project's example of various
decorators, but I'm not able to get any of theirs to work. Does
anyone have an example of a generic admin_required and/or
login_required decorator that could be use in conjunction with the
google-app-engine-django project code?

Roberto Saccon

unread,
Jun 21, 2008, 2:44:05 AM6/21/08
to Google App Engine
I took those decorators for admin / login as well from rietveld and it
worked for me on an app-engine-django-helper based project (and I
can't remember having changed anything), so it is probably just a tiny
detail you got wrong (assuming you know more or less what you are
doing, of course).

regards
--
Roberto Saccon
http:rsaccon.com

David Webb

unread,
Jun 21, 2008, 4:12:44 AM6/21/08
to google-a...@googlegroups.com
You don't have to use Django authentication to protect a page with an admin login.  You can still do this with app.yaml.  This does mean you're specifying URLs in both app.yaml and urls.py but it does work rather well:

For example, in my urls.py I have:

urlpatterns = patterns('views',
    (r'^$','home'),
    (r'^gallery/$','home'),
    (r'^admin/$','admin'),
    (r'^contact/$','contact'),
    (r'^contact/sent/$','contact_sent'),
    (r'^admin/init/$','initialise'),
    (r'^admin/refresh/$','flush'),
    ...etc - lots more views

And in my app.yaml I have:

handlers:
- url: /static
  static_dir: static

- url: /admin/.*
  script: main.py
  login: admin

- url: /.*
  script: main.py

So all my URLs for dynamic pages are still handled by Django, but any ones starting /admin/... require an admin login first.

Regards,

Dave.

2008/6/21 Roberto Saccon <rsa...@gmail.com>:

nchauvat (Logilab)

unread,
Jun 21, 2008, 8:08:03 AM6/21/08
to Google App Engine
> One thing that is tripping me up is creating
> a decorator for requiring certain views be run by an admin user.

Using this other framework, you would just be setting permissions:

http://groups.google.com/group/google-appengine/browse_thread/thread/f48cf6099973aef5/95522f68806205f3?lnk=gst&q=lax+permissions#95522f68806205f3
Reply all
Reply to author
Forward
0 new messages