[snowy] Patch from Stuart Langridge updating Root resource to latest API spec
- From: Sanford Armstrong <sharm src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [snowy] Patch from Stuart Langridge updating Root resource to latest API spec
- Date: Sun, 6 Sep 2009 00:55:50 +0000 (UTC)
commit 4179313336153e15e31eaa1a3a0618c5ad1246de
Author: Sandy Armstrong <sanfordarmstrong gmail com>
Date: Sat Sep 5 17:47:51 2009 -0700
Patch from Stuart Langridge updating Root resource to latest API spec
Basic Root resource info is available anonymously.
api/handlers.py | 26 +++++++++++++++++++++-----
urls.py | 6 +++---
2 files changed, 24 insertions(+), 8 deletions(-)
---
diff --git a/api/handlers.py b/api/handlers.py
index c92387f..a3aa19c 100644
--- a/api/handlers.py
+++ b/api/handlers.py
@@ -53,18 +53,34 @@ class catch_and_return(object):
return wrapper
# http://domain/api/1.0
+class RootHandlerAnonymous(AnonymousBaseHandler):
+ allow_methods = ('GET')
+
+ def read(self, request):
+ kwargs = {'username': request.user.username}
+ return basic_root()
+
+# http://domain/api/1.0
class RootHandler(BaseHandler):
allow_methods = ('GET')
+ anonymous = RootHandlerAnonymous
def read(self, request):
kwargs = {'username': request.user.username}
- return {
- 'user-ref': {
+ root = basic_root()
+ root['user-ref'] = {
'api-ref' : reverse_full('user_api_index', kwargs=kwargs),
'href' : reverse_full('user_index', kwargs=kwargs),
- },
- 'api-version': '1.0'
- }
+ }
+ return root
+
+def basic_root():
+ return {
+ 'oauth_request_token_url': reverse_full('oauth_request_token'),
+ 'oauth_authorize_url': reverse_full('oauth_user_auth'),
+ 'oauth_access_token_url': reverse_full('oauth_access_token'),
+ 'api-version': '1.0'
+ }
# http://domain/api/1.0/user
class UserHandler(AnonymousBaseHandler):
diff --git a/urls.py b/urls.py
index 1898a48..46fbae4 100644
--- a/urls.py
+++ b/urls.py
@@ -49,7 +49,7 @@ if settings.DEBUG:
# OAuth
urlpatterns += patterns('piston.authentication',
- url(r'^oauth/request_token/$', 'oauth_request_token'),
- url(r'^oauth/authenticate/$', 'oauth_user_auth'),
- url(r'^oauth/access_token/$', 'oauth_access_token'),
+ url(r'^oauth/request_token/$', 'oauth_request_token', name='oauth_request_token'),
+ url(r'^oauth/authenticate/$', 'oauth_user_auth', name='oauth_user_auth'),
+ url(r'^oauth/access_token/$', 'oauth_access_token', name='oauth_access_token'),
)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]