37 |
37 |
|
38 |
38 |
def app_web_services(request, path):
|
39 |
39 |
app = get_app_settings()
|
40 |
|
if hasattr(app, 'urlpatterns'):
|
41 |
|
view, args, kwargs = resolve(request.path, urlconf=app)
|
|
40 |
if hasattr(app, 'SITE_WEBSERVICES'):
|
|
41 |
view, args, kwargs = resolve(request.path, urlconf=app.SITE_WEBSERVICES)
|
42 |
42 |
return view(request, *args, **kwargs)
|
43 |
43 |
raise Http404
|
44 |
44 |
|
... | ... | |
92 |
92 |
return slugify(type(self).__name__)
|
93 |
93 |
|
94 |
94 |
|
|
95 |
class AppWebservice(object):
|
|
96 |
'''- endpoints = [
|
|
97 |
{'foo': 'https://example.org/foo/'},
|
|
98 |
{'bar': 'https://example.org/bar/'},
|
|
99 |
]
|
|
100 |
- urlpatterns = [
|
|
101 |
url('user/(?P<username>\w+)/$', views.myapp.user_details, name='user-details'),
|
|
102 |
url('user/(?P<username>\w+/books/$)', views.myapp.user_books, name='user-books'),
|
|
103 |
]
|
|
104 |
'''
|
|
105 |
|
|
106 |
def __init__(self, endpoints=None, urlpatterns=None):
|
|
107 |
self.endpoints = endpoints
|
|
108 |
self.urlpatterns = urlpatterns
|
|
109 |
|
|
110 |
def get_endpoint(self, name):
|
|
111 |
for endpoint in self.endpoints:
|
|
112 |
if endpoint.get(name, None):
|
|
113 |
return endpoint[name]
|
|
114 |
return None
|
|
115 |
|
|
116 |
|
95 |
117 |
# Test App Settings
|
96 |
118 |
class Test(AppSettings):
|
97 |
119 |
SITE_LOGIN_PATH = '/'
|
... | ... | |
190 |
212 |
|
191 |
213 |
SITE_FORCE_REDIRECT_LOCATOR = '.connectBox'
|
192 |
214 |
|
193 |
|
SITE_WS_ENDPOINT = {
|
194 |
|
'account_details': '/DEFAULT/Ermes/Services/ILSClient.svc/RetrieveAccount',
|
195 |
|
}
|
196 |
|
|
197 |
|
urlpatterns = [
|
198 |
|
url(
|
199 |
|
r'account/(?P<username>\w+)/$',
|
200 |
|
views.archimed_account_details,
|
201 |
|
name='archimed-account-details'),
|
202 |
|
]
|
|
215 |
SITE_WEBSERVICES = AppWebservice(
|
|
216 |
[
|
|
217 |
{'account_details': '/DEFAULT/Ermes/Services/ILSClient.svc/RetrieveAccount'},
|
|
218 |
{'login_url': '/DEFAULT/Ermes/Recherche/logon.svc/logon'}
|
|
219 |
],
|
|
220 |
[
|
|
221 |
url(r'account/(?P<username>\w+)/$', views.archimed_account_details,
|
|
222 |
name='archimed-account-details')
|
|
223 |
]
|
|
224 |
)
|
203 |
225 |
|
204 |
226 |
SITE_LOGOUT_LOCATOR = '.account_logoff'
|
205 |
227 |
|