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

Andy andy@agmweb.ca
Mon, 14 Jan 2002 22:43:23 -0800


Actually to add this I wrote on new how-to and found an old one:
-    using guid's on Windows: http://www.zope.org/Members/andym/GUID
-    using FSCounter: http://www.zope.org/Members/andym/FSCounter/unique_ids

HTH.

----- Original Message -----
From: "Andy" <andy@agmweb.ca>
To: "Joe Block" <jpb@ApesSeekingKnowledge.net>; "Zope List" <zope@zope.org>
Sent: Monday, January 14, 2002 10:09 PM
Subject: Re: [Zope] q: How should I get a guaranteed unique id in Zope?


> Along with all the other suggestion the FSCounter product is a counter in
> the file system. I use this to happily generate incrementing values.
>
> ----- 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.
> >
> >
> > _______________________________________________
> > 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 )
>