@core_helper
def convert_to_dict(object_type, objs):
 def dictize_revision_list(revision, context):
  def process_names(items):
   array = []
   for item in items:
    array.append(item.name)
   return array
  rev = {'id': revision.id, 'state': revision.state, 'timestamp': revision.timestamp, 'author': revision.author, 'packages': process_names(revision.packages), 'groups': process_names(revision.groups), 'message': revision.message}
  return rev
 import ckan.lib.dictization.model_dictize as md
 converters = {'package': md.package_dictize, 'revisions': dictize_revision_list}
 converter = converters[object_type]
 items = []
 context = {'model': model}
 for obj in objs:
  item = converter(obj, context)
  items.append(item)
 return items

@ core_helper def convert_to_dict ( object_type , objs ) : def dictize_revision_list ( revision , context ) : def process_names ( items ) : array = [ ] for item in items : array . append ( item . name ) return array rev = { 'id' : revision . id , 'state' : revision . state , 'timestamp' : revision . timestamp , 'author' : revision . author , 'packages' : process_names ( revision . packages ) , 'groups' : process_names ( revision . groups ) , 'message' : revision . message } return rev import ckan . lib . dictization . model_dictize as md converters = { 'package' : md . package_dictize , 'revisions' : dictize_revision_list } converter = converters [ object_type ] items = [ ] context = { 'model' : model } for obj in objs : item = converter ( obj , context ) items . append ( item ) return items
this is a helper function for converting lists of objects into lists of dicts .