[Zope] getting at ZCatalog data object in Python

Tom P. Allred tom at allreddata.com
Sun Nov 16 17:06:56 EST 2003


I'd like to return the data object a ZCatalog entry points to so a ZPT can
display the data.  Currently I'm doing it in a 2-step process where a Python
script finds/returns the catalog entry and the ZPT uses getObject to define
a variable to get at the actual data.  What I want to do is have the Python
script find the catalog entry then return the actual data object to the ZPT.

CatalogClientTest Script excerpt:
# normally uses variables instead of hard-coded values
zcat = context.Catalog(datatype='client',id='12346')
return zcat

ZPT excerpt:
<body tal:define="results container/CatalogClientTest">
...
<div tal:define="cdata result/getObject">
...
<span tal:replace="cdata/cl_lastname">client lastname</span>

I can get at the data object in the Python script if I hardcode the
data_record_id:
clientrec = context.Catalog.getobject(833051159)
return clientrec

but I can't figure out how to get from zcat to clientrec programmatically.
Any advice?

Thanks,
Tom P. Allred
Tom at AllredData.com





More information about the Zope mailing list