Hello, After some deep searches about the subject, I found that zope has no real unique ID's. For a particular application (where we can't use the object "url" as an ID as ojects will move), I'd like to assign a unique_id property to each object whenever they are added (the ID must be really really unique). Is there already a patch that do that ? Is there a reason why zope doesn't provide this facility? Thanks in advance, Philippe
You could use the 'thread safe counter' product, it's part of ZopeGUD, used for a similar purpose in there.
From: Philippe Jadin <philippe@123piano.com> Date: Wed, 31 Oct 2001 10:08:10 +0100 To: zope <zope@zope.org> Subject: [Zope] Unique ID's ?
Hello,
After some deep searches about the subject, I found that zope has no real unique ID's.
For a particular application (where we can't use the object "url" as an ID as ojects will move), I'd like to assign a unique_id property to each object whenever they are added (the ID must be really really unique).
Is there already a patch that do that ? Is there a reason why zope doesn't provide this facility?
Thanks in advance,
Philippe
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
I had this problem recently and I solved it (sort of) this way: I wrote a method that created a unique id I called CID from the time+userIP+random number and then made that a property of the object each time an instance was created. Then I wrote some methods to walk the tree and return a dictionary of CID:ID pairs so I could easily translate them back. This then lead to some interesting trouble - if I copy an item do I want this id to be copied or reset to a new value? I am presently trying to modify the copy/paste methods so that it resets the id after a copy. Hope to have that solved soon. Tom => -----Original Message----- => From: zope-admin@zope.org [mailto:zope-admin@zope.org]On Behalf Of marc => lindahl => Sent: Thursday, 1 November 2001 3:20 AM => To: Philippe Jadin; zope => Subject: Re: [Zope] Unique ID's ? => => => You could use the 'thread safe counter' product, it's part of => ZopeGUD, used => for a similar purpose in there. => => > From: Philippe Jadin <philippe@123piano.com> => > Date: Wed, 31 Oct 2001 10:08:10 +0100 => > To: zope <zope@zope.org> => > Subject: [Zope] Unique ID's ? => > => > Hello, => > => > After some deep searches about the subject, I found that zope has no => > real unique ID's. => > => > For a particular application (where we can't use the object "url" as an => > ID as ojects will move), I'd like to assign a unique_id => property to each => > object whenever they are added (the ID must be really really unique). => > => > Is there already a patch that do that ? Is there a reason why zope => > doesn't provide this facility? => > => > Thanks in advance, => > => > Philippe => > => > _______________________________________________ => > Zope maillist - Zope@zope.org => > http://lists.zope.org/mailman/listinfo/zope => > ** No cross posts or HTML encoding! ** => > (Related lists - => > http://lists.zope.org/mailman/listinfo/zope-announce => > http://lists.zope.org/mailman/listinfo/zope-dev ) => => => _______________________________________________ => Zope maillist - Zope@zope.org => http://lists.zope.org/mailman/listinfo/zope => ** No cross posts or HTML encoding! ** => (Related lists - => http://lists.zope.org/mailman/listinfo/zope-announce => http://lists.zope.org/mailman/listinfo/zope-dev ) =>
Tom Cameron wrote:
I had this problem recently and I solved it (sort of) this way:
I wrote a method that created a unique id I called CID from the time+userIP+random number and then made that a property of the object each time an instance was created.
Was it automagically called as a zope hotpatch ? I mean, was it a patch to zope simple item or so ? That's what I 'd like to do : give a unique ID to any zope object without having to worry about calling a special method manually. Do you think it is possible to patch zope in a way to have this behavior? How did you built your system? IS it available somewhere ?
Then I wrote some methods to walk the tree and return a dictionary of CID:ID pairs so I could easily translate them back.
Yep, we may need that also.
This then lead to some interesting trouble - if I copy an item do I want this id to be copied or reset to a new value? I am presently trying to modify the copy/paste methods so that it resets the id after a copy. Hope to have that solved soon.
In our case, we absolutelly don't want to loose the item ID, even if it's moved. If needed we could update the dictionary. The goal here is to keep an id wherever goes the object. Thanks in advance for your tips ! Philippe
On Wed, 31 Oct 2001 10:08:10 +0100, Philippe Jadin <philippe@123piano.com> wrote:
Hello,
After some deep searches about the subject, I found that zope has no real unique ID's.
For a particular application (where we can't use the object "url" as an ID as ojects will move), I'd like to assign a unique_id property to each object whenever they are added (the ID must be really really unique).
Is there already a patch that do that ? Is there a reason why zope doesn't provide this facility?
ZODB provides unique ids for all persisted objects, in the attribute _p_oid. They are unique within a storage, but beware you may get duplicates if you have mounted databases. Also, _p_oid will change if an object is copy/pasted or export/imported. This may, or may not be what you want. Toby Dickenson tdickenson@geminidataloggers.com
participants (4)
-
marc lindahl -
Philippe Jadin -
Toby Dickenson -
Tom Cameron