PageRenderTime 36ms CodeModel.GetById 32ms app.highlight 3ms RepoModel.GetById 0ms app.codeStats 0ms

/tests/test_project/apps/testapp/urls.py

https://bitbucket.org/cklein/django-piston
Python | 58 lines | 51 code | 7 blank | 0 comment | 2 complexity | 256e5061a7bc580328cca610b92180c8 MD5 | raw file
 1from django.conf.urls.defaults import *
 2from piston.resource import Resource
 3from piston.authentication import HttpBasicAuthentication, HttpBasicSimple
 4
 5from test_project.apps.testapp.handlers import EntryHandler, ExpressiveHandler, AbstractHandler, EchoHandler, PlainOldObjectHandler, Issue58Handler, ListFieldsHandler
 6
 7auth = HttpBasicAuthentication(realm='TestApplication')
 8
 9entries = Resource(handler=EntryHandler, authentication=auth)
10expressive = Resource(handler=ExpressiveHandler, authentication=auth)
11abstract = Resource(handler=AbstractHandler, authentication=auth)
12echo = Resource(handler=EchoHandler)
13popo = Resource(handler=PlainOldObjectHandler)
14list_fields = Resource(handler=ListFieldsHandler)
15issue58 = Resource(handler=Issue58Handler)
16
17AUTHENTICATORS = [auth,]
18SIMPLE_USERS = (('admin', 'secr3t'),
19                ('admin', 'user'),
20                ('admin', 'allwork'),
21                ('admin', 'thisisneat'))
22
23for username, password in SIMPLE_USERS:
24    AUTHENTICATORS.append(HttpBasicSimple(realm='Test', 
25                            username=username, password=password))
26
27multiauth = Resource(handler=PlainOldObjectHandler, 
28                        authentication=AUTHENTICATORS)
29
30urlpatterns = patterns('',
31    url(r'^entries/$', entries),
32    url(r'^entries/(?P<pk>.+)/$', entries),
33    url(r'^entries\.(?P<emitter_format>.+)', entries),
34    url(r'^entry-(?P<pk>.+)\.(?P<emitter_format>.+)', entries),
35
36    url(r'^issue58\.(?P<emitter_format>.+)$', issue58),
37
38    url(r'^expressive\.(?P<emitter_format>.+)$', expressive),
39
40    url(r'^abstract\.(?P<emitter_format>.+)$', abstract),
41    url(r'^abstract/(?P<id_>\d+)\.(?P<emitter_format>.+)$', abstract),
42
43    url(r'^echo$', echo),
44
45    url(r'^multiauth/$', multiauth),
46
47    # oauth entrypoints
48    url(r'^oauth/request_token$', 'piston.authentication.oauth_request_token'),
49    url(r'^oauth/authorize$', 'piston.authentication.oauth_user_auth'),
50    url(r'^oauth/access_token$', 'piston.authentication.oauth_access_token'),
51
52    url(r'^list_fields$', list_fields),
53    url(r'^list_fields/(?P<id>.+)$', list_fields),
54    
55    url(r'^popo$', popo),
56)
57
58