[Zope] Where to store global Property - Incremental ID / Counter

AdvertisingDept Layne.Bilyeu@robbstucky.net
Wed, 11 Sep 2002 11:30:34 -0400


Newbie looking for sage wisdom on Creating Sequentially Id'ed objects.


I have a ZClass, instances of which will be created in a single Folder, 
not throughout the ZopeObject heirarchy. When creating a new instance, I 
would like to assign the id in sequential fashion, similar to 
take-a-number queing at the Deli counter.
   . . . now serving number 1023

I see two ways of doing this:
a) have the add method query the folder and find the highest numbered id 
ZclassIntanceObject, add one to that value and make that the id of the 
next ZClass instance.

b) Create a 'global' property - lastnumberused. Have the add method query 
this property and ...


Which is the better method via Zope?

a) which requires calculations max( container.objectItems() ) - 
considering there may be thousands of Zclass instances in this folder.

b) a property 
   where to put it - on the container of the instances, or on the parent 
ZClass?
   garbage collection - (I've heard something about zope creating but not 
disposing of instances each time a property is updated - a la FScounter - 
but have no background to discern if this problem applies to my situation)

Suggestions?