[ckan-changes] commit/ckanextiati: amercader: Update package serialization patch (again)

Bitbucket commits-noreply at bitbucket.org
Mon Sep 19 15:37:47 UTC 2011


1 new changeset in ckanextiati:

http://bitbucket.org/okfn/ckanextiati/changeset/b8153a614306/
changeset:   b8153a614306
user:        amercader
date:        2011-09-19 17:37:36
summary:     Update package serialization patch (again)
affected #:  1 file (-1 bytes)

--- a/ckanext/iati/patch.py	Mon Sep 19 15:32:53 2011 +0100
+++ b/ckanext/iati/patch.py	Mon Sep 19 16:37:36 2011 +0100
@@ -4,6 +4,7 @@
 import ckan.lib.helpers as h
 import ckan.authz as authz
 from ckan.lib.base import *
+from ckan.model import Package
 
 from ckanext.iati.controllers.group_schema import fields
 
@@ -11,11 +12,20 @@
 
 ######### 
 log.warn("Monkey-patching package serialization format!")
+
+old = Package.as_dict
+def as_dict_with_groups_types(self):
+    _dict = old(self)
+    _dict['groups_types'] = "".join([g.extras.get('type', '') for g in self.groups])
+    return _dict
+
+Package.as_dict = as_dict_with_groups_types
+
 from ckan.lib.dictization import model_dictize
 
-old2 = model_dictize.package_dictize
+old = model_dictize.package_dictize
 def package_dictize_with_group_types(pkg,context):
-    _dict = old2(pkg,context)
+    _dict = old(pkg,context)
     _dict['groups_types'] = "".join([g.extras.get('type', '') for g in pkg.groups])
     return _dict

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

--

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