RE: [Zope] NEWBIE: assign next free ID automatically
This is untested, but an idea: <dtml-in "objectValues()[:-1]" sort=id reverse> <dtml-call "REQUEST.set('new_id', id+1)"> <dtml-var new_id> It is still subject to failure if 2 or more processes are writing an article in the same time. Furthermore it has to find and sort all the items in the folder. That could take a long time if there are lots of them. Maybe you should somehow insert a dtml-try until you succed in writing the article. Another aproach would be to have the folder with your articles have a property "lastID" and let "nexID" be a method that automatically would increment lastID end return it. Maybe it is possible to lock the lastID property??
From: Patrick Koetter [mailto:p@state-of-mind.de]
What is it that I want to do? I want to evaluate the highest ID (all are 'int') within the folder and assign the next highest. I'm sure this is easy to you...
participants (1)
-
Max Møller Rasmussen