[Zope-dev] DTML Syntax contd. + rant + summary
Stuart 'Zen' Bishop
zen@cs.rmit.edu.au
Fri, 12 Nov 1999 16:18:54 +1100 (EST)
This message is in MIME format. The first part should be readable text,
while the remaining parts are likely unreadable without MIME-aware tools.
Send mail to mime@docserver.cac.washington.edu for more info.
---559023410-748104835-942383934=:10674
Content-Type: TEXT/PLAIN; charset=US-ASCII
On Thu, 11 Nov 1999, Christopher Petrilli wrote:
> On 11/11/99 5:35 PM, Stuart 'Zen' Bishop at zen@cs.rmit.edu.au wrote:
>
> > Magic sequence- variables need to have aliases of sequence_ (everyone
> > rabidly agrees on this) Strangely enough no one has owned up to
> > actually implementing the '-' variables, most likely as they are
> > afraid of being lynched.
>
> I looked at this today, it's not going into 2.1 most likely, it's a LOT of
> work to make sure it works, *and* doesn't have any negative performance
> impact. Since it will by its nature, I'll need to balance that with a
> performance enhancement somewhere :-)
Is this any good as a temporary fix?
*** DT_InSV.py.org Fri Nov 12 15:26:50 1999
--- DT_InSV.py Fri Nov 12 16:06:51 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,122 ----
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 __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
--- 126,137 ----
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
---559023410-748104835-942383934=:10674
Content-Type: TEXT/PLAIN; charset=US-ASCII; name="DT_InSV.py"
Content-Transfer-Encoding: BASE64
Content-ID: <Pine.SOL.4.10.9911121618540.10674@goanna.cs.rmit.edu.au>
Content-Description:
Content-Disposition: attachment; filename="DT_InSV.py"
KioqIERUX0luU1YucHkub3JnCUZyaSBOb3YgMTIgMTU6MjY6NTAgMTk5OQ0K
LS0tIERUX0luU1YucHkJRnJpIE5vdiAxMiAxNjowNjo1MSAxOTk5DQoqKioq
KioqKioqKioqKioNCioqKiA4OCw5NCAqKioqDQogICRJZDogRFRfSW5TVi5w
eSx2IDEuMTYgMTk5OS8xMS8wMiAxNjo1MTozMiBicmlhbiBFeHAgJCcnJw0K
ICBfX3ZlcnNpb25fXz0nJFJldmlzaW9uOiAxLjE2ICQnWzExOi0yXQ0KICAN
CiEgZnJvbSBzdHJpbmcgaW1wb3J0IGxvd2VyLCByZmluZCwgc3BsaXQsIGpv
aW4NCiAgZnJvbSBtYXRoIGltcG9ydCBzcXJ0DQogIFR1cGxlVHlwZT10eXBl
KCgpKQ0KICB0cnk6DQotLS0gODgsOTUgLS0tLQ0KICAkSWQ6IERUX0luU1Yu
cHksd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GYu
ZGF0YT1kYXRhPXNlcXVlbmNlX2t3ZGljdCh7DQogICAgICAgICAgICAgICdw
cmV2aW91cy1zZXF1ZW5jZSc6IDAsDQogICAgICAgICAgICAgICduZXh0LXNl
cXVlbmNlJzogMCwNCiAgICAgICAgICAgICAgJ3NlcXVlbmNlLXN0YXJ0Jzog
MSwNCiAgICAgICAgICAgICAgJ3NlcXVlbmNlLWVuZCc6IDAsDQohICAgICAg
ICAgICAgIH0pDQogIA0KICANCiAgICAgIGRlZiBudW1iZXIoc2VsZixpbmRl
eCk6IHJldHVybiBpbmRleCsxDQo=
---559023410-748104835-942383934=:10674--