[ZPT] CVS: Zope/lib/python/Products/PageTemplates - Expressions.py:1.35 PageTemplate.py:1.24 PageTemplateFile.py:1.14 PathIterator.py:1.3 PythonExpr.py:1.7 ZPythonExpr.py:1.7 ZRPythonExpr.py:1.9 ZopePageTemplate.py:1.38

Andreas Jung andreas@digicool.com
Fri, 19 Apr 2002 10:16:10 -0400


Update of /cvs-repository/Zope/lib/python/Products/PageTemplates
In directory cvs.zope.org:/tmp/cvs-serv7137/lib/python/Products/PageTemplates

Modified Files:
	Expressions.py PageTemplate.py PageTemplateFile.py 
	PathIterator.py PythonExpr.py ZPythonExpr.py ZRPythonExpr.py 
	ZopePageTemplate.py 
Log Message:
replace string module calls by string methods


=== Zope/lib/python/Products/PageTemplates/Expressions.py 1.34 => 1.35 ===
 from TALES import Engine, CompilerError, _valid_name, NAME_RE, \
      Undefined, Default, _parse_expr
-from string import strip, split, join, replace, lstrip
 from Acquisition import aq_base, aq_inner, aq_parent
 
 
@@ -104,7 +103,7 @@
 
 class SubPathExpr:
     def __init__(self, path):
-        self._path = path = split(strip(path), '/')
+        self._path = path = path.strip().split('/')
         self._base = base = path.pop(0)
         if not _valid_name(base):
             raise CompilerError, 'Invalid variable name "%s"' % base
@@ -145,15 +144,15 @@
     def __init__(self, name, expr, engine):
         self._s = expr
         self._name = name
-        paths = split(expr, '|')
+        paths = expr.split('|')
         self._subexprs = []
         add = self._subexprs.append
         for i in range(len(paths)):
-            path = lstrip(paths[i])
+            path = paths[i].lstrip()
             if _parse_expr(path):
                 # This part is the start of another expression type,
                 # so glue it back together and compile it.
-                add(engine.compile(lstrip(join(paths[i:], '|'))))
+                add(engine.compile(('|'.join(paths[i:]).lstrip())))
                 break
             add(SubPathExpr(path)._eval)
 
@@ -204,11 +203,11 @@
     def __init__(self, name, expr, engine):
         self._s = expr
         if '%' in expr:
-            expr = replace(expr, '%', '%%')
+            expr = expr.replace('%', '%%')
         self._vars = vars = []
         if '$' in expr:
             parts = []
-            for exp in split(expr, '$$'):
+            for exp in expr.split('$$'):
                 if parts: parts.append('$')
                 m = _interp.search(exp)
                 while m is not None:
@@ -222,7 +221,7 @@
                     raise CompilerError, (
                         '$ must be doubled or followed by a simple path')
                 parts.append(exp)
-            expr = join(parts, '')
+            expr = ''.join(parts)
         self._expr = expr
         
     def __call__(self, econtext):
@@ -243,7 +242,7 @@
 
 class NotExpr:
     def __init__(self, name, expr, compiler):
-        self._s = expr = lstrip(expr)
+        self._s = expr = expr.lstrip()
         self._c = compiler.compile(expr)
         
     def __call__(self, econtext):
@@ -265,7 +264,7 @@
 
 class DeferExpr:
     def __init__(self, name, expr, compiler):
-        self._s = expr = lstrip(expr)
+        self._s = expr = expr.lstrip()
         self._c = compiler.compile(expr)
         
     def __call__(self, econtext):


=== Zope/lib/python/Products/PageTemplates/PageTemplate.py 1.23 => 1.24 ===
 from TAL.TALInterpreter import TALInterpreter
 from Expressions import getEngine
-from string import join, strip, rstrip, split, replace, lower, find
 from cStringIO import StringIO
 from ExtensionClass import Base
 from ComputedAttribute import ComputedAttribute
@@ -148,7 +147,7 @@
                          self._text) )
                                   
         return ('%s\n %s\n-->\n%s' % (self._error_start,
-                                      join(self._v_errors, '\n '),
+                                      '\n '.join(self._v_errors),
                                       self._text))
 
     def _cook(self):
@@ -182,7 +181,7 @@
 class _ModuleImporter:
     def __getitem__(self, module):
         mod = __import__(module)
-        path = split(module, '.')
+        path = module.split('.')
         for name in path[1:]:
             mod = getattr(mod, name)
         return mod


=== Zope/lib/python/Products/PageTemplates/PageTemplateFile.py 1.13 => 1.14 ===
 from Globals import package_home, DevelopmentMode
 from zLOG import LOG, ERROR, INFO
-from string import join, strip, rstrip, split, lower
 from Shared.DC.Scripts.Script import Script, BindingsUI
 from Shared.DC.Scripts.Signature import FuncCode
 from AccessControl import getSecurityManager
