[Zope] q: How should I get a guaranteed unique id in Zope?

Troy Farrell troy@entheossoft.com
Mon, 14 Jan 2002 23:36:09 -0600


Mmmm. Good point.  Joe, I'd assumed you were storing the data in a 
python product/class object in the ZODB.  Grand.  Now I'm second 
guessing myself.

Joe, can you clarify your architecture a bit?  What DB?  Are you moving 
the cgi(s) to a python product?  A set of external methods?

Troy
:wq

Todd Graham wrote:

> Hey Joe,
> 
> What database are you using as the backend, does it support sequences?  This
> is probably the best way to ensure referential integrity.
> 
> T
> 
> 
> ----- Original Message -----
> From: Joe Block <jpb@ApesSeekingKnowledge.net>
> To: Zope List <zope@zope.org>
> Sent: Monday, January 14, 2002 6:34 PM
> Subject: [Zope] q: How should I get a guaranteed unique id in Zope?
> 
> 
> 
>>I just discovered Zope a couple of weeks ago, and have started migrating
>>a cgi based web application that I was writing in straight python to
>>Zope both as a learning exercise and to take advantage of Zope's feature
>>set.
>>
>>My problem is, I have several sql tables that I'm storing data in that I
>>need to be able to have the same jobid in because I'm using the jobid to
>>match which comments are attached to which jobs.  When I was using cgis,
>>this was easy - I made a class that wrapped the following function
>>
>>         def makeID(self):
>>                 idstring = "%s-%s.%s-%s" % (self.prefix, os.getpid(),
>>time.time(), self.counter)
>>                 self.counter = self.counter + 1
>>                 return idstring
>>
>>and I could be guaranteed their uniqueness because prefix was the
>>hostname of the server the cgi was running on, and the combination of
>>the other 3 parts was unique per call to makeID.
>>
>>Now that I'm using Zope, the pid isn't unique any more, of course.  I
>>don't want to store a counter in the database, because from some of the
>>postings I saw in the last few days here I think it'll cause my db to
>>grow for no reason as it stores unwanted undo information.  I also
>>haven't figured out how to lock an object while I update properties
>>yet.  I don't want to use an external file either, because the constant
>>locking & unlocking seems likely to cause performance problems
>>eventually.
>>
>>I have both _The Zope Book_ and _Zope Web Application Development and
>>Content Management_ , and haven't found an answer to my problem in
>>either book as yet.
>>
>>I'm running Zope 2.5.0b3 with Python 2.1.1 on Mac OS X 10.1.2
>>
>>Thanks,
>>
>>jpb
>>--
>>Joe Block <jpb@ApesSeekingKnowledge.net>
>>
>>Madness takes its toll. Please have exact change ready.