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

Bitbucket commits-noreply at bitbucket.org
Fri Aug 12 17:25:53 UTC 2011


6 new changesets in ckan:

http://bitbucket.org/okfn/ckan/changeset/94b2cd9b0001/
changeset:   94b2cd9b0001
branch:      feature-1253-authz-refactor
user:        amercader
date:        2011-08-12 12:33:14
summary:     [auth] Raise an exception if the auth function is not found
affected #:  1 file (72 bytes)

--- a/ckan/new_authz.py	Thu Aug 11 14:59:19 2011 +0100
+++ b/ckan/new_authz.py	Fri Aug 12 11:33:14 2011 +0100
@@ -2,6 +2,7 @@
 from ckan.plugins import implements, SingletonPlugin
 from ckan.plugins import IAuthFunctions
 from ckan.plugins import PluginImplementations
+from ckan.lib.base import _
 
 log = getLogger(__name__)
 
@@ -14,7 +15,7 @@
     if auth_function:
         return auth_function(context, data_dict)
     else:
-        return {'success': True}
+        raise ValueError(_('Authorization function not found: %s' % action))
 
 def _get_auth_function(action):
     if _auth_functions:


http://bitbucket.org/okfn/ckan/changeset/434f8aa3fa5b/
changeset:   434f8aa3fa5b
branch:      feature-1253-authz-refactor
user:        amercader
date:        2011-08-12 12:55:15
summary:     [auth] Fix wrong auth function
affected #:  1 file (2 bytes)

--- a/ckan/templates/group/layout.html	Fri Aug 12 11:33:14 2011 +0100
+++ b/ckan/templates/group/layout.html	Fri Aug 12 11:55:15 2011 +0100
@@ -24,7 +24,7 @@
   <py:match path="minornavigation" py:if="c.group"><ul class="tabbed"><li>${h.subnav_link(c, h.icon('group') + _('View'), controller='group', action='read', id=c.group.name)}</li>
-    <li py:if="h.check_access('group_edit',{'id':c.group.id})">
+    <li py:if="h.check_access('group_update',{'id':c.group.id})">
       ${h.subnav_link(c, h.icon('group_edit') + _('Edit'), controller='group', action='edit', id=c.group.name)}
     </li><li>${h.subnav_link(c, h.icon('page_white_stack') + _('History'), controller='group', action='history', id=c.group.name)}</li>


http://bitbucket.org/okfn/ckan/changeset/b233d12909a3/
changeset:   b233d12909a3
branch:      feature-1253-authz-refactor
user:        amercader
date:        2011-08-12 17:47:17
summary:     [auth] Restore authorized query on auth group listing
affected #:  3 files (431 bytes)

--- a/ckan/controllers/package.py	Fri Aug 12 11:55:15 2011 +0100
+++ b/ckan/controllers/package.py	Fri Aug 12 16:47:17 2011 +0100
@@ -78,8 +78,9 @@
             raise DataError(data_dict)
 
     def _setup_template_variables(self, context, data_dict):
-        c.groups = get.group_list_available(context, data_dict)
         c.groups_authz = get.group_list_authz(context, data_dict)
+        data_dict.update({'available_only':True})
+        c.groups_available = get.group_list_authz(context, data_dict)
         c.licences = [('', '')] + model.Package.get_license_options()
         c.is_sysadmin = Authorizer().is_sysadmin(c.user)
         c.resource_columns = model.Resource.get_columns()
@@ -392,6 +393,7 @@
         vars = {'data': data, 'errors': errors, 'error_summary': error_summary}
 
         self._setup_template_variables(context, {'id': id})
+
         c.form = render(self.package_form, extra_vars=vars)
         return render('package/edit.html')
 


--- a/ckan/logic/action/get.py	Fri Aug 12 11:55:15 2011 +0100
+++ b/ckan/logic/action/get.py	Fri Aug 12 16:47:17 2011 +0100
@@ -137,35 +137,29 @@
     return group_list
 
 def group_list_authz(context, data_dict):
+    '''
+    Returns a list of groups which the user is allowed to edit
+
+    If 'available_only' is specified, the existing groups in the package are
+    removed.
+
+    '''
     model = context['model']
     user = context['user']
+    available_only = data_dict.get('available_only',False)
 
     check_access('group_list_authz',context, data_dict)
 
