Commit 57cfe411 authored by Shane Hathaway's avatar Shane Hathaway

Collector #2357

parent cbb99bc1
...@@ -402,8 +402,8 @@ ...@@ -402,8 +402,8 @@
''' #' ''' #'
__rcs_id__='$Id: DT_In.py,v 1.52 2001/06/21 17:45:12 shane Exp $' __rcs_id__='$Id: DT_In.py,v 1.53 2001/07/02 16:30:46 shane Exp $'
__version__='$Revision: 1.52 $'[11:-2] __version__='$Revision: 1.53 $'[11:-2]
import sys import sys
from DT_Util import ParseError, parse_params, name_param, str from DT_Util import ParseError, parse_params, name_param, str
...@@ -412,6 +412,7 @@ from DT_Util import simple_name, add_with_prefix ...@@ -412,6 +412,7 @@ from DT_Util import simple_name, add_with_prefix
import re import re
from DT_InSV import sequence_variables, opt from DT_InSV import sequence_variables, opt
TupleType=type(()) TupleType=type(())
StringTypes = (type(''), type(u''))
class InFactory: class InFactory:
blockContinuations=('else',) blockContinuations=('else',)
...@@ -652,14 +653,23 @@ class InClass: ...@@ -652,14 +653,23 @@ class InClass:
client = sequence[index] client = sequence[index]
pkw['sequence-index']=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] client=client[1]
if mapping: push(client) if mapping:
else: push(InstanceDict(client, md)) pushed = 1
push(client)
elif t in StringTypes:
pushed = 0
else:
pushed = 1
push(InstanceDict(client, md))
try: append(render(section, md)) try: append(render(section, md))
finally: pop(1) finally:
if pushed:
pop()
if index==first: pkw['sequence-start']=0 if index==first: pkw['sequence-start']=0
...@@ -744,14 +754,23 @@ class InClass: ...@@ -744,14 +754,23 @@ class InClass:
client = sequence[index] client = sequence[index]
pkw['sequence-index']=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] client=client[1]
if mapping: push(client) if mapping:
else: push(InstanceDict(client, md)) pushed = 1
push(client)
elif t in StringTypes:
pushed = 0
else:
pushed = 1
push(InstanceDict(client, md))
try: append(render(section, md)) try: append(render(section, md))
finally: pop() finally:
if pushed:
pop()
if index==0: pkw['sequence-start']=0 if index==0: pkw['sequence-start']=0
result = ''.join(result) result = ''.join(result)
......
...@@ -85,8 +85,8 @@ ...@@ -85,8 +85,8 @@
"""Document Template Tests """Document Template Tests
""" """
__rcs_id__='$Id: testDTML.py,v 1.5 2001/05/23 18:03:37 shane Exp $' __rcs_id__='$Id: testDTML.py,v 1.6 2001/07/02 16:30:46 shane Exp $'
__version__='$Revision: 1.5 $'[11:-2] __version__='$Revision: 1.6 $'[11:-2]
import sys, os import sys, os
import unittest import unittest
...@@ -108,6 +108,8 @@ def read_file(name): ...@@ -108,6 +108,8 @@ def read_file(name):
from DocumentTemplate import HTML, String from DocumentTemplate import HTML, String
from ExtensionClass import Base from ExtensionClass import Base
class D: class D:
__allow_access_to_unprotected_subobjects__ = 1
def __init__(self, **kw): def __init__(self, **kw):
for k, v in kw.items(): self.__dict__[k]=v for k, v in kw.items(): self.__dict__[k]=v
...@@ -476,7 +478,7 @@ foo bar ...@@ -476,7 +478,7 @@ foo bar
andrew, 5 andrew, 5
chessie, 2 chessie, 2
""" """
result = HTML(html)(data=data) result = self.doc_class(html)(data=data)
assert result == expected, result assert result == expected, result
def checkBasicHTMLIn2(self): def checkBasicHTMLIn2(self):
...@@ -491,7 +493,16 @@ foo bar ...@@ -491,7 +493,16 @@ foo bar
2 2
3 3
""" """
result = HTML(html)(xxx=xxx) result = self.doc_class(html)(xxx=xxx)
assert result == expected, result
def checkBasicHTMLIn3(self):
ns = {'prop_ids': ('title', 'id'), 'title': 'good', 'id': 'times'}
html = """:<dtml-in prop_ids><dtml-var sequence-item>=<dtml-var
expr="_[_['sequence-item']]">:</dtml-in>"""
result = self.doc_class(html)(None, ns)
expected = ":title=good:id=times:"
assert result == expected, result assert result == expected, result
def checkHTMLInElse(self): def checkHTMLInElse(self):
...@@ -510,7 +521,7 @@ foo bar ...@@ -510,7 +521,7 @@ foo bar
2 2
3 3
""" """
result = HTML(html)(xxx=xxx, data={}) result = self.doc_class(html)(xxx=xxx, data={})
assert result == expected, result assert result == expected, result
def checkBasicStringIn(self): def checkBasicStringIn(self):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment