Revision e3ff6830 snf-pithos-app/pithos/api/urls.py
b/snf-pithos-app/pithos/api/urls.py | ||
---|---|---|
32 | 32 |
# or implied, of GRNET S.A. |
33 | 33 |
|
34 | 34 |
from functools import partial |
35 |
|
|
36 | 35 |
from django.conf.urls.defaults import include, patterns |
37 |
from django.views.decorators.csrf import csrf_exempt |
|
38 |
|
|
39 | 36 |
from snf_django.lib.api.proxy import proxy |
37 |
from snf_django.lib.api.utils import prefix_pattern |
|
38 |
from pithos.api.settings import ( |
|
39 |
BASE_PATH, ASTAKOS_BASE_URL, BASE_ASTAKOS_PROXY_PATH, |
|
40 |
ASTAKOS_ACCOUNTS_PREFIX, PROXY_USER_SERVICES) |
|
41 |
from urlparse import urlparse |
|
40 | 42 |
|
41 |
import pithos.api.settings as settings |
|
42 |
|
|
43 |
astakos_proxy = partial(proxy, target=settings.ASTAKOS_URL) |
|
44 | 43 |
|
45 | 44 |
# TODO: This only works when in this order. |
46 |
api_urlpatterns = patterns(
|
|
45 |
pithos_api_patterns = patterns(
|
|
47 | 46 |
'pithos.api.functions', |
48 | 47 |
(r'^$', 'top_demux'), |
49 | 48 |
(r'^(?P<v_account>.+?)/(?P<v_container>.+?)/(?P<v_object>.+?)$', |
... | ... | |
52 | 51 |
'container_demux'), |
53 | 52 |
(r'^(?P<v_account>.+?)/?$', 'account_demux')) |
54 | 53 |
|
55 |
urlpatterns = patterns(
|
|
54 |
pithos_patterns = patterns(
|
|
56 | 55 |
'', |
57 |
(r'^v1(?:$|/)', include(api_urlpatterns)),
|
|
58 |
(r'^v1\.0(?:$|/)', include(api_urlpatterns)),
|
|
56 |
(r'^v1(?:$|/)', include(pithos_api_patterns)),
|
|
57 |
(r'^v1\.0(?:$|/)', include(pithos_api_patterns)),
|
|
59 | 58 |
(r'^public/(?P<v_public>.+?)/?$', 'pithos.api.public.public_demux')) |
60 | 59 |
|
61 |
if settings.PROXY_USER_SERVICES: |
|
60 |
urlpatterns = patterns( |
|
61 |
'', |
|
62 |
(prefix_pattern(BASE_PATH), include(pithos_patterns)), |
|
63 |
) |
|
64 |
|
|
65 |
if PROXY_USER_SERVICES: |
|
66 |
astakos_proxy = partial(proxy, proxy_base=BASE_ASTAKOS_PROXY_PATH, |
|
67 |
target_base=ASTAKOS_BASE_URL) |
|
68 |
|
|
69 |
proxy_patterns = patterns( |
|
70 |
'', |
|
71 |
(r'^login/?$', astakos_proxy), |
|
72 |
(r'^feedback/?$', astakos_proxy), |
|
73 |
(r'^user_catalogs/?$', astakos_proxy), |
|
74 |
(prefix_pattern(ASTAKOS_ACCOUNTS_PREFIX), astakos_proxy), |
|
75 |
) |
|
76 |
|
|
62 | 77 |
urlpatterns += patterns( |
63 | 78 |
'', |
64 |
(r'^login/?$', csrf_exempt(astakos_proxy)), |
|
65 |
(r'^feedback/?$', csrf_exempt(astakos_proxy)), |
|
66 |
(r'^user_catalogs/?$', csrf_exempt(astakos_proxy)), |
|
67 |
(r'^astakos/api/', csrf_exempt(astakos_proxy)) |
|
79 |
(prefix_pattern(BASE_ASTAKOS_PROXY_PATH), include(proxy_patterns)), |
|
68 | 80 |
) |
Also available in: Unified diff