-    query = model.Session.query(model.GroupRevision)
-    query = query.filter(model.GroupRevision.state=='active')
-    query = query.filter(model.GroupRevision.current==True)
+    from ckan.authz import Authorizer
+    query = Authorizer().authorized_query(user, model.Group, model.Action.EDIT)
+    groups = set(query.all())
+    
+    if available_only:
+        package = context.get('package')
+        if package:
+            groups = groups - set(package.groups)
 
-    groups = set(query.all())
-    return dict((group.id, group.name) for group in groups)
-
-def group_list_available(context, data_dict):
-    model = context['model']
-    user = context['user']
-    pkg = context.get('package')
-
-    check_access('group_list_available',context, data_dict)
-
-    query = model.Session.query(model.GroupRevision)
-    query = query.filter(model.GroupRevision.state=='active')
-    query = query.filter(model.GroupRevision.current==True)
-
-    groups = set(query.all())
-
-    if pkg:
-        groups = groups - set(pkg.groups)
-
-    return [(group.id, group.name) for group in groups]
+    return [{'id':group.id,'name':group.name} for group in groups]
 
 def group_revision_list(context, data_dict):
     model = context['model']


--- a/ckan/templates/package/new_package_form.html	Fri Aug 12 11:55:15 2011 +0100
+++ b/ckan/templates/package/new_package_form.html	Fri Aug 12 16:47:17 2011 +0100
@@ -101,23 +101,28 @@
   <legend>Groups</legend><dl><py:for each="num, group in enumerate(data.get('groups', []))">
+        <?python
+        authorized_group = [group_authz for group_authz in c.groups_authz if group_authz['id'] == group['id']]
+        authorized_group = authorized_group[0] if authorized_group else None
+        ?>
+
       <dt py:if="'id' in group">
-      <input type="${'checkbox' if group['id'] in c.groups_authz else 'hidden'}" name="groups__${num}__id" checked="checked" value="${group['id']}" />
-      <input type="hidden" name="groups__${num}__name" value="${group.get('name', c.groups_authz.get(group['id']))}" />
+      <input type="${'checkbox' if authorized_group else 'hidden'}" name="groups__${num}__id" checked="checked" value="${group['id']}" />
+      <input type="hidden" name="groups__${num}__name" value="${group.get('name', authorized_group['name'])}" /></dt>     
-      <dd py:if="'id' in group"><label for="groups__${num}__checked">${group.get('name', c.groups_authz.get(group['id']))}</label></dd>
+      <dd py:if="'id' in group"><label for="groups__${num}__checked">${group.get('name', authorized_group['name'])}</label></dd></py:for><dt>Group</dt>
-    <dd py:if="c.groups"> 
+    <dd py:if="c.groups_available"><select id="groups__${len(data.get('groups', []))}__id" name="groups__${len(data.get('groups', []))}__id"><option selected="selected" value="">(None)</option>
-        <py:for each="group_id, group_name in c.groups">
-          <option value="${group_id}" py:if="group_id in c.groups_authz">${group_name}</option>
+        <py:for each="group in c.groups_available">
+          <option value="${group['id']}" >${group['name']}</option></py:for></select></dd> 
-    <dd py:if="not c.groups">Cannot add any groups.</dd>
+    <dd py:if="not c.groups_available">Cannot add any groups.</dd></dl></fieldset><fieldset id='detail'>


http://bitbucket.org/okfn/ckan/changeset/7cb28b2bda05/
changeset:   7cb28b2bda05
branch:      feature-1253-authz-refactor
user:        amercader
date:        2011-08-12 17:58:45
summary:     [auth] Fix bugs in package relationship list auth function
affected #:  1 file (5 bytes)

--- a/ckan/logic/auth/get.py	Fri Aug 12 16:47:17 2011 +0100
+++ b/ckan/logic/auth/get.py	Fri Aug 12 16:58:45 2011 +0100
@@ -61,12 +61,12 @@
     # Users list is visible by default
     return {'success': True}
 
-def package_relationship_list(context, data_dict):
+def package_relationships_list(context, data_dict):
     model = context['model']
     user = context['user']
 
     id = data_dict['id']
-    id2 = data_dict['id2']
+    id2 = data_dict.get('id2')
     pkg1 = model.Package.get(id)
     pkg2 = model.Package.get(id2)
 