@@ -116,7 +115,7 @@
         self._cook()
         if self._v_errors:
             LOG('PageTemplateFile', ERROR, 'Error in template',
-                join(self._v_errors, '\n'))
+                '\n'.join(self._v_errors))
             return
         self._v_last_read = mtime
 


=== Zope/lib/python/Products/PageTemplates/PathIterator.py 1.2 => 1.3 ===
 import TALES
 from Expressions import restrictedTraverse, Undefs, getSecurityManager
-from string import split
 
 class Iterator(TALES.Iterator):
     def __bobo_traverse__(self, REQUEST, name):
@@ -36,7 +35,7 @@
         if name is None:
             return ob1 == ob2
         if isinstance(name, type('')):
-            name = split(name, '/')
+            name = name.split('/')
         name = filter(None, name)
         securityManager = getSecurityManager()
         try:


=== Zope/lib/python/Products/PageTemplates/PythonExpr.py 1.6 => 1.7 ===
 
 from TALES import CompilerError
-from string import strip, split, join, replace, lstrip
 from sys import exc_info
 
 class getSecurityManager:
@@ -28,10 +27,10 @@
 
 class PythonExpr:
     def __init__(self, name, expr, engine):
-        self.expr = expr = replace(strip(expr), '\n', ' ')
+        self.expr = expr = expr.strip().replace('\n', ' ')
         try:
             d = {}
-            exec 'def f():\n return %s\n' % strip(expr) in d
+            exec 'def f():\n return %s\n' % expr.strip() in d
             self._f = d['f']
         except:
             raise CompilerError, ('Python expression error:\n'


=== Zope/lib/python/Products/PageTemplates/ZPythonExpr.py 1.6 => 1.7 ===
      GuardedBlock, theGuard, safebin, WriteGuard, ReadGuard, UntupleFunction
 from TALES import CompilerError
-from string import strip, split, join, replace, lstrip
 
 from PythonExpr import PythonExpr
 
 class PythonExpr(PythonExpr):
     def __init__(self, name, expr, engine):
-        self.expr = expr = replace(strip(expr), '\n', ' ')
+        self.expr = expr = expr.strip().replace('\n', ' ')
         blk = GuardedBlock('def f():\n return \\\n %s\n' % expr)
         if blk.errors:
             raise CompilerError, ('Python expression error:\n%s' %
-                                  join(blk.errors, '\n') )
+                                  '\n'.join(blk.errors) )
         guards = {'$guard': theGuard, '$write_guard': WriteGuard,
                   '$read_guard': ReadGuard, '__debug__': __debug__}
         self._f = UntupleFunction(blk.t, guards, __builtins__=safebin)
@@ -43,7 +42,7 @@
     __allow_access_to_unprotected_subobjects__ = 1
     def __getitem__(self, module):
         mod = safebin['__import__'](module)
-        path = split(module, '.')
+        path = module.split('.')
         for name in path[1:]:
             mod = getattr(mod, name)
         return mod


=== Zope/lib/python/Products/PageTemplates/ZRPythonExpr.py 1.8 => 1.9 ===
 from RestrictedPython import compile_restricted_eval
 from TALES import CompilerError
-from string import strip, split, join, replace, lstrip
 
 from PythonExpr import PythonExpr
 
@@ -33,11 +32,11 @@
                 '_getattr_': guarded_getattr,
                 '_getitem_': guarded_getitem,}
     def __init__(self, name, expr, engine):
-        self.expr = expr = replace(strip(expr), '\n', ' ')
+        self.expr = expr = expr.strip().replace('\n', ' ')
         code, err, warn, use = compile_restricted_eval(expr, str(self))
         if err:
             raise CompilerError, ('Python expression error:\n%s' %
-                                  join(err, '\n') )
+                                  '\n'.join(err) )
         self._f_varnames = use.keys()
         self._code = code
         
@@ -52,7 +51,7 @@
     __allow_access_to_unprotected_subobjects__ = 1
     def __getitem__(self, module):
         mod = safe_builtins['__import__'](module)
-        path = split(module, '.')
+        path = module.split('.')
         for name in path[1:]:
             mod = getattr(mod, name)
         return mod


=== Zope/lib/python/Products/PageTemplates/ZopePageTemplate.py 1.37 => 1.38 ===
 from OFS.SimpleItem import SimpleItem
 from DateTime.DateTime import DateTime
-from string import join, strip, rstrip, split, replace, lower
 from Shared.DC.Scripts.Script import Script, BindingsUI
 from Shared.DC.Scripts.Signature import FuncCode
 from AccessControl import getSecurityManager
@@ -119,7 +118,7 @@
         message = "Saved changes."
         if getattr(self, '_v_warnings', None):
             message = ("<strong>Warning:</strong> <i>%s</i>" 
-                       % join(self._v_warnings, '<br>'))
+                       % '<br>'.join(self._v_warnings))
         return self.pt_editForm(manage_tabs_message=message)
 
     def pt_setTitle(self, title):