On Fri, 12 Nov 1999, Stuart 'Zen' Bishop wrote:
Is this any good as a temporary fix?
Grr... just found an obvious flaw. Lets try take 2 at embarassing myself. *** DT_InSV.py.org Fri Nov 12 15:26:50 1999 --- DT_InSV.py Fri Nov 12 16:29:56 1999 *************** *** 88,94 **** $Id: DT_InSV.py,v 1.16 1999/11/02 16:51:32 brian Exp $''' __version__='$Revision: 1.16 $'[11:-2] ! from string import lower, rfind, split, join from math import sqrt TupleType=type(()) try: --- 88,95 ---- $Id: DT_InSV.py,v 1.16 1999/11/02 16:51:32 brian Exp $''' __version__='$Revision: 1.16 $'[11:-2] ! from UserDict import UserDict ! from string import lower, rfind, split, join, replace from math import sqrt TupleType=type(()) try: *************** *** 96,101 **** --- 97,127 ---- mv=Missing.Value except: mv=None + def _transkey(key): + if key[:13] == 'sequence-var-': + # Only translate the first 2 '-' characters in a sequence-var- + return replace(key,'-','_',2) + else: + return replace(key,'-','_') + + class sequence_kwdict(UserDict): + '''This class is used to implement the dictionary in sequence_variables + It duplicates keys containing '-' characters to a corresponding entry + with a key mapping all the first two '-' characters to '_' characters. + This will greatly improve DTML readability.''' + + def __init__(self,data): + self.data = data + for i in data.items(): + data[_transkey(i[0])] = i[1] + + def __setitem__(self,key,value): + self.data[key] = value + self.data[_transkey(key)] = value + + def __delitem__(self,key,value): + del self.data[key] + del self.data[_transkey(key)] class sequence_variables: *************** *** 105,116 **** self.query_string=query_string self.start_name_re=start_name_re ! self.data=data={ 'previous-sequence': 0, 'next-sequence': 0, 'sequence-start': 1, 'sequence-end': 0, ! } def number(self,index): return index+1 --- 131,142 ---- self.query_string=query_string self.start_name_re=start_name_re ! self.data=data=sequence_kwdict({ 'previous-sequence': 0, 'next-sequence': 0, 'sequence-start': 1, 'sequence-end': 0, ! }) def number(self,index): return index+1 ___ // Zen (alias Stuart Bishop) Work: zen@cs.rmit.edu.au // E N Senior Systems Alchemist Play: zen@shangri-la.dropbear.id.au //__ Computer Science, RMIT WWW: http://www.cs.rmit.edu.au/~zen