http://bitbucket.org/okfn/ckan/changeset/2b9dc8f81632/
changeset:   2b9dc8f81632
branch:      feature-1253-authz-refactor
user:        amercader
date:        2011-08-12 18:32:01
summary:     Fix bug in package form
affected #:  1 file (56 bytes)

--- a/ckan/templates/package/new_package_form.html	Fri Aug 12 16:58:45 2011 +0100
+++ b/ckan/templates/package/new_package_form.html	Fri Aug 12 17:32:01 2011 +0100
@@ -108,9 +108,9 @@
 
       <dt py:if="'id' in group"><input type="${'checkbox' if authorized_group else 'hidden'}" name="groups__${num}__id" checked="checked" value="${group['id']}" />
-      <input type="hidden" name="groups__${num}__name" value="${group.get('name', authorized_group['name'])}" />
+      <input type="hidden" name="groups__${num}__name" value="${group.get('name', authorized_group['name'] if authorized_group else '')}" /></dt>     
-      <dd py:if="'id' in group"><label for="groups__${num}__checked">${group.get('name', authorized_group['name'])}</label></dd>
+      <dd py:if="'id' in group"><label for="groups__${num}__checked">${group.get('name', authorized_group['name'] if authorized_group else '')}</label></dd></py:for><dt>Group</dt>


http://bitbucket.org/okfn/ckan/changeset/9c8b7fb5f494/
changeset:   9c8b7fb5f494
branch:      feature-1253-authz-refactor
user:        amercader
date:        2011-08-12 19:24:35
summary:     [logic] Update calls to action functions
affected #:  7 files (124 bytes)

--- a/ckan/controllers/api.py	Fri Aug 12 17:32:01 2011 +0100
+++ b/ckan/controllers/api.py	Fri Aug 12 18:24:35 2011 +0100
@@ -12,10 +12,6 @@
 from ckan.lib.munge import munge_title_to_name
 from ckan.lib.navl.dictization_functions import DataError
 from ckan.logic import get_action, check_access
-import ckan.logic.action.get as get 
-import ckan.logic.action.create as create
-import ckan.logic.action.update as update
-import ckan.logic.action.delete as delete
 from ckan.logic import NotFound, NotAuthorized, ValidationError
 from ckan.lib.jsonp import jsonpify
 from ckan.forms.common import package_exists
@@ -182,13 +178,13 @@
                    'user': c.user, 'api_version': ver}
         log.debug('listing: %s' % context)
         action_map = {
-            'revision': get.revision_list,
-            'group': get.group_list,
-            'package': get.package_list,
-            'tag': get.tag_list,
-            'licenses': get.licence_list,
-            ('package', 'relationships'): get.package_relationships_list,
-            ('package', 'revisions'): get.package_revision_list,
+            'revision': get_action('revision_list'),
+            'group': get_action('group_list'),
+            'package': get_action('package_list'),
+            'tag': get_action('tag_list'),
+            'licenses': get_action('licence_list'),
+            ('package', 'relationships'): get_action('package_relationships_list'),
+            ('package', 'revisions'): get_action('package_revision_list'),
         }
 
         action = action_map.get((register, subregister)) 
@@ -207,11 +203,11 @@
 
     def show(self, ver=None, register=None, subregister=None, id=None, id2=None):
         action_map = {
-            'revision': get.revision_show,
-            'group': get.group_show_rest,
-            'tag': get.tag_show_rest,
-            'package': get.package_show_rest,
-            ('package', 'relationships'): get.package_relationships_list,
+            'revision': get_action('revision_show'),
+            'group': get_action('group_show_rest'),
+            'tag': get_action('tag_show_rest'),
+            'package': get_action('package_show_rest'),
+            ('package', 'relationships'): get_action('package_relationships_list'),
         }
 
         context = {'model': model, 'session': model.Session, 'user': c.user,
@@ -219,7 +215,7 @@
         data_dict = {'id': id, 'id2': id2, 'rel': subregister}
 
         for type in model.PackageRelationship.get_all_types():
-            action_map[('package', type)] = get.package_relationships_list
+            action_map[('package', type)] = get_action('package_relationships_list')
         log.debug('show: %s' % context)
 
         action = action_map.get((register, subregister)) 
@@ -250,7 +246,7 @@
         }
 
         for type in model.PackageRelationship.get_all_types():
