[ZODB-Dev] Re: [Zope-dev] ZODB, Catalog and actually using it
Nicholas Henke
henken@unholymess.com
Wed, 29 May 2002 16:30:02 -0400
On Wednesday 29 May 2002 04:20 pm, Casey Duncan wrote:
> try:
>
> ob =3D r.getObject()
> ob.function()
ob gets returned as None -- I think this is due to=20
AbstractCatalogBrain::getObject(). I don't believe self.aq_parent is set=20
correctly -- how is it supposed to be set ?
>
> or if that doesn't work:
>
> ob =3D catalog.getobject(r.data_record_id_)
AttributeError -- getobject doesnt exist?
> ob.function()
>
> Bear in mind that getObject traverses to the object which is expensive =
both
> in time and memory if the number of results is large.
OK -- is there a better way to do all of this ? What I am trying to do i=
s=20
have ZODB store objects and Catalog maintain indexes on them. Now I can c=
ome=20
back and do a 'SELECT' on the objects, say for variable !=3D 1, and someh=
ow get=20
access to the original objects if I wish to. Is there somewhere that=20
documents using Catalog and PluginIndexes without all of the other Zope=20
stuff? Any documents on using it with the Zope stuff ?
Nic
>
> 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
>
> CatalogQuery
>
> > to create a generic object layer on top of ZODB. I can index and sear=
ch
> > til
>
> I
>
> > am blue in the face, and I always get the correct answers. Now for th=
e
> > 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
> >
> > ...so I can get an object (a mybrains instance )back that allows me t=
o
> > print r.variable, but I cannot get r.function().
> > How does one do this? Is there a mapping between RIDs in the catalog =
and
>
> real
>
> > objects somewhere? Do I need to do that mapping in an IOBtree (it wou=
ld
> > make the most sense since I am using id(obj) as the uid in the catalo=
g)?
> > Is there somewhere in Zope/google/web that does this?
> >
> > Thanks for any help!!
> > Nic
> >
> >
> >
> > _______________________________________________
> > 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 )