[ZPT] CVS: Packages/ZTUtils - Iterator.py:1.6.16.1 Tree.py:1.5.16.1 Zope.py:1.9.16.1

Evan Simpson evan@zope.com
Tue, 9 Jul 2002 18:46:03 -0400


Update of /cvs-repository/Packages/ZTUtils
In directory cvs.zope.org:/tmp/cvs-serv27860

Modified Files:
      Tag: evan-zpt-1_5_2-branch
	Iterator.py Tree.py Zope.py 
Log Message:
Remove string methods.


=== Packages/ZTUtils/Iterator.py 1.6 => 1.6.16.1 ===
 $Id$'''
 __version__='$Revision$'[11:-2]
 
+import string
+
 class Iterator:
     '''Simple Iterator class'''
 
@@ -86,8 +88,8 @@
             s = s + r * rct
         return s
 
-    def roman(self):
-        return self.Roman().lower()
+    def roman(self, lower=string.lower):
+        return lower(self.Roman())
 
     def first(self, name=None):
         if self.start: return 1


=== Packages/ZTUtils/Tree.py 1.5 => 1.5.16.1 ===
     return filter(self, inst, parent, name, value)
 
 from binascii import b2a_base64, a2b_base64
-from string import translate, maketrans
+import string
+from string import split, join, translate
 
-a2u_map = maketrans('+/=', '-._')
-u2a_map = maketrans('-._', '+/=')
+a2u_map = string.maketrans('+/=', '-._')
+u2a_map = string.maketrans('-._', '+/=')
 
 def b2a(s):
     '''Encode a value as a cookie- and url-safe string.
@@ -163,7 +164,7 @@
     frags = []
     for i in range(0, len(s), 57):
         frags.append(b2a_base64(s[i:i + 57])[:-1])
-    return translate(''.join(frags), a2u_map)
+    return translate(join(frags, ''), a2u_map)
 
 def a2b(s):
     '''Decode a b2a-encoded string.'''
@@ -173,7 +174,7 @@
     frags = []
     for i in range(0, len(s), 76):
         frags.append(a2b_base64(s[i:i + 76]))
-    return ''.join(frags)
+    return join(frags, '')
 
 def encodeExpansion(nodes):
     '''Encode the expanded node ids of a tree into a string.
@@ -195,7 +196,7 @@
         steps.append(node.id)
         node.expansion_number = n
         n = n + 1
-    return ':'.join(steps)
+    return join(steps, ':')
         
 def decodeExpansion(s, nth=None):
     '''Decode an expanded node map from a string.
@@ -208,7 +209,7 @@
     nth_pair = None
     if nth is not None:
         nth_pair = (None, None)
-    for step in s.split(':'):
+    for step in split(s, ':'):
         if step[:1] == '.':
             pop = len(step) - 1
             continue


=== Packages/ZTUtils/Zope.py 1.9 => 1.9.16.1 ===
 from Batch import Batch
 from Products.ZCatalog.Lazy import Lazy
 from AccessControl import getSecurityManager
+from string import split, join
 from types import StringType, ListType, IntType, FloatType
 from DateTime import DateTime
 
@@ -116,7 +117,7 @@
         if state:
             setst = req.form.get(set_name)
             if setst:
-                st, pn, expid = setst.split(',')
+                st, pn, expid = split(setst, ',')
                 state, (m, obid) = decodeExpansion(state, int(pn))
                 if m is None:
                     pass
@@ -177,7 +178,7 @@
         k, m, v = qlist[i]
         qlist[i] = '%s%s=%s' % (uq(k), m, uq(str(v)))
 
-    return '&'.join(qlist) 
+    return join(qlist, '&')
                 
 def make_hidden_input(*args, **kwargs):
     '''Construct a set of hidden input elements, with marshalling markup.
@@ -204,7 +205,7 @@
         qlist[i] = ('<input type="hidden" name="%s%s" value="%s">'
                     % (hq(k), m, hq(str(v))))
 
-    return '\n'.join(qlist)
+    return join(qlist, '\n')
                 
 def complex_marshal(pairs):
     '''Add request marshalling information to a list of name-value pairs.
@@ -273,7 +274,7 @@
     qs = request.get('QUERY_STRING', '')
     
     if qs and omit:
-        qsparts = qs.split('&')
+        qsparts = split(qs, '&')
 
         if isinstance(omit, StringType):
             omits = {omit: None}
@@ -285,17 +286,17 @@
 
         unq = urllib.unquote
         for i in range(len(qsparts)):
-            name = unq(qsparts[i].split('=', 1)[0])
+            name = unq(split(qsparts[i], '=', 1)[0])
             if omitted(name):
                 qsparts[i] = ''
-            name = name.split(':', 1)[0]
+            name = split(name, ':', 1)[0]
             if omitted(name):
                 qsparts[i] = ''
-            name = name.split('.', 1)[0]
+            name = split(name, '.', 1)[0]
             if omitted(name):
                 qsparts[i] = ''
             
-        qs = '&'.join(filter(None, qsparts))
+        qs = join(filter(None, qsparts), '&')
 
     # We alway append '?' since arguments will be appended to the URL
     return '%s?%s' % (base, qs)