-            action_map[('package', type)] = create.package_relationship_create
+            action_map[('package', type)] = get_action('package_relationship_create')
 
         context = {'model': model, 'session': model.Session, 'user': c.user,
                    'api_version': ver}
@@ -298,7 +294,7 @@
              'group': get_action('group_update_rest'),
         }
         for type in model.PackageRelationship.get_all_types():
-            action_map[('package', type)] = update.package_relationship_update
+            action_map[('package', type)] = get_action('package_relationship_update')
 
         context = {'model': model, 'session': model.Session, 'user': c.user,
                    'api_version': ver, 'id': id}
@@ -335,12 +331,12 @@
 
     def delete(self, ver=None, register=None, subregister=None, id=None, id2=None):
         action_map = {
-            ('package', 'relationships'): delete.package_relationship_delete,
-             'group': delete.group_delete,
-             'package': delete.package_delete,
+            ('package', 'relationships'): get_action('package_relationship_delete'),
+             'group': get_action('group_delete'),
+             'package': get_action('package_delete'),
         }
         for type in model.PackageRelationship.get_all_types():
-            action_map[('package', type)] = delete.package_relationship_delete
+            action_map[('package', type)] = get_action('package_relationship_delete')
 
         context = {'model': model, 'session': model.Session, 'user': c.user,
                    'api_version': ver}
@@ -467,7 +463,7 @@
 
         data_dict = {'all_fields': True}
 
-        tag_list = get.tag_list(context, data_dict)
+        tag_list = get_action('tag_list')(context, data_dict)
         results = []
         for tag in tag_list:
             tag_count = len(tag['packages'])
@@ -504,7 +500,7 @@
 
             data_dict = {'q':q,'limit':limit}
 
-            user_list = get.user_autocomplete(context,data_dict)
+            user_list = get_action('user_autocomplete')(context,data_dict)
         return user_list
 
 
@@ -550,7 +546,7 @@
 
             data_dict = {'q':q,'limit':limit}
 
