[entities] Make it possible to override the CKAN organization
authorDenis Laxalde <denis.laxalde@logilab.fr>
Mon, 24 Nov 2014 10:37:53 +0100
changeset 17 7c8af9dda7d9
parent 16 4d8fea13570d
child 18 0becfca6d171
[entities] Make it possible to override the CKAN organization And thus make the corresponding configuration option optional.
entities.py
site_cubicweb.py
utils.py
--- a/entities.py	Fri Nov 21 17:15:40 2014 +0100
+++ b/entities.py	Mon Nov 24 10:37:53 2014 +0100
@@ -72,6 +72,11 @@
             return [d['url'] for d in res['resources']]
         return []
 
+    @property
+    def ckan_organization(self):
+        """The CKAN organization which should own the dataset"""
+        return self._cw.vreg.config.get('ckan-organization')
+
     def ckan_get_organization_id(self, orgname):
         """Retrieve the ID of an organization given its name"""
         data = {'organizations': [orgname],
@@ -94,9 +99,9 @@
                 'notes': self.ckan_notes(),
                 'maintainer': None,
                 'maintainer_email': None,
+                'owner_org':self.ckan_get_organization_id(
+                    self.ckan_organization)
                }
-        orgname = self._cw.vreg.config.get('ckan-organization')
-        data['owner_org'] = self.ckan_get_organization_id(orgname)
         maintainer = self.dataset_maintainer()
         if maintainer:
             data['maintainer'] = maintainer.dc_long_title()
--- a/site_cubicweb.py	Fri Nov 21 17:15:40 2014 +0100
+++ b/site_cubicweb.py	Mon Nov 24 10:37:53 2014 +0100
@@ -15,7 +15,6 @@
       }),
     ('ckan-organization',
      {'type' : 'string',
-      'default': REQUIRED,
       'help': u'the organization under which dataset will be created',
       'group': 'ckan', 'level': 0,
       }),
--- a/utils.py	Fri Nov 21 17:15:40 2014 +0100
+++ b/utils.py	Mon Nov 24 10:37:53 2014 +0100
@@ -48,7 +48,7 @@
     (Mostly useful in tests to disable CKAN hooks.)
     """
     config = req.vreg.config
-    for option in ('ckan-baseurl', 'ckan-api-key', 'ckan-organization'):
+    for option in ('ckan-baseurl', 'ckan-api-key'):
         if not config.get(option):
             req.warning('CKAN instance configuration incomplete, missing "%s" '
                         'option' % option)