[Zope] Updating auto incrementing counter in a propertysheet

Andy McKay andym@ActiveState.com
Mon, 23 Oct 2000 09:00:43 -0700


[..]
> When I try to get the property directly via the browser i get a result of
> "1" The default value for lastID=0 to begin with so this sounds plausible,
> but when I refresh the browser nothing happens. So I guess that lastID
isn't
> updated in the above code.

I think this is a class - object problem. Each time you create an object
based on your ZClass, the lastID becomes 0. Each object has its own lastID,
rather than what you are expecting which is one instance of last id.

My advice... download and install FSCounter from Zope.org
(http://www.zope.org/Members/andym/FSCounter)

Add an FSCounter, call it "Unique" and turn Cookie? to OFF (very important).
This will generate and keep track of an incrementing value on the file
system

Then in your constructor add / change:

<dtml-let u=Unique>
<dtml-call "REQUEST.set('unique', u)">
</dtml-let>

<dtml-with "mxm_comment.createInObjectManager(_.str(REQUEST['unique']),
REQUEST)">

That should work like a charm.