[Zope] getting at ZCatalog data object in Python
J. Cameron Cooper
jccooper at jcameroncooper.com
Mon Nov 17 19:59:13 EST 2003
Tom P. Allred wrote:
>Here is my modified (working) script based on your suggestion:
>for x in context.Catalog(datatype='client',id='12346'):
> drec = x.getObject()
>return drec
>
>Just out of curiosity, can you tell me why the following doesn't work
>(Script Error: LazyMap instance has no attribute 'getObject') since only one
>catalog item is the result of the query?
>
>zcat = context.Catalog(datatype='client',id='12346')
>drec = zcat.getObject()
>return drec
>
>
A list with one item is still a list. You call 'getObject' on a catalog
result list, which knows of no such method.
If you know it to have only one result, you may say
zcat = context.Catalog(datatype='client',id='12346')
drec = zcat[0].getObject()
return drec
--jcc
--
"My point and period will be throughly wrought,
Or well or ill, as this day's battle's fought."
More information about the Zope
mailing list