summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
author <bdauvergne@entrouvert.com>2009-09-21 12:30:14 (GMT)
committer <bdauvergne@entrouvert.com>2009-09-21 12:30:14 (GMT)
commitba3cd5286390e555397e940fffd4ba3860ae3f58 (patch)
tree6e67387711105fa31cd00d8984a2cfd4ae4aca20
parentf9dcf7fb1580c66c7ddbcee4e0d57f061e7a6767 (diff)
downloadpratic-ba3cd5286390e555397e940fffd4ba3860ae3f58.zip
pratic-ba3cd5286390e555397e940fffd4ba3860ae3f58.tar.gz
pratic-ba3cd5286390e555397e940fffd4ba3860ae3f58.tar.bz2
Fix problems with global services
* when creating a service instance from a global service, copy cdg59metadataURL and cdg59URL in the service instance from the service definition. * when retrieving service instances which do not possess a metadataURL or an URL, and whose service type is global, retrieve service type datas.
-rw-r--r--idp/extra/modules/directory.py23
-rw-r--r--idp/extra/modules/services_ui.ptl5
2 files changed, 25 insertions, 3 deletions
diff --git a/idp/extra/modules/directory.py b/idp/extra/modules/directory.py
index bd48bd9..d3fd103 100644
--- a/idp/extra/modules/directory.py
+++ b/idp/extra/modules/directory.py
@@ -470,7 +470,18 @@ def get_service_instances(collectivity):
store = get_store()
result = store.ldap_conn.search_s(collectivity.dn,
ldap.SCOPE_SUBTREE, 'objectClass=cdg59serviceInstance')
- return [ServiceInstance(x) for x in result]
+ service_instances = [ServiceInstance(x) for x in result]
+ # fill missing fields for global services
+ services = get_services()
+ for si in service_instances:
+ if not si.cdg59metadataURL and not si.cdg59URL:
+ s = get_service(si.cdg59serviceType)
+ if s and s.cdg59isGlobal:
+ si.cdg59metadataURL = s.cdg59metadataURL
+ si.cdg59URL = s.cdg59URL
+ return service_instances
+
+
def get_service_instance(collectivity, siid):
store = get_store()
@@ -478,7 +489,15 @@ def get_service_instance(collectivity, siid):
ldap.SCOPE_SUBTREE, ldap.filter.filter_format('(&(cdg59siid=%s)(objectclass=cdg59serviceInstance))', (siid,)))
if not result:
raise KeyError()
- return ServiceInstance(result[0])
+ si = ServiceInstance(result[0])
+ # fix missing field values for global services
+ if not si.cdg59metadataURL and not si.cdg59URL:
+ s = get_service(si.cdg59serviceType)
+ if s and s.cdg59isGlobal:
+ si.cdg59metadataURL = s.cdg59metadataURL
+ si.cdg59URL = s.cdg59URL
+ return si
+
diff --git a/idp/extra/modules/services_ui.ptl b/idp/extra/modules/services_ui.ptl
index eb8e45f..f2f02ba 100644
--- a/idp/extra/modules/services_ui.ptl
+++ b/idp/extra/modules/services_ui.ptl
@@ -549,10 +549,13 @@ class ServicesDirectory(Directory):
si = directory.ServiceInstance()
si.cdg59siid = sid
si.cdg59serviceType = sid
+ associated_service = [x for x in all_services if x.cdg59sid == sid][0]
+ if associated_service.cdg59isGlobal:
+ si.cdg59metadataURL = associated_service.cdg59metadataURL
+ si.cdg59URL = associated_service.cdg59URL
si.add(self.collectivity)
- associated_service = [x for x in all_services if x.cdg59sid == sid][0]
if associated_service.cdg59isGlobal:
return redirect('.')
else: