[ckan-dev] Getting organization name via organzation_show

Koebrick, Andrew (MNIT) andrew.koebrick at state.mn.us
Wed Dec 2 17:19:19 UTC 2015


Solved this myself.  I had been mixing up keys between the resource_obj and package_obj (among other confusions...).  Anyhow, in case any other newbys ever try to do something similar, below is what seems to be a functional code chunk to initiate a RabbitMQ task, using Pika to send a subset of info about a newly uploaded dataset to a queue.

Sorry to clutter the list with what I should have been able to figure out right away.

Andrew

++++++++++++++++++++++++++++++++++
    def _create_ng911_task(self, resource):

        resource_obj = resource_dictize(resource, {'model': model})
        package_obj = get_action('package_show')(None, {'id':  resource_obj['package_id']})
        organization_obj = get_action('organization_show')(None, {'id':  package_obj['owner_org']})

        data = {}
        data['packageId'] =  resource_obj['package_id']
        data['organization_name'] =  organization_obj['name']
        data['organization_guid'] =  package_obj['owner_org']
        data['url'] = resource_obj['url']
        payload = json.dumps(data)

        connection = pika.BlockingConnection(pika.ConnectionParameters(host='localhost'))
        channel = connection.channel()
        channel.queue_declare(queue='NG911-etl')
        channel.basic_publish(exchange='',
                              routing_key='NG911-etl',
                              body=payload)
        connection.close()
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.okfn.org/pipermail/ckan-dev/attachments/20151202/fdfe6089/attachment-0003.html>


More information about the ckan-dev mailing list