[Zope-dev] ZODB, Catalog and actually using it

Nicholas Henke henken@unholymess.com
Wed, 29 May 2002 16:05:38 -0400


Hello~~
=09I am playing with using the Catalog class in ZCatalog along with Catal=
ogQuery=20
to create a generic object layer on top of ZODB. I can index and search t=
il I=20
am blue in the face, and I always get the correct answers. Now for the=20
problems...

Say I have the following obj:
class test(Persistent):
=09variable =3D 1
=09def function(self):
=09=09print self.__dict__

now if I do:
catalog =3D Catalog()
catalog.addIndex('variable', Fieldindex('variable'))
catalog.addColumn('variable')
obj =3D test()
catalog.catalogObject(obj, id(obj))

catalog_query =3D CatalogQuery(catalog, "variable=3D=3D1")
results =3D catalog_query()
for r in results:
=09print r.variable  # ok
=09print r.getRID() # ok
=09print r.function # NameError

=2E..so I can get an object (a mybrains instance )back that allows me to =
print=20
r.variable, but I cannot get r.function().=20
How does one do this? Is there a mapping between RIDs in the catalog and =
real=20
objects somewhere? Do I need to do that mapping in an IOBtree (it would m=
ake=20
the most sense since I am using id(obj) as the uid in the catalog)? Is th=
ere=20
somewhere in Zope/google/web that does this?

Thanks for any help!!
Nic=20