You are not logged in Log in Join
You are here: Home » Members » Jfarr's Zope Page » Patches » dtml-break-2.1.6-patch.diff

Log in
Name

Password

 

dtml-break-2.1.6-patch.diff

File details
Size
2 K
File type
text/plain

File contents

--- DT_In.py.orig	Fri Aug 27 07:56:28 1999
+++ DT_In.py	Wed May 10 17:59:42 2000
@@ -392,6 +392,8 @@
 from DT_InSV import sequence_variables, opt
 TupleType=type(())
 
+BreakError = 'Break Error'
+
 class InFactory:
     blockContinuations=('else',)
     name='in'
@@ -538,7 +540,8 @@
                     kw['previous-sequence-start-index']=pstart-1
                     kw['previous-sequence-end-index']=pend-1
                     kw['previous-sequence-size']=pend+1-pstart
-                    result=render(section,md)
+                    try: result=render(section,md)
+                    except BreakError: pass
 
                 elif self.elses: result=render(self.elses, md)
                 else: result=''
@@ -554,7 +557,8 @@
                     kw['next-sequence-start-index']=pstart-1
                     kw['next-sequence-end-index']=pend-1
                     kw['next-sequence-size']=pend+1-pstart
-                    result=render(section,md)
+                    try: result=render(section,md)
+                    except BreakError: pass
                 except:
                     if self.elses: result=render(self.elses, md)
                     else: result=''
@@ -608,7 +612,9 @@
                     if mapping: push(client)
                     else: push(InstanceDict(client, md))
 
-                    try: append(render(section, md))
+                    try: 
+                        try: append(render(section, md))
+                        except BreakError: break
                     finally: pop(1)
 
                     if index==first: kw['sequence-start']=0
@@ -688,7 +694,9 @@
                     if mapping: push(client)
                     else: push(InstanceDict(client, md))
 
-                    try: append(render(section, md))
+                    try:
+                        try: append(render(section, md))
+                        except BreakError: break
                     finally: pop()
                     if index==0: kw['sequence-start']=0
 
@@ -738,6 +746,18 @@
         return s
 
 
+class Break:
+
+    name='break'
+
+    def __init__(self, blocks):
+        pass
+        
+    def render(self, md):
+        raise BreakError, 'break outside of in tag'
+
+    __call__=render
+    
 basic_type={type(''): 1, type(0): 1, type(0.0): 1, type(()): 1, type([]): 1
             }.has_key
 
--- DT_String.py.orig	Thu Mar 09 11:08:32 2000
+++ DT_String.py	Wed May 10 16:00:04 2000
@@ -131,6 +131,7 @@
         'var': Var,
         'call': Call,
         'in': ('in', 'DT_In','In'),
+        'break': ('break', 'DT_In', 'Break'),
         'with': ('with', 'DT_With','With'),
         'if': ('if', 'DT_If','If'),
         'unless': ('unless', 'DT_If','Unless'),