Skip to content

Commit

Permalink
[#1400] use context, data_dict param order
Browse files Browse the repository at this point in the history
  • Loading branch information
wardi committed Dec 18, 2013
1 parent ca05e99 commit 2939575
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions ckan/lib/plugins.py
Expand Up @@ -170,13 +170,13 @@ def register_group_plugins(map):
_default_group_plugin = DefaultGroupForm()


def plugin_validate(plugin, data_dict, schema, context, action):
def plugin_validate(plugin, context, data_dict, schema, action):
"""
Backwards compatibility with 2.x dataset group and org plugins:
return a default validate method if one has not been provided.
"""
if hasattr(plugin, 'validate'):
return plugin.validate(data_dict, schema, context, action)
return plugin.validate(context, data_dict, schema, action)

return toolkit.navl_validate(data_dict, schema, context)

Expand Down
4 changes: 2 additions & 2 deletions ckan/logic/action/create.py
Expand Up @@ -142,7 +142,7 @@ def package_create(context, data_dict):
package_plugin.check_data_dict(data_dict)

data, errors = lib_plugins.plugin_validate(
package_plugin, data_dict, schema, context, 'package_create')
package_plugin, context, data_dict, schema, 'package_create')
log.debug('package_create validate_errs=%r user=%s package=%s data=%r',
errors, context.get('user'),
data.get('name'), data_dict)
Expand Down Expand Up @@ -519,7 +519,7 @@ def _group_or_org_create(context, data_dict, is_org=False):
group_plugin.check_data_dict(data_dict)

data, errors = lib_plugins.plugin_validate(
group_plugin, data_dict, schema, context,
group_plugin, context, data_dict, schema,
'organization_create' if is_org else 'group_create')
log.debug('group_create validate_errs=%r user=%s group=%s data_dict=%r',
errors, context.get('user'), data_dict.get('name'), data_dict)
Expand Down
4 changes: 2 additions & 2 deletions ckan/logic/action/get.py
Expand Up @@ -863,7 +863,7 @@ def package_show(context, data_dict):
schema = package_plugin.show_package_schema()
if schema and context.get('validate', True):
package_dict, errors = lib_plugins.plugin_validate(
package_plugin, package_dict, schema, context,
package_plugin, context, package_dict, schema,
'package_show')

for item in plugins.PluginImplementations(plugins.IPackageController):
Expand Down Expand Up @@ -1012,7 +1012,7 @@ def _group_or_org_show(context, data_dict, is_org=False):

if schema:
group_dict, errors = lib_plugins.plugin_validate(
group_plugin, group_dict, schema, context,
group_plugin, context, group_dict, schema,
'organization_show' if is_org else 'group_show')
return group_dict

Expand Down
4 changes: 2 additions & 2 deletions ckan/logic/action/update.py
Expand Up @@ -292,7 +292,7 @@ def package_update(context, data_dict):
package_plugin.check_data_dict(data_dict)

data, errors = lib_plugins.plugin_validate(
package_plugin, data_dict, schema, context, 'package_update')
package_plugin, context, data_dict, schema, 'package_update')
log.debug('package_update validate_errs=%r user=%s package=%s data=%r',
errors, context.get('user'),
context.get('package').name if context.get('package') else '',
Expand Down Expand Up @@ -495,7 +495,7 @@ def _group_or_org_update(context, data_dict, is_org=False):
group_plugin.check_data_dict(data_dict)

data, errors = lib_plugins.plugin_validate(
group_plugin, data_dict, schema, context,
group_plugin, context, data_dict, schema,
'organization_update' if is_org else 'group_update')
log.debug('group_update validate_errs=%r user=%s group=%s data_dict=%r',
errors, context.get('user'),
Expand Down
12 changes: 6 additions & 6 deletions ckan/plugins/interfaces.py
Expand Up @@ -824,7 +824,7 @@ def package_form(self):
'''

def validate(self, data_dict, schema, context, action):
def validate(self, context, data_dict, schema, action):
"""Customize validation of datasets.
When this method is implemented it is used to perform all validation
Expand All @@ -839,13 +839,13 @@ def validate(self, data_dict, schema, context, action):
dataset, or if you wish to use a different method for validation, then
this method may be used.
:param context: extra information about the request
:type context: dictionary
:param data_dict: the dataset to be validated
:type data_dict: dictionary
:param schema: a schema, typically from ``show_package_schema()``,
``create_package_schema()`` or ``update_package_schama()``
:type schema: dictionary
:param context: extra information about the request
:type context: dictionary
:param action: ``'package_show'``, ``'package_create'`` or
``'package_update'``
:type action: string
Expand Down Expand Up @@ -975,7 +975,7 @@ def setup_template_variables(self, context, data_dict):
Add variables to c just prior to the template being rendered.
"""

def validate(self, data_dict, schema, context, action):
def validate(self, context, data_dict, schema, action):
"""Customize validation of groups.
When this method is implemented it is used to perform all validation
Expand All @@ -990,13 +990,13 @@ def validate(self, data_dict, schema, context, action):
group, or if you wish to use a different method for validation, then
this method may be used.
:param context: extra information about the request
:type context: dictionary
:param data_dict: the group to be validated
:type data_dict: dictionary
:param schema: a schema, typically from ``form_to_db_schema()``,
or ``db_to_form_schama()``
:type schema: dictionary
:param context: extra information about the request
:type context: dictionary
:param action: ``'group_show'``, ``'group_create'``,
``'group_update'``, ``'organization_show'``,
``'organization_create'`` or ``'organization_update'``
Expand Down

0 comments on commit 2939575

Please sign in to comment.