-            tag_names = get.tag_autocomplete(context,data_dict)
+            tag_names = get_action('tag_autocomplete')(context,data_dict)
 
         resultSet = {
             'ResultSet': {
@@ -567,7 +563,7 @@
             context = {'model': model, 'session': model.Session,
                        'user': c.user or c.author}
             data_dict = {'q': q, 'limit': limit}
-            formats = get.format_autocomplete(context, data_dict)
+            formats = get_action('format_autocomplete')(context, data_dict)
 
         resultSet = {
             'ResultSet': {


--- a/ckan/controllers/group.py	Fri Aug 12 17:32:01 2011 +0100
+++ b/ckan/controllers/group.py	Fri Aug 12 18:24:35 2011 +0100
@@ -9,11 +9,9 @@
 from ckan.authz import Authorizer
 from ckan.lib.helpers import Page
 from ckan.plugins import PluginImplementations, IGroupController
-import ckan.logic.action.create as create
-import ckan.logic.action.update as update
-import ckan.logic.action.get as get
 from ckan.lib.navl.dictization_functions import DataError, unflatten, validate
-from ckan.logic import NotFound, NotAuthorized, ValidationError, check_access
+from ckan.logic import NotFound, NotAuthorized, ValidationError
+from ckan.logic import check_access, get_action
 from ckan.logic.schema import group_form_schema
 from ckan.logic import tuplize_dict, clean_dict, parse_params
 import ckan.forms
@@ -59,7 +57,7 @@
         except NotAuthorized:
             abort(401, _('Not authorized to see this page'))
         
-        results = get.group_list(context,data_dict)
+        results = get_action('group_list')(context,data_dict)
 
         c.page = Page(
             collection=results,
@@ -75,7 +73,7 @@
                    'schema': self._form_to_db_schema()}
         data_dict = {'id': id}
         try:
-            c.group_dict = get.group_show(context, data_dict)
+            c.group_dict = get_action('group_show')(context, data_dict)
             c.group = context['group']
         except NotFound:
             abort(404, _('Group not found'))
@@ -134,7 +132,7 @@
             return self._save_edit(id, context)
 
         try:
-            old_data = get.group_show(context, data_dict)
+            old_data = get_action('group_show')(context, data_dict)
             c.grouptitle = old_data.get('title')
             c.groupname = old_data.get('name')
             schema = self._db_to_form_schema()
@@ -165,7 +163,7 @@
             data_dict = clean_dict(unflatten(
                 tuplize_dict(parse_params(request.params))))
             context['message'] = data_dict.get('log_message', '')
-            group = create.group_create(context, data_dict)
+            group = get_action('group_create')(context, data_dict)
             h.redirect_to(controller='group', action='read', id=group['name'])
         except NotAuthorized:
             abort(401, _('Unauthorized to read group %s') % '')
@@ -184,7 +182,7 @@
                 tuplize_dict(parse_params(request.params))))
             context['message'] = data_dict.get('log_message', '')
             data_dict['id'] = id
-            group = update.group_update(context, data_dict)
+            group = get_action('group_update')(context, data_dict)
             h.redirect_to(controller='group', action='read', id=group['name'])
         except NotAuthorized:
             abort(401, _('Unauthorized to read group %s') % id)
@@ -433,8 +431,8 @@
                    'schema': self._form_to_db_schema()}
         data_dict = {'id': id}
         try:
-            c.group_dict = get.group_show(context, data_dict)
-            c.group_revisions = get.group_revision_list(context, data_dict)
+            c.group_dict = get_action('group_show')(context, data_dict)
+            c.group_revisions = get_action('group_revision_list')(context, data_dict)
             #TODO: remove
             # Still necessary for the authz check in group/layout.html
             c.group = context['group']


--- a/ckan/controllers/home.py	Fri Aug 12 17:32:01 2011 +0100
+++ b/ckan/controllers/home.py	Fri Aug 12 18:24:35 2011 +0100
@@ -5,8 +5,8 @@
 from genshi.template import NewTextTemplate
 
 from ckan.authz import Authorizer
-import ckan.logic.action.get as get
-from ckan.logic import NotAuthorized,check_access
+from ckan.logic import NotAuthorized
+from ckan.logic import check_access, get_action
 from ckan.i18n import set_session_locale
 from ckan.lib.search import query_for, QueryOptions, SearchError
 from ckan.lib.cache import proxy_cache, get_cache_expires
@@ -52,7 +52,7 @@
         c.facets = query.facets
         c.fields = []
         c.package_count = query.count
-        c.latest_packages = get.current_package_list_with_resources({'model': model,
+        c.latest_packages = get_action('current_package_list_with_resources')({'model': model,
                                                                  'user': c.user},
                                                                  {'limit': 5})      
         return render('home/index.html', cache_key=cache_key,


--- a/ckan/controllers/package.py	Fri Aug 12 17:32:01 2011 +0100
+++ b/ckan/controllers/package.py	Fri Aug 12 18:24:35 2011 +0100
@@ -12,9 +12,6 @@
 from autoneg.accept import negotiate
 from babel.dates import format_date, format_datetime, format_time
 
-import ckan.logic.action.create as create
-import ckan.logic.action.update as update
-import ckan.logic.action.get as get
 from ckan.logic import get_action, check_access
 from ckan.logic.schema import package_form_schema
 from ckan.lib.base import request, c, BaseController, model, abort, h, g, render
@@ -78,9 +75,9 @@
             raise DataError(data_dict)
 
     def _setup_template_variables(self, context, data_dict):
-        c.groups_authz = get.group_list_authz(context, data_dict)
+        c.groups_authz = get_action('group_list_authz')(context, data_dict)
         data_dict.update({'available_only':True})
-        c.groups_available = get.group_list_authz(context, data_dict)
+        c.groups_available = get_action('group_list_authz')(context, data_dict)
         c.licences = [('', '')] + model.Package.get_license_options()
         c.is_sysadmin = Authorizer().is_sysadmin(c.user)
         c.resource_columns = model.Resource.get_columns()
@@ -161,7 +158,7 @@
                          'filter_by_downloadable':c.downloadable_only,
                         }
 
-            query = get.package_search(context,data_dict)
+            query = get_action('package_search')(context,data_dict)
 
             c.page = h.Page(
                 collection=query['results'],
@@ -211,7 +208,7 @@
             
         #check if package exists
         try:
-            c.pkg_dict = get.package_show(context, data_dict)
+            c.pkg_dict = get_action('package_show')(context, data_dict)
             c.pkg = context['package']
         except NotFound:
             abort(404, _('Package not found'))
@@ -246,7 +243,7 @@
 
         #check if package exists
         try:
-            c.pkg_dict = get.package_show(context, {'id':id})
+            c.pkg_dict = get_action('package_show')(context, {'id':id})
             c.pkg = context['package']
         except NotFound:
             abort(404, _('Package not found'))
@@ -284,8 +281,8 @@
                    'extras_as_string': True,}
         data_dict = {'id':id}
         try:
-            c.pkg_dict = get.package_show(context, data_dict)
-            c.pkg_revisions = get.package_revision_list(context, data_dict)
+            c.pkg_dict = get_action('package_show')(context, data_dict)
+            c.pkg_revisions = get_action('package_revision_list')(context, data_dict)
             #TODO: remove
             # Still necessary for the authz check in group/layout.html
             c.pkg = context['package']
@@ -372,7 +369,7 @@
         if (context['save'] or context['preview']) and not data:
             return self._save_edit(id, context)
         try:
-            old_data = get.package_show(context, {'id':id})
+            old_data = get_action('package_show')(context, {'id':id})
             schema = self._db_to_form_schema()
             if schema:
                 old_data, errors = validate(old_data, schema)
@@ -405,7 +402,7 @@
                    'revision_id': revision}
 
         try:
-            data = get.package_show(context, {'id': id})
+            data = get_action('package_show')(context, {'id': id})
             schema = self._db_to_form_schema()
             if schema:
                 data, errors = validate(data, schema)
@@ -428,7 +425,7 @@
                    'extras_as_string': True,}
         data_dict = {'id':id}
         try:
-            pkg_revisions = get.package_revision_list(context, data_dict)
+            pkg_revisions = get_action('package_revision_list')(context, data_dict)
         except NotAuthorized:
             abort(401, _('Unauthorized to read package %s') % '')
         except NotFound:
@@ -492,7 +489,7 @@
             data_dict['id'] = id
             pkg = get_action('package_update')(context, data_dict)
             if request.params.get('save', '') == 'Approve':
-                update.make_latest_pending_package_active(context, data_dict)
+                get_action('make_latest_pending_package_active')(context, data_dict)
             c.pkg = context['package']
             c.pkg_dict = pkg
 
@@ -779,7 +776,7 @@
 
         data_dict = {'q':q}
 
-        packages = get.package_autocomplete(context,data_dict)
+        packages = get_action('package_autocomplete')(context,data_dict)
 
         pkg_list = []
         for pkg in packages:


--- a/ckan/controllers/tag.py	Fri Aug 12 17:32:01 2011 +0100
+++ b/ckan/controllers/tag.py	Fri Aug 12 18:24:35 2011 +0100
@@ -7,8 +7,8 @@
 from ckan.lib.cache import proxy_cache
 from ckan.lib.helpers import AlphaPage, Page
 
-from ckan.logic import NotFound, NotAuthorized, check_access
-import ckan.logic.action.get as get
+from ckan.logic import NotFound, NotAuthorized
+from ckan.logic import check_access, get_action
 
 LIMIT = 25
 
@@ -37,7 +37,7 @@
             data_dict['offset'] = (page-1)*LIMIT
             data_dict['return_objects'] = True
                
-        results = get.tag_list(context,data_dict)
+        results = get_action('tag_list')(context,data_dict)
          
         if c.q:
             c.page = h.Page(
@@ -64,7 +64,7 @@
         
         data_dict = {'id':id}
         try:
-            c.tag = get.tag_show(context,data_dict)
+            c.tag = get_action('tag_show')(context,data_dict)
         except NotFound:
             abort(404, _('Tag not found'))
 


--- a/ckan/controllers/user.py	Fri Aug 12 17:32:01 2011 +0100
+++ b/ckan/controllers/user.py	Fri Aug 12 18:24:35 2011 +0100
@@ -8,14 +8,11 @@
 from ckan.lib import mailer
 from ckan.authz import Authorizer
 from ckan.lib.navl.dictization_functions import DataError, unflatten
-from ckan.logic import NotFound, NotAuthorized, ValidationError, check_access
+from ckan.logic import NotFound, NotAuthorized, ValidationError
+from ckan.logic import check_access, get_action
 from ckan.logic import tuplize_dict, clean_dict, parse_params
 from ckan.logic.schema import user_new_form_schema, user_edit_form_schema 
 
-import ckan.logic.action.get as get
-import ckan.logic.action.create as create
-import ckan.logic.action.update as update
-
 log = logging.getLogger(__name__)
 
 def login_form():
@@ -72,7 +69,7 @@
         except NotAuthorized:
             abort(401, _('Not authorized to see this page'))
 
-        users_list = get.user_list(context,data_dict)
+        users_list = get_action('user_list')(context,data_dict)
 
         c.page = h.Page(
             collection=users_list,
@@ -96,7 +93,7 @@
             abort(401, _('Not authorized to see this page'))
 
         try:
-            user_dict = get.user_show(context,data_dict)
+            user_dict = get_action('user_show')(context,data_dict)
         except NotFound:
             h.redirect_to(controller='user', action='login', id=None)
 
@@ -143,7 +140,7 @@
             data_dict = clean_dict(unflatten(
                 tuplize_dict(parse_params(request.params))))
             context['message'] = data_dict.get('log_message', '')
-            user = create.user_create(context, data_dict)
+            user = get_action('user_create')(context, data_dict)
             h.redirect_to(controller='user', action='read', id=user['name'])
         except NotAuthorized:
             abort(401, _('Unauthorized to create user %s') % '')
@@ -174,7 +171,7 @@
             return self._save_edit(id, context)
 
         try:
-            old_data = get.user_show(context, data_dict)
+            old_data = get_action('user_show')(context, data_dict)
 
             schema = self._db_to_edit_form_schema()
             if schema:
@@ -210,7 +207,7 @@
                 tuplize_dict(parse_params(request.params))))
             context['message'] = data_dict.get('log_message', '')
             data_dict['id'] = id
-            user = update.user_update(context, data_dict)
+            user = get_action('user_update')(context, data_dict)
 
             if context['preview']:
                 about = request.params.getone('about')
@@ -246,7 +243,7 @@
 
             data_dict = {'id':c.user}
 
-            user_dict = get.user_show(context,data_dict)
+            user_dict = get_action('user_show')(context,data_dict)
 
             response.set_cookie("ckan_user", user_dict['name'])
             response.set_cookie("ckan_display_name", user_dict['display_name'])
@@ -274,7 +271,7 @@
             data_dict = {'id':id}
             user_obj = None
             try:
-                user_dict = get.user_show(context,data_dict)
+                user_dict = get_action('user_show')(context,data_dict)
                 user_obj = context['user_obj']
             except NotFound:
                 # Try searching the user
@@ -282,13 +279,13 @@
                 data_dict['q'] = id
 
                 if id and len(id) > 2:
-                    user_list = get.user_list(context,data_dict)
+                    user_list = get_action('user_list')(context,data_dict)
                     if len(user_list) == 1:
                         # This is ugly, but we need the user object for the mailer,
                         # and user_list does not return them
                         del data_dict['q']
                         data_dict['id'] = user_list[0]['id']
-                        user_dict = get.user_show(context,data_dict)
+                        user_dict = get_action('user_show')(context,data_dict)
                         user_obj = context['user_obj']
                     elif len(user_list) > 1:
                         h.flash_error(_('"%s" matched several users') % (id))
@@ -313,7 +310,7 @@
         data_dict = {'id':id}
 
         try:
-            user_dict = get.user_show(context,data_dict)
+            user_dict = get_action('user_show')(context,data_dict)
             user_obj = context['user_obj']
         except NotFound, e:
             abort(404, _('User not found'))
@@ -329,7 +326,7 @@
                 new_password = self._get_form_password()
                 user_dict['password'] = new_password
                 user_dict['reset_key'] = c.reset_key
-                user = update.user_update(context, user_dict)
+                user = get_action('user_update')(context, user_dict)
 
                 h.flash_success(_("Your password has been reset."))
                 redirect('/')


--- a/ckan/logic/__init__.py	Fri Aug 12 17:32:01 2011 +0100
+++ b/ckan/logic/__init__.py	Fri Aug 12 18:24:35 2011 +0100
@@ -145,7 +145,7 @@
     # Rather than writing them out in full will use __import__
     # to load anything from ckan.logic.action that looks like it might
     # be an action 
-    for action_module_name in ['get', 'create', 'update']:
+    for action_module_name in ['get', 'create', 'update','delete']:
         module_path = 'ckan.logic.action.'+action_module_name
         module = __import__(module_path)
         for part in module_path.split('.')[1:]:

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