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

Bitbucket commits-noreply at bitbucket.org
Wed Sep 14 11:16:21 UTC 2011


4 new changesets in ckan:

http://bitbucket.org/okfn/ckan/changeset/0736786f6e31/
changeset:   0736786f6e31
user:        amercader
date:        2011-09-14 12:53:12
summary:     [forms] #1333 Move form converters to ckan core
affected #:  1 file (934 bytes)

--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ckan/logic/converters.py	Wed Sep 14 11:53:12 2011 +0100
@@ -0,0 +1,35 @@
+from ckan.lib.navl.dictization_functions import Invalid
+from ckan.lib.field_types import DateType, DateConvertError
+
+
+
+def convert_to_extras(key, data, errors, context):
+
+    extras = data.get(('extras',), [])
+    if not extras:
+        data[('extras',)] = extras
+
+    extras.append({'key': key[-1], 'value': data[key]})
+
+def convert_from_extras(key, data, errors, context):
+
+    for data_key, data_value in data.iteritems():
+        if (data_key[0] == 'extras'
+            and data_key[-1] == 'key'
+            and data_value == key[-1]):
+            data[key] = data[('extras', data_key[1], 'value')]
+
+def date_to_db(value, context):
+    try:
+        value = DateType.form_to_db(value)
+    except DateConvertError, e:
+        raise Invalid(str(e))
+    return value
+
+def date_to_form(value, context):
+    try:
+        value = DateType.db_to_form(value)
+    except DateConvertError, e:
+        raise Invalid(str(e))
+    return value
+


http://bitbucket.org/okfn/ckan/changeset/b01de680bf86/
changeset:   b01de680bf86
user:        amercader
date:        2011-09-14 12:55:08
summary:     [model, dictization] Fix for #1334 (Exception when logging in)
affected #:  1 file (14 bytes)

--- a/ckan/model/__init__.py	Wed Sep 14 11:53:12 2011 +0100
+++ b/ckan/model/__init__.py	Wed Sep 14 11:55:08 2011 +0100
@@ -314,10 +314,10 @@
         ))
     if include_packages:
         revision_dict['packages'] = [getattr(pkg, ref_package_by) \
-                                     for pkg in revision.packages]
+                                     for pkg in revision.packages if pkg]
     if include_groups:
         revision_dict['groups'] = [getattr(grp, ref_package_by) \
-                                     for grp in revision.groups]
+                                     for grp in revision.groups if grp]
        
     return revision_dict
 


http://bitbucket.org/okfn/ckan/changeset/b1d9a4fcfcd9/
changeset:   b1d9a4fcfcd9
user:        amercader
date:        2011-09-14 12:57:26
summary:     [dictization] Fix for #1337 (Group extras are JSON encoded in the REST API response)
affected #:  1 file (24 bytes)

--- a/ckan/lib/dictization/model_dictize.py	Wed Sep 14 11:55:08 2011 +0100
+++ b/ckan/lib/dictization/model_dictize.py	Wed Sep 14 11:57:26 2011 +0100
@@ -196,7 +196,7 @@
 def group_to_api1(group, context):
     
     dictized = group_dictize(group, context)
-    dictized["extras"] = dict((extra["key"], extra["value"]) 
+    dictized["extras"] = dict((extra["key"], json.loads(extra["value"])) 
                               for extra in dictized["extras"])
     dictized["packages"] = sorted([package["name"] for package in dictized["packages"]])
     return dictized
@@ -204,7 +204,7 @@
 def group_to_api2(group, context):
     
     dictized = group_dictize(group, context)
-    dictized["extras"] = dict((extra["key"], extra["value"]) 
+    dictized["extras"] = dict((extra["key"], json.loads(extra["value"])) 
                               for extra in dictized["extras"])
     dictized["packages"] = sorted([package["id"] for package in dictized["packages"]])
     return dictized


http://bitbucket.org/okfn/ckan/changeset/136c04d9f149/
changeset:   136c04d9f149
user:        amercader
date:        2011-09-14 13:00:18
summary:     [forms] Fix for #1338 (Exception when trying to use a custom form schema from an extension)
affected #:  3 files (50 bytes)

--- a/ckan/controllers/group.py	Wed Sep 14 11:57:26 2011 +0100
+++ b/ckan/controllers/group.py	Wed Sep 14 12:00:18 2011 +0100
@@ -137,7 +137,7 @@
             c.groupname = old_data.get('name')
             schema = self._db_to_form_schema()
             if schema:
-                old_data, errors = validate(old_data, schema)
+                old_data, errors = validate(old_data, schema, context=context)
 
             data = data or old_data
 


--- a/ckan/controllers/package.py	Wed Sep 14 11:57:26 2011 +0100
+++ b/ckan/controllers/package.py	Wed Sep 14 12:00:18 2011 +0100
@@ -371,7 +371,7 @@
             old_data = get_action('package_show')(context, {'id':id})
             schema = self._db_to_form_schema()
             if schema:
-                old_data, errors = validate(old_data, schema)
+                old_data, errors = validate(old_data, schema, context=context)
             data = data or old_data
         except NotAuthorized:
             abort(401, _('Unauthorized to read package %s') % '')


--- a/ckan/logic/schema.py	Wed Sep 14 11:57:26 2011 +0100
+++ b/ckan/logic/schema.py	Wed Sep 14 12:00:18 2011 +0100
@@ -137,7 +137,7 @@
 
     schema = default_package_schema()
     ##new
-    schema['log_message'] = [unicode, no_http]
+    schema['log_message'] = [ignore_missing, unicode, no_http]
     schema['groups'] = {
             'id': [ignore_missing, unicode],
             '__extras': [empty],

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