[ckan-dev] Getting organization name via organzation_show

Koebrick, Andrew (MNIT) andrew.koebrick at state.mn.us
Wed Dec 2 15:59:34 UTC 2015


I am hoping somebody can assist with some code that is confusing me.  I am attempting to get the organization name via get_action('organization_show') but am only getting errors.  Below is the code from my current extension.  I marked the bad area with the comment "Problematic section".  I have tried all sorts of syntax to get the organization object, but keep getting server errors like:

[Wed Dec 02 09:47:39 2015] [error] /usr/lib/ckan/ng911/lib/python2.6/site-packages/sqlalchemy/orm/unitofwork.py:79: SAWarning: Usage of the 'related attribute set' operation is not currently supported within the execution stage of the flush process. Results may not be consistent.  Consider using alternative event listeners or connection-level operations instead.
[Wed Dec 02 09:47:39 2015] [error]   sess._flush_warning("related attribute set")

In my code I am trying to use the same type of formation with organization_show as I do with package_show (which does work).  But no luck.

Many thanks if anyone can help with this.  I am beating my head against a wall here.

Andrew

##############################
# Code snippet
##############################

    def _create_ng911_task(self, resource):
        user = get_action('get_site_user')({'model': model,
                                            'ignore_auth': True,
                                            'defer_commit': True}, {})
        resource_obj = resource_dictize(resource, {'model': model})

        #Below line sets up the whole package as a json object; it works
        packageJson = json.dumps(get_action('package_show')(None, {'id':  resource_obj['package_id']}))

        organization_guid = resource_obj['organization']


      # Problematic section
       # organization_dict = get_action('organization_show', {'id': organization_guid})
       data2 = json.dumps(get_action('organization_show')(None, {'id': organization_guid}))
       # data2 = json.dumps(get_action('organization_show', {'id': organization_guid}))


        data = {}
        data['organization_guid'] =  resource_obj[organization_guid]
        data['packageId'] =  resource_obj['package_id']
        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)

Andrew Koebrick  |  MINNESOTA GEOSPATIAL INFORMATION OFFICE
Web Coordinator / Systems administrator / Librarian
MN.IT Services @ MNGEO
651-201-2465 (w)  |   651-296-6398 (f) |  andrew.koebrick at state.mn.us<mailto:andrew.koebrick at state.mn.us>
658 Cedar St., Room 300, St. Paul, MN 55155, www.mngeo.state.mn.us<http://www.mngeo.state.mn.us/>

[cid:image002.jpg at 01CE61F8.52552AE0]<http://www.mn.gov/oet>

Information Technology for Minnesota Government   |   mn.gov/mnit<http://www.mn.gov/oet>



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.okfn.org/pipermail/ckan-dev/attachments/20151202/02839a75/attachment-0002.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.jpg
Type: image/jpeg
Size: 1624 bytes
Desc: image001.jpg
URL: <http://lists.okfn.org/pipermail/ckan-dev/attachments/20151202/02839a75/attachment-0002.jpg>


More information about the ckan-dev mailing list