[ZODB-Dev] Re: [Zope-dev] ZODB, Catalog and actually using it
Casey Duncan
casey@zope.com
Wed, 29 May 2002 16:20:44 -0400
try:
ob =3D r.getObject()
ob.function()
or if that doesn't work:
ob =3D catalog.getobject(r.data_record_id_)
ob.function()
Bear in mind that getObject traverses to the object which is expensive bo=
th in=20
time and memory if the number of results is large.
hth,
-Casey
On Wednesday 29 May 2002 04:05 pm, Nicholas Henke wrote:
> Hello~~
> =09I am playing with using the Catalog class in ZCatalog along with=20
CatalogQuery=20
> to create a generic object layer on top of ZODB. I can index and search=
til=20
I=20
> am blue in the face, and I always get the correct answers. Now for the=20
> problems...
>=20
> Say I have the following obj:
> class test(Persistent):
> =09variable =3D 1
> =09def function(self):
> =09=09print self.__dict__
>=20
> now if I do:
> catalog =3D Catalog()
> catalog.addIndex('variable', Fieldindex('variable'))
> catalog.addColumn('variable')
> obj =3D test()
> catalog.catalogObject(obj, id(obj))
>=20
> 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
>=20
> ...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 an=
d=20
real=20
> objects somewhere? Do I need to do that mapping in an IOBtree (it would=
make=20
> the most sense since I am using id(obj) as the uid in the catalog)? Is =
there=20
> somewhere in Zope/google/web that does this?
>=20
> Thanks for any help!!
> Nic=20
>=20
>=20
>=20
> _______________________________________________
> Zope-Dev maillist - Zope-Dev@zope.org
> http://lists.zope.org/mailman/listinfo/zope-dev
> ** No cross posts or HTML encoding! **
> (Related lists -
> http://lists.zope.org/mailman/listinfo/zope-announce
> http://lists.zope.org/mailman/listinfo/zope )
>=20