Tags:
create new tag
, view all tags

Question

I am implementing a job recording system in Twiki that requires users to enter information into a form, which is then used to automatically populate a new topic, the name of which is automatically generated from a sequential ID. Unfortunately, there is the possibility that if two users access the form at the same time to create a new topic, the name of the topic will be the same and the subsequent saving of one version will immediately overwrite the data in the other. I can mitigate this risk to some extent using some javascript and a backend http call to deliver me a topic identifier, but the topic doesn't 'reserve' the number until it is saved and if someone is still editing a topic at this time, there is still a danger that the earlier version can get overwritten.

I really need the ability to "lock" the topic identifer at the point when the page goes into "edit" mode, so that the same ID can't be picked by another user. I understand that this feature is evident when existing topics are being edited, but this doesn't appear to be the case for new topics. I suppose also that a feature that bypasses the "Preview/Save" requirement would also do the trick, but is this possible with BeijingRelease?

Environment

TWiki version: TWikiRelease01Feb2003
TWiki plugins: DefaultPlugin, EmptyPlugin, InterwikiPlugin
Server OS: Redhat 9
Web server: Apache
Perl version:  
Client OS:  
Web Browser:  

-- MarkEdwards - 11 Mar 2004

Answer

Possibly not a good answer but something that gets you further:

With the latest TWikiBetaRelease you can prevent users from creating the same topic name with a onlynewtopic=on URL parameter for the edit script. See FlagForEditScriptToAvoidFormDataOverwrite

Alternatively, use a pseudo random topic name based on the date with a granularity down to the second. The likleyhood of two persons loading the "AddRecord" page within the same second is small. Set a hidden field for the topic name to FooBarID%SERVERTIME{$year$mo$day$hour$min$sec}%, which renders as FooBarID20120527222558.

You also could use a random number, generated by the latest SpreadSheetPlugin.

-- PeterThoeny - 11 Mar 2004

Mark, there are a number of techniques that can help you here.

  1. If you were using the latest beta, you could use the GuidPlugin. This would let you enter a topic name like "UniqueName%GUID_ID%" which would always appear with a question-mark after it.
  2. Alternatively, with earlier releases of TWiki, you could use the autocreate script bundled with the FormQueryPlugin. The FQP supports a %TOPICCREATOR% tag that helps create unique, sequential topic names. You are welcome to rip the code off.
  3. Finally, the luddite solution is to create a topic creation form that incoporates the date and time in a generated topic name, thus (view http://www.twiki.org/cgi-bin/view/Support/DuplicateTopicNames?raw=on to see how I did this):
Create new topic: (default value is today's date and time)

None of the above techniques would actually "lock" the topic, but they would all guarantee unique topic names. I personally use the third technique a lot to generate - for example - meeting minutes pages.

-- CrawfordCurrie - 12 Mar 2004

I can't seem to get the third option to function properly. I would like to be able to create several topics in one web named QueryGuide, not displaying whatever extension it must have to be considered unique. Is this possible?

-- PalWerdenhoff

See MeetingMinutes for an example with date based topic names.

A topic name is the unique identifier in a web, so there can be only one topic called QueryGuide.

The latest TWikiRelease04x00x00 supports a TopicNameXXXXXXXXXX feature on topic creation, where 10 or more X'es get replaced by a serial number.

-- PeterThoeny - 15 Feb 2006

Topic revision: r6 - 2006-02-15 - PeterThoeny
 
Twitter Delicious Facebook Digg Google Bookmarks E-mail LinkedIn Reddit StumbleUpon    
  • Download TWiki
TWiki logo Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2012 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.