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

https://bitbucket.org/cklein/django-piston · Python · 58 lines · 40 code · 17 blank · 1 comment · 1 complexity · 256e5061a7bc580328cca610b92180c8 MD5 · raw file

  1. from django.conf.urls.defaults import *
  2. from piston.resource import Resource
  3. from piston.authentication import HttpBasicAuthentication, HttpBasicSimple
  4. from test_project.apps.testapp.handlers import EntryHandler, ExpressiveHandler, AbstractHandler, EchoHandler, PlainOldObjectHandler, Issue58Handler, ListFieldsHandler
  5. auth = HttpBasicAuthentication(realm='TestApplication')
  6. entries = Resource(handler=EntryHandler, authentication=auth)
  7. expressive = Resource(handler=ExpressiveHandler, authentication=auth)
  8. abstract = Resource(handler=AbstractHandler, authentication=auth)
  9. echo = Resource(handler=EchoHandler)
  10. popo = Resource(handler=PlainOldObjectHandler)
  11. list_fields = Resource(handler=ListFieldsHandler)
  12. issue58 = Resource(handler=Issue58Handler)
  13. AUTHENTICATORS = [auth,]
  14. SIMPLE_USERS = (('admin', 'secr3t'),
  15. ('admin', 'user'),
  16. ('admin', 'allwork'),
  17. ('admin', 'thisisneat'))
  18. for username, password in SIMPLE_USERS:
  19. AUTHENTICATORS.append(HttpBasicSimple(realm='Test',
  20. username=username, password=password))
  21. multiauth = Resource(handler=PlainOldObjectHandler,
  22. authentication=AUTHENTICATORS)
  23. urlpatterns = patterns('',
  24. url(r'^entries/$', entries),
  25. url(r'^entries/(?P<pk>.+)/$', entries),
  26. url(r'^entries\.(?P<emitter_format>.+)', entries),
  27. url(r'^entry-(?P<pk>.+)\.(?P<emitter_format>.+)', entries),
  28. url(r'^issue58\.(?P<emitter_format>.+)$', issue58),
  29. url(r'^expressive\.(?P<emitter_format>.+)$', expressive),
  30. url(r'^abstract\.(?P<emitter_format>.+)$', abstract),
  31. url(r'^abstract/(?P<id_>\d+)\.(?P<emitter_format>.+)$', abstract),
  32. url(r'^echo$', echo),
  33. url(r'^multiauth/$', multiauth),
  34. # oauth entrypoints
  35. url(r'^oauth/request_token$', 'piston.authentication.oauth_request_token'),
  36. url(r'^oauth/authorize$', 'piston.authentication.oauth_user_auth'),
  37. url(r'^oauth/access_token$', 'piston.authentication.oauth_access_token'),
  38. url(r'^list_fields$', list_fields),
  39. url(r'^list_fields/(?P<id>.+)$', list_fields),
  40. url(r'^popo$', popo),
  41. )