913acb7c5eaf8c83499b72814d22ff8350527feb
[redakcja.git] / apps / api / urls.py
1 __author__="lreqc"
2 __date__ ="$2009-09-17 16:16:54$"
3
4 from django.conf.urls.defaults import *
5 from piston.resource import Resource
6
7 from api.handlers import *
8 from api.utils import TextEmitter, DjangoAuth
9
10 authdata = {'authentication': DjangoAuth()}
11
12 FORMAT_EXT = r"\.(?P<emitter_format>xml|json|yaml)$"
13
14 library_resource = Resource(LibraryHandler, **authdata)
15 document_resource = Resource(DocumentHandler, **authdata)
16 document_text_resource = Resource(DocumentTextHandler, **authdata)
17 document_dc_resource = Resource(DocumentDublinCoreHandler, **authdata)
18
19 urlpatterns = patterns('',
20 #    url(r'^hello$', hello_resource, {'emitter_format': 'json'}),
21 #    url(r'^hello\.(?P<emitter_format>.+)$', hello_resource),
22
23     # Documents
24     url(r'^documents$', library_resource,
25         {'emitter_format': 'json'}, name="document_list_view"),
26
27     url(r'^documents'+FORMAT_EXT, library_resource,
28         name="document_list_view_withformat"),
29         
30     url(r'^documents/(?P<docid>[^/]+)'+FORMAT_EXT,
31         document_resource, name="document_view_withformat"),
32
33     url(r'^documents/(?P<docid>[^/]+)$',
34         document_resource, {'emitter_format': 'json'},
35         name="document_view"),
36     
37     url(r'^documents/(?P<docid>[^/]+)/text$',
38         document_text_resource, {'emitter_format': 'rawxml'},
39         name="doctext_view"),
40
41     url(r'^documents/(?P<docid>[^/]+)/dc' + FORMAT_EXT,
42         document_dc_resource,
43         name="docdc_view_withformat"),
44
45     url(r'^documents/(?P<docid>[^/]+)/dc$',
46         document_dc_resource, {'emitter_format': 'json'},
47         name="docdc_view"),
48
49     url(r'^documents/(?P<docid>[^/]+)/parts$',
50         document_resource, {'emitter_format': 'json'},
51         name="docparts_view"),
52         
53   #  url(r'^posts/(?P<post_slug>[^/]+)/$', blogpost_resource),
54   #  url(r'^other/(?P<username>[^/]+)/(?P<data>.+)/$', arbitrary_resource),
55 )
56