[Zope-Checkins] CVS: Zope2 - DT_In.py:1.53

shane@digicool.com shane@digicool.com
Mon, 2 Jul 2001 12:30:47 -0400 (EDT)


Update of /cvs-repository/Zope2/lib/python/DocumentTemplate
In directory korak.digicool.com:/tmp/cvs-serv26143

Modified Files:
	DT_In.py 
Log Message:
Collector #2357



--- Updated File DT_In.py in package Zope2 --
--- DT_In.py	2001/06/21 17:45:12	1.52
+++ DT_In.py	2001/07/02 16:30:46	1.53
@@ -412,6 +412,7 @@
 import re
 from DT_InSV import sequence_variables, opt
 TupleType=type(())
+StringTypes = (type(''), type(u''))
 
 class InFactory:
     blockContinuations=('else',)
@@ -652,14 +653,23 @@
                         client = sequence[index]
 
                     pkw['sequence-index']=index
-                    if type(client)==TupleType and len(client)==2:
+                    t = type(client)
+                    if t is TupleType and len(client)==2:
                         client=client[1]
 
-                    if mapping: push(client)
-                    else: push(InstanceDict(client, md))
+                    if mapping:
+                        pushed = 1
+                        push(client)
+                    elif t in StringTypes:
+                        pushed = 0
+                    else:
+                        pushed = 1
+                        push(InstanceDict(client, md))
 
                     try: append(render(section, md))
-                    finally: pop(1)
+                    finally:
+                        if pushed:
+                            pop()
 
                     if index==first: pkw['sequence-start']=0
 
@@ -744,14 +754,23 @@
                         client = sequence[index]
 
                     pkw['sequence-index']=index
-                    if type(client)==TupleType and len(client)==2:
+                    t = type(client)
+                    if t is TupleType and len(client)==2:
                         client=client[1]
 
-                    if mapping: push(client)
-                    else: push(InstanceDict(client, md))
+                    if mapping:
+                        pushed = 1
+                        push(client)
+                    elif t in StringTypes:
+                        pushed = 0
+                    else:
+                        pushed = 1
+                        push(InstanceDict(client, md))
 
                     try: append(render(section, md))
-                    finally: pop()
+                    finally:
+                        if pushed:
+                            pop()
                     if index==0: pkw['sequence-start']=0
 
                 result = ''.join(result)