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

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


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

Modified Files:
      Tag: Zope-2_4-branch
	DT_In.py 
Log Message:
Fixed collector #2357: Python 2.1 strings now have attributes, especially
"title".



--- 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:29:11	1.52.2.1
@@ -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)