[Zope-dev] Confused about catalog unique ID in ZScheduler

Michel Pelletier michel@digicool.com
Mon, 06 Mar 2000 13:03:01 -0800


Loren Stafford wrote:
> 
> Two questions really:
> 
> 1. How do I get the uid from the catalog in a python product. Currently I
> have
> 
>     for event in self._catalog.searchResults(
>             nextEventTime=DateTime(1),
>             nextEventTime_usage='range:min',
>             sort_on='nextEventTime'
>             ):
>       next_url = event.absolute_url
>       next_time = event.nextEventTime
>       #next_uid = event.uid
>       break  # just look at the first one
>     return (next_uid, next_time, next_url)
> 
> ...but that event.uid line isn't correct.

Well, brain objects do not have a uid attribute (unless you have an
metadata table entry called uid, which you might...).

The 'unique id' that the catalog uses can be accessed with a two step
process.  First, the integer record 'id' of the catalog result can be
gotten from 'data_record_id_' (this is a name holdover from ZTables). 
Using this integer, you can access the 'unique id' that the catalog uses
for the object.  This is by convention the path to the object.

self._catalog.getpath(event.data_record_id_)

> 
> 2. I need to add to ZScheduler the ability to delete a catalog entry if the
> Dispatcher gets an error when it tries to disarm an event. Is uid what I
> need in ZScheduler to subsequently do this?
> 
>       self.uncatalog_object(uid)

If self is a catalog, yes.

-Michel