20 |
20 |
from importlib import import_module
|
21 |
21 |
|
22 |
22 |
from django.conf import settings
|
23 |
|
from django.conf.urls import patterns, url
|
|
23 |
from django.conf.urls import url
|
24 |
24 |
from django.http import Http404
|
25 |
25 |
from django.core.exceptions import ImproperlyConfigured
|
26 |
26 |
from django.core.urlresolvers import resolve
|
... | ... | |
35 |
35 |
|
36 |
36 |
def app_web_services(request, path):
|
37 |
37 |
app = get_app_settings()
|
38 |
|
if hasattr(app, 'urlpatterns'):
|
39 |
|
view, args, kwargs = resolve(request.path, urlconf=app)
|
|
38 |
if hasattr(app, 'SITE_WEBSERVICES'):
|
|
39 |
view, args, kwargs = resolve(request.path, urlconf=app.SITE_WEBSERVICES)
|
40 |
40 |
return view(request, *args, **kwargs)
|
41 |
41 |
raise Http404
|
42 |
42 |
|
... | ... | |
90 |
90 |
return slugify(type(self).__name__)
|
91 |
91 |
|
92 |
92 |
|
|
93 |
class AppWebservice(object):
|
|
94 |
'''- endpoints = [
|
|
95 |
{'foo': 'https://example.org/foo/'},
|
|
96 |
{'bar': 'https://example.org/bar/'},
|
|
97 |
]
|
|
98 |
- urlpatterns = [
|
|
99 |
url('user/(?P<username>\w+)/$', views.myapp.user_details, name='user-details'),
|
|
100 |
url('user/(?P<username>\w+/books/$)', views.myapp.user_books, name='user-books'),
|
|
101 |
]
|
|
102 |
'''
|
|
103 |
|
|
104 |
def __init__(self, endpoints=None, urlpatterns=None):
|
|
105 |
self.endpoints = endpoints
|
|
106 |
self.urlpatterns = urlpatterns
|
|
107 |
|
|
108 |
def get_endpoint(self, name):
|
|
109 |
for endpoint in self.endpoints:
|
|
110 |
if endpoint.get(name, None):
|
|
111 |
return endpoint[name]
|
|
112 |
return None
|
|
113 |
|
|
114 |
|
93 |
115 |
# Test App Settings
|
94 |
116 |
class Test(AppSettings):
|
95 |
117 |
SITE_LOGIN_PATH = '/'
|
... | ... | |
188 |
210 |
|
189 |
211 |
SITE_FORCE_REDIRECT_LOCATOR = '.connectBox'
|
190 |
212 |
|
191 |
|
SITE_WS_ENDPOINT = {
|
192 |
|
'account_details': '/DEFAULT/Ermes/Services/ILSClient.svc/RetrieveAccount',
|
193 |
|
}
|
194 |
|
|
195 |
|
urlpatterns = patterns(
|
196 |
|
'',
|
197 |
|
url(
|
198 |
|
r'account/(?P<username>\w+)/$',
|
199 |
|
'mandayejs.applications.views.archimed_account_details',
|
200 |
|
name='archimed-account-details'),
|
|
213 |
SITE_WEBSERVICES = AppWebservice(
|
|
214 |
[
|
|
215 |
{'account_details': '/DEFAULT/Ermes/Services/ILSClient.svc/RetrieveAccount'},
|
|
216 |
{'login_url': '/DEFAULT/Ermes/Recherche/logon.svc/logon'}
|
|
217 |
],
|
|
218 |
[
|
|
219 |
url(r'account/(?P<username>\w+)/$', 'mandayejs.applications.views.archimed_account_details',
|
|
220 |
name='archimed-account-details')
|
|
221 |
]
|
201 |
222 |
)
|
202 |
223 |
|
203 |
224 |
SITE_LOGOUT_LOCATOR = '.account_logoff'
|