diff options
author | Hanno Schlichting <hanno@hannosch.eu> | 2011-08-20 15:44:04 +0000 |
---|---|---|
committer | Hanno Schlichting <hanno@hannosch.eu> | 2011-08-20 15:44:04 +0000 |
commit | 1367f9511261bea77dfae339fcf91513ba6fa996 (patch) | |
tree | 1637140515d47cadec5334c058848a7cad001f04 | |
parent | b951f9ec834ff7f1ee2ccde58f9ee472097d61fb (diff) | |
download | zope-pagetemplate-1367f9511261bea77dfae339fcf91513ba6fa996.tar.gz |
Replaced StringIO stream class with a faster list-based implementation.
-rw-r--r-- | CHANGES.txt | 5 | ||||
-rw-r--r-- | setup.py | 2 | ||||
-rw-r--r-- | src/zope/pagetemplate/pagetemplate.py | 16 |
3 files changed, 19 insertions, 4 deletions
diff --git a/CHANGES.txt b/CHANGES.txt index fdac192..2b2b5f4 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -3,9 +3,12 @@ CHANGES ======= 3.6.0 (unreleased) +------------------ + +- Replaced StringIO stream class with a faster list-based implementation. - Abstract out the template engine and program interfaces and allow - implementation replacement via a utility component registration. + implementation replacement via a utility registration. 3.5.3 (unreleased) ------------------ @@ -27,7 +27,7 @@ def read(*rnames): setup(name='zope.pagetemplate', - version='3.5.3dev', + version='3.6.0dev', author='Zope Foundation and Contributors', author_email='zope-dev@zope.org', description='Zope Page Templates', diff --git a/src/zope/pagetemplate/pagetemplate.py b/src/zope/pagetemplate/pagetemplate.py index 0b3bfcc..55f7ffb 100644 --- a/src/zope/pagetemplate/pagetemplate.py +++ b/src/zope/pagetemplate/pagetemplate.py @@ -22,8 +22,6 @@ from zope.tal.talgenerator import TALGenerator from zope.tal.talinterpreter import TALInterpreter from zope.tales.engine import Engine from zope.component import queryUtility -# Don't use cStringIO here! It's not unicode aware. -from StringIO import StringIO from zope.pagetemplate.interfaces import IPageTemplateSubclassing from zope.pagetemplate.interfaces import IPageTemplateEngine @@ -35,6 +33,20 @@ _default_options = {} _error_start = '<!-- Page Template Diagnostics' +class StringIO(list): + """Unicode aware append-only version of StringIO. + """ + write = list.append + + def __init__(self, value=None): + list.__init__(self) + if value is not None: + self.append(value) + + def getvalue(self): + return u''.join(self) + + class PageTemplate(object): """Page Templates using TAL, TALES, and METAL. |