[ckan-changes] commit/ckan: 3 new changesets

Bitbucket commits-noreply at bitbucket.org
Thu Sep 1 19:30:57 UTC 2011


3 new changesets in ckan:

http://bitbucket.org/okfn/ckan/changeset/166c4645b505/
changeset:   166c4645b505
branch:      feature-1293-rename-package-to-dataset
user:        John Glover
date:        2011-09-01 21:01:09
summary:     [1293] Change Package routing to /dataset instead of /package
affected #:  12 files (1.3 KB)

--- a/ckan/config/routing.py	Thu Sep 01 12:28:48 2011 +0100
+++ b/ckan/config/routing.py	Thu Sep 01 20:01:09 2011 +0100
@@ -36,6 +36,7 @@
     # CKAN API versioned.
     register_list = [
             'package',
+            'dataset',
             'resource',
             'tag',
             'group',
@@ -152,7 +153,7 @@
 
     map.connect('/api/2/util/user/autocomplete', controller='api',
         action='user_autocomplete')
-    map.connect('/api/2/util/package/create_slug', controller='api', action='create_slug',
+    map.connect('/api/2/util/dataset/create_slug', controller='api', action='create_slug',
                 conditions=dict(method=['GET']))
     map.connect('/api/2/util/tag/autocomplete', controller='api', action='tag_autocomplete',
                 conditions=dict(method=['GET']))
@@ -166,15 +167,17 @@
     ## /END API
     ###########
 
-    map.redirect("/packages", "/package")
-    map.redirect("/packages/{url:.*}", "/package/{url}")
-    map.connect('/package', controller='package', action='search')
+    map.redirect("/packages", "/dataset")
+    map.redirect("/packages/{url:.*}", "/dataset/{url}")
+    map.redirect("/package", "/dataset")
+    map.redirect("/package/{url:.*}", "/dataset/{url}")
+    map.connect('/dataset', controller='package', action='search')
 
     ##to get back formalchemy uncomment these lines
     ##map.connect('/package/new', controller='package_formalchemy', action='new')
     ##map.connect('/package/edit/{id}', controller='package_formalchemy', action='edit')
 
-    map.connect('/package/{action}', controller='package',
+    map.connect('/dataset/{action}', controller='package',
         requirements=dict(action='|'.join([
             'list',
             'new',
@@ -182,9 +185,9 @@
             'search'
             ]))
         )
-    map.connect('/package', controller='package', action='index')
-    map.connect('/package/{action}/{id}/{revision}', controller='package', action='read_ajax')
-    map.connect('/package/{action}/{id}', controller='package',
+    map.connect('/dataset', controller='package', action='index')
+    map.connect('/dataset/{action}/{id}/{revision}', controller='package', action='read_ajax')
+    map.connect('/dataset/{action}/{id}', controller='package',
         requirements=dict(action='|'.join([
         'edit',
         'authz',
@@ -193,7 +196,7 @@
         'history_ajax',
         ]))
         )
-    map.connect('/package/{id}', controller='package', action='read')
+    map.connect('/dataset/{id}', controller='package', action='read')
     # group
     map.redirect("/groups", "/group")
     map.redirect("/groups/{url:.*}", "/group/{url}")


--- a/ckan/controllers/api.py	Thu Sep 01 12:28:48 2011 +0100
+++ b/ckan/controllers/api.py	Thu Sep 01 20:01:09 2011 +0100
@@ -139,7 +139,6 @@
         context = {'model': model, 'session': model.Session, 'user': c.user}
         model.Session()._context = context
         return_dict = {'help': function.__doc__}
-
         try:
             request_data = self._get_request_data()
         except ValueError, inst:
@@ -180,10 +179,13 @@
         action_map = {
             'revision': get_action('revision_list'),
             'group': get_action('group_list'),
+            'dataset': get_action('package_list'),
             'package': get_action('package_list'),
             'tag': get_action('tag_list'),
             'licenses': get_action('licence_list'),
+            ('dataset', 'relationships'): get_action('package_relationships_list'),
             ('package', 'relationships'): get_action('package_relationships_list'),
+            ('dataset', 'revisions'): get_action('package_revision_list'),
             ('package', 'revisions'): get_action('package_revision_list'),
         }
 
@@ -206,7 +208,9 @@
             'revision': get_action('revision_show'),
             'group': get_action('group_show_rest'),
             'tag': get_action('tag_show_rest'),
+            'dataset': get_action('package_show_rest'),
             'package': get_action('package_show_rest'),
+            ('dataset', 'relationships'): get_action('package_relationships_list'),
             ('package', 'relationships'): get_action('package_relationships_list'),
         }
 
@@ -215,6 +219,7 @@
         data_dict = {'id': id, 'id2': id2, 'rel': subregister}
 
         for type in model.PackageRelationship.get_all_types():
+            action_map[('dataset', type)] = get_action('package_relationships_list')
             action_map[('package', type)] = get_action('package_relationships_list')
         log.debug('show: %s' % context)
 
@@ -239,13 +244,16 @@
     def create(self, ver=None, register=None, subregister=None, id=None, id2=None):
 
         action_map = {
+            ('dataset', 'relationships'): get_action('package_relationship_create'),
             ('package', 'relationships'): get_action('package_relationship_create'),
              'group': get_action('group_create_rest'),
+             'dataset': get_action('package_create_rest'),
              'package': get_action('package_create_rest'),
              'rating': get_action('rating_create'),
         }
 
         for type in model.PackageRelationship.get_all_types():
+            action_map[('dataset', type)] = get_action('package_relationship_create')
             action_map[('package', type)] = get_action('package_relationship_create')
 
         context = {'model': model, 'session': model.Session, 'user': c.user,
@@ -289,11 +297,14 @@
     def update(self, ver=None, register=None, subregister=None, id=None, id2=None):
 
         action_map = {
+            ('dataset', 'relationships'): get_action('package_relationship_update'),
             ('package', 'relationships'): get_action('package_relationship_update'),
+             'dataset': get_action('package_update_rest'),
              'package': get_action('package_update_rest'),
              'group': get_action('group_update_rest'),
         }
         for type in model.PackageRelationship.get_all_types():
+            action_map[('dataset', type)] = get_action('package_relationship_update')
             action_map[('package', type)] = get_action('package_relationship_update')
 
         context = {'model': model, 'session': model.Session, 'user': c.user,
@@ -331,11 +342,14 @@
 
     def delete(self, ver=None, register=None, subregister=None, id=None, id2=None):
         action_map = {
+            ('dataset', 'relationships'): get_action('package_relationship_delete'),
             ('package', 'relationships'): get_action('package_relationship_delete'),
              'group': get_action('group_delete'),
+             'dataset': get_action('package_delete'),
              'package': get_action('package_delete'),
         }
         for type in model.PackageRelationship.get_all_types():
+            action_map[('dataset', type)] = get_action('package_relationship_delete')
             action_map[('package', type)] = get_action('package_relationship_delete')
 
         context = {'model': model, 'session': model.Session, 'user': c.user,
@@ -390,7 +404,7 @@
                     gettext("Missing search term ('since_id=UUID' or 'since_time=TIMESTAMP')"))
             revs = model.Session.query(model.Revision).filter(model.Revision.timestamp>since_time)
             return self._finish_ok([rev.id for rev in revs])
-        elif register == 'package' or register == 'resource':
+        elif register in ['dataset', 'package', 'resource']:
             try:
                 params = self._get_search_params(request.params)
             except ValueError, e:
@@ -417,7 +431,7 @@
                 for v in values:
                     query_fields.add(field, v)
             
-            if register == 'package':
+            if register in ['dataset', 'package']:
                 options.ref_entity_with_attr = 'id' if ver == '2' else 'name'
             try:
                 backend = None


--- a/ckan/lib/dictization/model_dictize.py	Thu Sep 01 12:28:48 2011 +0100
+++ b/ckan/lib/dictization/model_dictize.py	Thu Sep 01 20:01:09 2011 +0100
@@ -252,7 +252,7 @@
     dictized['ratings_count'] = len(pkg.ratings)
     site_url = config.get('ckan.site_url', None)
     if site_url:
-        dictized['ckan_url'] = '%s/package/%s' % (site_url, pkg.name)
+        dictized['ckan_url'] = '%s/dataset/%s' % (site_url, pkg.name)
     dictized['metadata_modified'] = pkg.metadata_modified.isoformat() \
         if pkg.metadata_modified else None
     dictized['metadata_created'] = pkg.metadata_created.isoformat() \
@@ -303,7 +303,7 @@
     dictized['ratings_count'] = len(pkg.ratings)
     site_url = config.get('ckan.site_url', None)
     if site_url:
-        dictized['ckan_url'] = '%s/package/%s' % (site_url, pkg.name)
+        dictized['ckan_url'] = '%s/dataset/%s' % (site_url, pkg.name)
     dictized['metadata_modified'] = pkg.metadata_modified.isoformat() \
         if pkg.metadata_modified else None
     dictized['metadata_created'] = pkg.metadata_created.isoformat() \


--- a/ckan/model/package.py	Thu Sep 01 12:28:48 2011 +0100
+++ b/ckan/model/package.py	Thu Sep 01 20:01:09 2011 +0100
@@ -202,7 +202,7 @@
                               for res in self.resources]
         site_url = config.get('ckan.site_url', None)
         if site_url:
-            _dict['ckan_url'] = '%s/package/%s' % (site_url, self.name)
+            _dict['ckan_url'] = '%s/dataset/%s' % (site_url, self.name)
         _dict['relationships'] = [rel.as_dict(self, ref_package_by=ref_package_by) for rel in self.get_relationships()]
         _dict['metadata_modified'] = self.metadata_modified.isoformat() \
             if self.metadata_modified else None


--- a/ckan/tests/forms/test_authz.py	Thu Sep 01 12:28:48 2011 +0100
+++ b/ckan/tests/forms/test_authz.py	Thu Sep 01 20:01:09 2011 +0100
@@ -32,7 +32,7 @@
         linker = ckan.forms.authz.get_package_linker('delete')
         pr = anna.roles[0]
         out = linker(pr)
-        assert '<a href="/package/authz/%s' % pr.package.name in out, out
+        assert '<a href="/dataset/authz/%s' % pr.package.name in out, out
 
 
 class TestSync:


--- a/ckan/tests/functional/api/base.py	Thu Sep 01 12:28:48 2011 +0100
+++ b/ckan/tests/functional/api/base.py	Thu Sep 01 20:01:09 2011 +0100
@@ -71,11 +71,11 @@
     def package_offset(self, package_name=None):
         if package_name is None:
             # Package Register
-            return self.offset('/rest/package')
+            return self.offset('/rest/dataset')
         else:
             # Package Entity
             package_ref = self.package_ref_from_name(package_name)
-            return self.offset('/rest/package/%s' % package_ref)
+            return self.offset('/rest/dataset/%s' % package_ref)
 
     def package_ref_from_name(self, package_name):
         package = self.get_package_by_name(unicode(package_name))
@@ -140,18 +140,18 @@
         package_1_ref = self.package_ref_from_name(package_1_name)
         if package_2_name is None:
             if not relationship_type:
-                return self.offset('/rest/package/%s/relationships' % \
+                return self.offset('/rest/dataset/%s/relationships' % \
                                    package_1_ref)
             else:
-                return self.offset('/rest/package/%s/%s' %
+                return self.offset('/rest/dataset/%s/%s' %
                                    (package_1_ref, relationship_type))
         else:
             package_2_ref = self.package_ref_from_name(package_2_name)
             if not relationship_type:
-                return self.offset('/rest/package/%s/relationships/%s' % \
+                return self.offset('/rest/dataset/%s/relationships/%s' % \
                                    (package_1_ref, package_2_ref))
             else:
-                return self.offset('/rest/package/%s/%s/%s' % \
+                return self.offset('/rest/dataset/%s/%s/%s' % \
                                    (package_1_ref,
                                     relationship_type,
                                     package_2_ref))


--- a/ckan/tests/functional/api/model/test_package.py	Thu Sep 01 12:28:48 2011 +0100
+++ b/ckan/tests/functional/api/model/test_package.py	Thu Sep 01 20:01:09 2011 +0100
@@ -151,19 +151,19 @@
             'name':u'testpackage06_400',
             'resources':[u'should_be_a_dict'],
         }
-        offset = self.offset('/rest/package')
+        offset = self.offset('/rest/dataset')
         postparams = '%s=1' % self.dumps(test_params)
         res = self.app.post(offset, params=postparams, status=self.STATUS_400_BAD_REQUEST,
                 extra_environ=self.extra_environ)
 
     def test_register_post_denied(self):
-        offset = self.offset('/rest/package')
+        offset = self.offset('/rest/dataset')
         postparams = '%s=1' % self.dumps(self.package_fixture_data)
         res = self.app.post(offset, params=postparams, status=self.STATUS_403_ACCESS_DENIED)
 
     def test_register_post_readonly_fields(self):
         # (ticket 662) Post a package with readonly field such as 'id'
-        offset = self.offset('/rest/package')
+        offset = self.offset('/rest/dataset')
         data = {'name': u'test_readonly',
                 'id': u'not allowed to be set',
                 }
@@ -176,7 +176,7 @@
     def test_entity_get_ok(self):
         package_refs = [self.anna.name, self.anna.id]
         for ref in package_refs:
-            offset = self.offset('/rest/package/%s' % ref)
+            offset = self.offset('/rest/dataset/%s' % ref)
             res = self.app.get(offset, status=self.STATUS_200_OK)
             self.assert_msg_represents_anna(msg=res.body)
 
@@ -190,7 +190,7 @@
         self.assert_msg_represents_anna(msg=msg)
 
     def test_entity_get_not_found(self):
-        offset = self.offset('/rest/package/22222')
+        offset = self.offset('/rest/dataset/22222')
         res = self.app.get(offset, status=self.STATUS_404_NOT_FOUND)
         self.remove()
 
@@ -232,7 +232,7 @@
         res = self.app.delete(offset, status=self.STATUS_403_ACCESS_DENIED)
 
     def test_09_update_package_entity_not_found(self):
-        offset = self.offset('/rest/package/22222')
+        offset = self.offset('/rest/dataset/22222')
         postparams = '%s=1' % self.dumps(self.package_fixture_data)
         res = self.app.post(offset, params=postparams,
                             status=self.STATUS_404_NOT_FOUND,
@@ -286,7 +286,7 @@
         # because you should be able to specify the package both ways round
         # for both versions of the API.
         package_ref = getattr(pkg, package_ref_attribute)
-        offset = self.offset('/rest/package/%s' % package_ref)
+        offset = self.offset('/rest/dataset/%s' % package_ref)
         params = '%s=1' % self.dumps(new_fixture_data)
         method_func = getattr(self.app, method_str)
         res = method_func(offset, params=params, status=self.STATUS_200_OK,
@@ -498,13 +498,13 @@
     def test_entity_delete_not_found(self):
         package_name = u'random_one'
         assert not model.Session.query(model.Package).filter_by(name=package_name).count()
-        offset = self.offset('/rest/package/%s' % package_name)
+        offset = self.offset('/rest/dataset/%s' % package_name)
         res = self.app.delete(offset, status=self.STATUS_404_NOT_FOUND,
                               extra_environ=self.extra_environ)
 
     def test_package_revisions(self):
         # check original revision
-        res = self.app.get(self.offset('/rest/package/%s/revisions' % 'annakarenina'))
+        res = self.app.get(self.offset('/rest/dataset/%s/revisions' % 'annakarenina'))
         revisions = res.json
         assert len(revisions) == 1, len(revisions)
         expected_keys = set(('id', 'message', 'author', 'timestamp', 'approved_timestamp'))
@@ -518,7 +518,7 @@
         model.repo.commit_and_remove()
 
         # check new revision is there
-        res = self.app.get(self.offset('/rest/package/%s/revisions' % 'annakarenina'))
+        res = self.app.get(self.offset('/rest/dataset/%s/revisions' % 'annakarenina'))
         revisions = res.json
         assert len(revisions) == 2, len(revisions)
 
@@ -532,7 +532,7 @@
         model.repo.commit_and_remove()
 
         # check new revision is there
-        res = self.app.get(self.offset('/rest/package/%s/revisions' % 'annakarenina'))
+        res = self.app.get(self.offset('/rest/dataset/%s/revisions' % 'annakarenina'))
         revisions = res.json
         assert len(revisions) == 3, len(revisions)
 


--- a/ckan/tests/functional/api/test_package_search.py	Thu Sep 01 12:28:48 2011 +0100
+++ b/ckan/tests/functional/api/test_package_search.py	Thu Sep 01 20:01:09 2011 +0100
@@ -27,7 +27,7 @@
                        'geographic_coverage':'England, Wales'},
         }
         CreateTestData.create_arbitrary(self.package_fixture_data)
-        self.base_url = self.offset('/search/package')
+        self.base_url = self.offset('/search/dataset')
 
     @classmethod
     def teardown_class(cls):


--- a/ckan/tests/functional/test_authz.py	Thu Sep 01 12:28:48 2011 +0100
+++ b/ckan/tests/functional/test_authz.py	Thu Sep 01 20:01:09 2011 +0100
@@ -13,8 +13,8 @@
 
 class AuthzTestBase(object):
     INTERFACES = ['wui', 'rest']
-    DEFAULT_ENTITY_TYPES = ['package', 'group']
-    ENTITY_CLASS_MAP = {'package': model.Package,
+    DEFAULT_ENTITY_TYPES = ['dataset', 'group']
+    ENTITY_CLASS_MAP = {'dataset': model.Package,
                         'group': model.Group,
                         'package_relationship': model.PackageRelationship}
         
@@ -81,11 +81,13 @@
                                   'Should NOT be able to %s %s %r as user %r on %r interface. Diagnostics: %r'
                             raise Exception(msg % (action, entity_type, entity_name, user.name, interface, truncate(repr(diagnostics), 1000)))
 
-    def _test_via_wui(self, action, user, entity_name, entity='package'):
+    def _test_via_wui(self, action, user, entity_name, entity='dataset'):
         # Test action on WUI
         str_required_in_response = entity_name
+        controller_name = 'package' if entity == 'dataset' else entity
+
         if action in (model.Action.EDIT, model.Action.READ):
-            offset = url_for(controller=entity, action=action, id=unicode(entity_name))
+            offset = url_for(controller=controller_name, action=action, id=unicode(entity_name))
         elif action == 'search':
             offset = '/%s/search?q=%s' % (entity, entity_name)
             str_required_in_response = '/%s"' % entity_name
@@ -98,7 +100,7 @@
             offset = '/%s/new' % entity
             str_required_in_response = 'New'
         elif action == 'delete':
-            offset = url_for(controller=entity, action=model.Action.EDIT, id=unicode(entity_name))
+            offset = url_for(controller=controller_name, action=model.Action.EDIT, id=unicode(entity_name))
             str_required_in_response = 'state'
         else:
             raise NotImplementedError
@@ -114,7 +116,7 @@
         self.app.reset()
         return is_ok, [offset, user.name, tests, res.status, res.body]
 
-    def _test_via_api(self, action, user, entity_name, entity_type='package'):
+    def _test_via_api(self, action, user, entity_name, entity_type='dataset'):
         # Test action on REST
         str_required_in_response = entity_name
         if action == model.Action.EDIT:
@@ -159,11 +161,11 @@
             if action == 'edit':
                 func = self.app.put
             if isinstance(entity_name, basestring):
-                offset = '/api/rest/package/%s/relationships' % entity_name
+                offset = '/api/rest/dataset/%s/relationships' % entity_name
             else:
                 assert isinstance(entity_name, tuple)
                 if len(entity_name) == 1:
-                    offset = '/api/rest/package/%s/relationships' % entity_name[0]
+                    offset = '/api/rest/dataset/%s/relationships' % entity_name[0]
                 else:
                     if len(entity_name) == 2:
                         entity_properties = {'entity1': entity_name[0],
@@ -176,9 +178,9 @@
                     else:
                         raise NotImplementedError
                     if action in 'list':
-                        offset = '/api/rest/package/%(entity1)s/relationships/%(entity2)s' % entity_properties
+                        offset = '/api/rest/dataset/%(entity1)s/relationships/%(entity2)s' % entity_properties
                     else:
-                        offset = '/api/rest/package/%(entity1)s/%(type)s/%(entity2)s' % entity_properties
+                        offset = '/api/rest/dataset/%(entity1)s/%(type)s/%(entity2)s' % entity_properties
                     str_required_in_response = '"object": "%(entity2)s", "type": "%(type)s", "subject": "%(entity1)s"' % entity_properties
                 
         if user.name == 'visitor':
@@ -188,7 +190,6 @@
         res = func(offset, params=postparams,
                    extra_environ=environ,
                    expect_errors=True)
-        
         tests = {}
         tests['str_required (%s)' % str_required_in_response] = bool(str_required_in_response in res)
         tests['error string'] = bool('error' not in res)
@@ -331,7 +332,7 @@
         self._test_can('edit', self.visitor, [], interfaces=['rest'])
 
     def test_visitor_creates(self):
-        self._test_can('create', self.visitor, [], interfaces=['wui'], entity_types=['package'])
+        self._test_can('create', self.visitor, [], interfaces=['wui'], entity_types=['dataset'])
         self._test_cant('create', self.visitor, [], interfaces=['wui'], entity_types=['group']) # need to be sysadmin
         self._test_cant('create', self.visitor, [], interfaces=['rest'])
 
@@ -364,9 +365,9 @@
 
     def test_search_deleted(self):
         # can't search groups
-        self._test_can('search', self.pkggroupadmin, ['xx', 'rx', 'wx', 'rr', 'wr', 'ww', 'deleted'], entity_types=['package'])
-        self._test_can('search', self.mrloggedin, ['rx', 'wx', 'rr', 'wr', 'ww'], entity_types=['package'])
-        self._test_cant('search', self.mrloggedin, ['deleted', 'xx'], entity_types=['package'])
+        self._test_can('search', self.pkggroupadmin, ['xx', 'rx', 'wx', 'rr', 'wr', 'ww', 'deleted'], entity_types=['dataset'])
+        self._test_can('search', self.mrloggedin, ['rx', 'wx', 'rr', 'wr', 'ww'], entity_types=['dataset'])
+        self._test_cant('search', self.mrloggedin, ['deleted', 'xx'], entity_types=['dataset'])
         
     def test_05_author_is_new_package_admin(self):
         user = self.mrloggedin
@@ -399,7 +400,7 @@
         self._test_can('create', self.testsysadmin, [])
 
     def test_sysadmin_can_search_anything(self):
-        self._test_can('search', self.testsysadmin, ['xx', 'rx', 'wx', 'rr', 'wr', 'ww', 'deleted'], entity_types=['package'])
+        self._test_can('search', self.testsysadmin, ['xx', 'rx', 'wx', 'rr', 'wr', 'ww', 'deleted'], entity_types=['dataset'])
                 
     def test_visitor_deletes(self):
         self._test_cant('delete', self.visitor, ['gets_filled'], interfaces=['wui'])
@@ -423,7 +424,7 @@
         self._test_can('purge', self.pkggroupadmin, ['gets_filled'], interfaces=['rest'])
 
     def test_sysadmin_purges(self):
-        self._test_can('purge', self.testsysadmin, ['gets_filled'], interfaces=['rest'], entity_types=['package'])
+        self._test_can('purge', self.testsysadmin, ['gets_filled'], interfaces=['rest'], entity_types=['dataset'])
     
     def test_sysadmin_relationships(self):
         opts = {'interfaces': ['rest'],
@@ -536,7 +537,7 @@
         self._test_can('edit', self.testsysadmin, 'deleted')
 
     def test_sysadmin_can_search_anything(self):
-        self._test_can('search', self.testsysadmin, self.ENTITY_NAME, entity_types=['package']) # cannot search groups
+        self._test_can('search', self.testsysadmin, self.ENTITY_NAME, entity_types=['dataset']) # cannot search groups
 
     def test_pkggroupadmin_read(self):
         # These don't make sense - there should be no difference between
@@ -554,14 +555,14 @@
 
     def test_pkggroupadmin_search(self):
         # can't search as not a site reader
-        self._test_cant('search', self.pkggroupadmin, self.ENTITY_NAME, entity_types=['package'])
+        self._test_cant('search', self.pkggroupadmin, self.ENTITY_NAME, entity_types=['dataset'])
 
     def test_site_reader(self):
-        self._test_can('search', self.site_reader, self.ENTITY_NAME, entity_types=['package']) # cannot search groups
+        self._test_can('search', self.site_reader, self.ENTITY_NAME, entity_types=['dataset']) # cannot search groups
         self._test_can('read', self.site_reader, self.ENTITY_NAME, entity_types=['tag'])
 
     def test_outcast_search(self):
-        self._test_cant('search', self.outcast, self.ENTITY_NAME, entity_types=['package']) # cannot search groups
+        self._test_cant('search', self.outcast, self.ENTITY_NAME, entity_types=['dataset']) # cannot search groups
         self._test_cant('read', self.outcast, self.ENTITY_NAME, entity_types=['tag'])
 
         


--- a/ckan/tests/functional/test_package.py	Thu Sep 01 12:28:48 2011 +0100
+++ b/ckan/tests/functional/test_package.py	Thu Sep 01 20:01:09 2011 +0100
@@ -550,7 +550,7 @@
         print 'MAIN', main_html
         assert 'This is an old revision of this package' in main_html
         assert 'at 2011-01-01 00:00' in main_html
-        self.check_named_element(main_html, 'a', 'href="/package/%s"' % self.pkg_name)
+        self.check_named_element(main_html, 'a', 'href="/dataset/%s"' % self.pkg_name)
         print 'PKG', pkg_html
         assert 'title1' in pkg_html
         assert 'key2' not in pkg_html
@@ -568,7 +568,7 @@
         print 'MAIN', main_html
         assert 'This is an old revision of this package' in main_html
         assert 'at 2011-01-02 00:00' in main_html
-        self.check_named_element(main_html, 'a', 'href="/package/%s"' % self.pkg_name)
+        self.check_named_element(main_html, 'a', 'href="/dataset/%s"' % self.pkg_name)
         print 'PKG', pkg_html
         assert 'title2' in pkg_html
         assert 'key2' in pkg_html
@@ -587,7 +587,7 @@
         assert 'This is an old revision of this package' not in main_html
         assert 'This is the current revision of this package' in main_html
         assert 'at 2011-01-03 00:00' in main_html
-        self.check_named_element(main_html, 'a', 'href="/package/%s"' % self.pkg_name)
+        self.check_named_element(main_html, 'a', 'href="/dataset/%s"' % self.pkg_name)
         print 'PKG', pkg_html
         assert 'title3' in pkg_html
         assert 'key2' in pkg_html
@@ -792,9 +792,9 @@
         res = fv.submit('save', status=400)
 
     def test_redirect_after_edit_using_param(self):
-        return_url = 'http://random.site.com/package/<NAME>?test=param'
+        return_url = 'http://random.site.com/dataset/<NAME>?test=param'
         # It's useful to know that this url encodes to:
-        # 'http%3A%2F%2Frandom.site.com%2Fpackage%2F%3CNAME%3E%3Ftest%3Dparam'
+        # 'http%3A%2F%2Frandom.site.com%2Fdataset%2F%3CNAME%3E%3Ftest%3Dparam'
         expected_redirect = return_url
         self._check_redirect(return_url, expected_redirect,
                              pkg_name_to_edit=self.editpkg_name)
@@ -1166,9 +1166,9 @@
         self._assert_form_errors(res)
 
     def test_redirect_after_new_using_param(self):
-        return_url = 'http://random.site.com/package/<NAME>?test=param'
+        return_url = 'http://random.site.com/dataset/<NAME>?test=param'
         # It's useful to know that this url encodes to:
-        # 'http%3A%2F%2Frandom.site.com%2Fpackage%2F%3CNAME%3E%3Ftest%3Dparam'
+        # 'http%3A%2F%2Frandom.site.com%2Fdataset%2F%3CNAME%3E%3Ftest%3Dparam'
         expected_redirect = return_url
         self._check_redirect(return_url, expected_redirect,
                              pkg_name_to_edit='')
@@ -1648,7 +1648,7 @@
     def test_etags_in_response(self):
         c.user = 'annafan'
         c.userobj = model.User.by_name(u'annafan')
-        res = self.app.get('/package/annakarenina',
+        res = self.app.get('/dataset/annakarenina',
                            extra_environ={'REMOTE_USER':c.user})
         anna_hash = str(PackageController._pkg_cache_key(self.anna))
         self.assert_equal(res.header_dict['ETag'], anna_hash)
@@ -1665,7 +1665,7 @@
 
     def test_package_autocomplete(self):
         query = 'a'
-        res = self.app.get('/package/autocomplete?q=%s' % query)
+        res = self.app.get('/dataset/autocomplete?q=%s' % query)
         
         expected = ['A Wonderful Story (warandpeace)|warandpeace','annakarenina|annakarenina']
         received = sorted(res.body.split('\n'))


--- a/ckan/tests/functional/test_package_relationships.py	Thu Sep 01 12:28:48 2011 +0100
+++ b/ckan/tests/functional/test_package_relationships.py	Thu Sep 01 20:01:09 2011 +0100
@@ -22,7 +22,7 @@
             return res
         res = read_package(u'homer')
         self.check_named_element(res, 'li', 'is a child of', 'abraham')
-        self.check_named_element(res, 'li', 'is a child of', '<a href="/package/abraham">abraham</a>')
+        self.check_named_element(res, 'li', 'is a child of', '<a href="/dataset/abraham">abraham</a>')
         self.check_named_element(res, 'li', 'is a parent of', 'bart')
         self.check_named_element(res, 'li', 'is a parent of', 'lisa')
         self.check_named_element(res, 'li', 'has derivation', 'homer_derived')


--- a/test-core.ini	Thu Sep 01 12:28:48 2011 +0100
+++ b/test-core.ini	Thu Sep 01 20:01:09 2011 +0100
@@ -27,8 +27,8 @@
 # pyamqplib or queue
 carrot_messaging_library = queue
 ckan.site_url = http://test.ckan.net
-package_new_return_url = http://localhost/package/<NAME>?test=new
-package_edit_return_url = http://localhost/package/<NAME>?test=edit
+package_new_return_url = http://localhost/dataset/<NAME>?test=new
+package_edit_return_url = http://localhost/dataset/<NAME>?test=edit
 rdf_packages = http://test.com/package/
 ckan.extra_resource_fields = alt_url
 


http://bitbucket.org/okfn/ckan/changeset/e7330b35fea3/
changeset:   e7330b35fea3
branch:      feature-1293-rename-package-to-dataset
user:        John Glover
date:        2011-09-01 21:02:12
summary:     [1293] Merge with default
affected #:  6 files (2.6 KB)

--- a/ckan/controllers/group_formalchemy.py	Thu Sep 01 20:01:09 2011 +0100
+++ b/ckan/controllers/group_formalchemy.py	Thu Sep 01 20:02:12 2011 +0100
@@ -16,10 +16,15 @@
 from ckan.lib.base import ValidationException
 from ckan.controllers.group import GroupController
 
+from ckan.plugins import PluginImplementations, IGroupController
+
 log = logging.getLogger(__name__)
 
 class GroupFormalchemyController(GroupController):
 
+    def __init__(self):
+        self.extensions = PluginImplementations(IGroupController)
+
     def new(self):
         record = model.Group
         c.error = ''


--- a/ckan/controllers/package.py	Thu Sep 01 20:01:09 2011 +0100
+++ b/ckan/controllers/package.py	Thu Sep 01 20:02:12 2011 +0100
@@ -23,7 +23,6 @@
 from ckan.lib.navl.dictization_functions import DataError, unflatten, validate
 from ckan.logic import NotFound, NotAuthorized, ValidationError
 from ckan.logic import tuplize_dict, clean_dict, parse_params, flatten_to_string_key
-from ckan.plugins import PluginImplementations, IPackageController
 from ckan.lib.dictization import table_dictize
 import ckan.forms
 import ckan.authz
@@ -97,7 +96,6 @@
     ## end hooks
 
     authorizer = ckan.authz.Authorizer()
-    extensions = PluginImplementations(IPackageController)
 
     def search(self):
         try:
@@ -253,9 +251,6 @@
         # used by disqus plugin
         c.current_package_id = c.pkg.id
 
-        for item in self.extensions:
-            item.read(c.pkg)
-
         #render the package
         PackageSaver().render_package(c.pkg_dict)
         return render('package/comments.html')


--- a/ckan/controllers/package_formalchemy.py	Thu Sep 01 20:01:09 2011 +0100
+++ b/ckan/controllers/package_formalchemy.py	Thu Sep 01 20:02:12 2011 +0100
@@ -9,11 +9,15 @@
 from pylons.i18n import get_lang, _
 from ckan.logic import check_access, NotAuthorized
 
+from ckan.plugins import PluginImplementations, IPackageController
 
 log = logging.getLogger(__name__)
 
 class PackageFormalchemyController(PackageController):
 
+    def __init__(self):
+        self.extensions = PluginImplementations(IPackageController)
+
     def new(self):
         c.error = ''
         api_url = config.get('ckan.api_url', '/').rstrip('/')


--- a/ckan/lib/dictization/model_save.py	Thu Sep 01 20:01:09 2011 +0100
+++ b/ckan/lib/dictization/model_save.py	Thu Sep 01 20:02:12 2011 +0100
@@ -320,6 +320,9 @@
     User = model.User
     if user:
         user_dict['id'] = user.id
+    
+    if 'password' in user_dict and not len(user_dict['password']):
+        del user_dict['password']
 
     user = table_dict_save(user_dict, User, context)
 


--- a/ckan/lib/mailer.py	Thu Sep 01 20:01:09 2011 +0100
+++ b/ckan/lib/mailer.py	Thu Sep 01 20:02:12 2011 +0100
@@ -44,8 +44,9 @@
         server.sendmail(mail_from, [recipient_email], msg.as_string())
         server.quit()
     except Exception, e:
-        log.exception(e)
-        raise MailerException(e.message)
+        msg = '%r' % e
+        log.exception(msg)
+        raise MailerException(msg)
 
 def mail_recipient(recipient_name, recipient_email, subject, 
         body, headers={}):


--- a/ckan/tests/functional/test_user.py	Thu Sep 01 20:01:09 2011 +0100
+++ b/ckan/tests/functional/test_user.py	Thu Sep 01 20:02:12 2011 +0100
@@ -416,6 +416,59 @@
         main_res = self.main_div(res)
         assert new_about in main_res, main_res
 
+    def test_user_edit_no_password(self):
+        # create user
+        username = 'testedit2'
+        about = u'Test About'
+        user = model.User.by_name(unicode(username))
+        if not user:
+            model.Session.add(model.User(name=unicode(username), about=about,
+                                         password='letmein'))
+            model.repo.commit_and_remove()
+            user = model.User.by_name(unicode(username))
+
+        old_password = user.password    
+
+        # edit
+        new_about = u'Changed about'
+        offset = url_for(controller='user', action='edit', id=user.id)
+        res = self.app.get(offset, status=200, extra_environ={'REMOTE_USER':username})
+        main_res = self.main_div(res)
+        assert 'Edit User: ' in main_res, main_res
+        assert about in main_res, main_res
+        fv = res.forms['user-edit']
+        fv['about'] = new_about
+        fv['password1'] = ''
+        fv['password2'] = ''
+
+        res = fv.submit('preview', extra_environ={'REMOTE_USER':username})
+        
+        # preview
+        main_res = self.main_div(res)
+        assert 'Edit User: testedit2' in main_res, main_res
+        in_preview = main_res[main_res.find('Preview'):]
+        assert new_about in in_preview, in_preview
+
+        # commit
+        res = fv.submit('save', extra_environ={'REMOTE_USER':username})      
+        assert res.status == 302, self.main_div(res).encode('utf8')
+        res = res.follow()
+        main_res = self.main_div(res)
+        assert 'testedit2' in main_res, main_res
+        assert new_about in main_res, main_res
+
+        # read, not logged in
+        offset = url_for(controller='user', action='read', id=user.id)
+        res = self.app.get(offset, status=200)
+        main_res = self.main_div(res)
+        assert new_about in main_res, main_res
+
+        updated_user = model.User.by_name(unicode(username))
+        new_password = updated_user.password
+
+        # Ensure password has not changed
+        assert old_password == new_password
+
     def test_user_edit_no_user(self):
         offset = url_for(controller='user', action='edit', id=None)
         res = self.app.get(offset, status=400)


http://bitbucket.org/okfn/ckan/changeset/4d62d1500cdc/
changeset:   4d62d1500cdc
branch:      feature-1293-rename-package-to-dataset
user:        John Glover
date:        2011-09-01 21:30:24
summary:     [1293] Fix functional/api/model/test_package.py
affected #:  1 file (0 bytes)

--- a/ckan/tests/functional/api/base.py	Thu Sep 01 20:02:12 2011 +0100
+++ b/ckan/tests/functional/api/base.py	Thu Sep 01 20:30:24 2011 +0100
@@ -221,7 +221,7 @@
 
         # Todo: What is the deal with ckan_url? And should this use IDs rather than names?
         assert 'ckan_url' in msg
-        assert '"ckan_url": "http://test.ckan.net/package/annakarenina"' in msg, msg
+        assert '"ckan_url": "http://test.ckan.net/dataset/annakarenina"' in msg, msg
 
     def assert_msg_represents_roger(self, msg):
         assert 'roger' in msg, msg

Repository URL: https://bitbucket.org/okfn/ckan/

--

This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.




More information about the ckan-changes mailing list