[Zope-Checkins] CVS: Zope/lib/python/OFS - Application.py:1.180 Cache.py:1.9 CopySupport.py:1.78 DTMLDocument.py:1.46 DTMLMethod.py:1.74 DefaultObservable.py:1.5 FindSupport.py:1.29 History.py:1.11 Image.py:1.135 Moniker.py:1.15 ObjectManager.py:1.146 PropertyManager.py:1.43 PropertySheets.py:1.82 SimpleItem.py:1.93 Traversable.py:1.14 Uninstalled.py:1.13 XMLExportImport.py:1.3 ZDOM.py:1.11 content_types.py:1.17 ndiff.py:1.2

Andreas Jung andreas@digicool.com
Thu, 7 Feb 2002 12:21:00 -0500


Update of /cvs-repository/Zope/lib/python/OFS
In directory cvs.zope.org:/tmp/cvs-serv10147

Modified Files:
	Application.py Cache.py CopySupport.py DTMLDocument.py 
	DTMLMethod.py DefaultObservable.py FindSupport.py History.py 
	Image.py Moniker.py ObjectManager.py PropertyManager.py 
	PropertySheets.py SimpleItem.py Traversable.py Uninstalled.py 
	XMLExportImport.py ZDOM.py content_types.py ndiff.py 
Log Message:
replaced string module calls by string methods


=== Zope/lib/python/OFS/Application.py 1.179 => 1.180 ===
 
 import Globals,Folder,os,sys,App.Product, App.ProductRegistry, misc_
-import time, traceback, os, string, Products
-from string import strip, lower, find, rfind, join
+import time, traceback, os,  Products
 from DateTime import DateTime
 from AccessControl.User import UserFolder
 from App.ApplicationManager import ApplicationManager
@@ -83,7 +82,7 @@
 
     def PrincipiaRedirect(self,destination,URL1):
         """Utility function to allow user-controlled redirects"""
-        if find(destination,'//') >= 0: raise 'Redirect', destination
+        if destination.find('//') >= 0: raise 'Redirect', destination
         raise 'Redirect', ("%s/%s" % (URL1, destination))
     Redirect=ZopeRedirect=PrincipiaRedirect
 


=== Zope/lib/python/OFS/Cache.py 1.8 => 1.9 ===
 
 import time, sys
-from string import join
 import Globals
 from Globals import DTMLFile
 from Acquisition import aq_get, aq_acquire, aq_inner, aq_parent, aq_base
@@ -373,7 +372,7 @@
             icon = getattr(aq_base(subob), 'icon', '')
             info = {
                 'sortkey': subpath,
-                'path': join(subpath, '/'),
+                'path': '/'.join(subpath),
                 'title': getattr(aq_base(subob), 'title', ''),
                 'icon': icon,
                 'associated': associated,}


=== Zope/lib/python/OFS/CopySupport.py 1.77 => 1.78 ===
 __version__='$Revision$'[11:-2]
 
-import sys, string, Globals, Moniker, tempfile, ExtensionClass
+import sys,  Globals, Moniker, tempfile, ExtensionClass
 from marshal import loads, dumps
 from urllib import quote, unquote
 from zlib import compress, decompress


=== Zope/lib/python/OFS/DTMLDocument.py 1.45 => 1.46 ===
 from webdav.WriteLockInterface import WriteLockInterface
 from sgmllib import SGMLParser
-from string import find
 from urllib import quote
 import Globals
 from AccessControl import getSecurityManager


=== Zope/lib/python/OFS/DTMLMethod.py 1.73 => 1.74 ===
 import History
 from Globals import HTML, DTMLFile, MessageDialog
-from string import join,split,strip,rfind,atoi,lower
 from SimpleItem import Item_w__name__, pretty_tb
 from OFS.content_types import guess_content_type
 from PropertyManager import PropertyManager
@@ -188,7 +187,7 @@
         '''
         ks = []
         for key in keys:
-            key = strip(str(key))
+            key = str(key).strip()
             if key:
                 ks.append(key)
         self._cache_namespace_keys = tuple(ks)
@@ -222,8 +221,8 @@
     def _er(self,data,title,SUBMIT,dtpref_cols,dtpref_rows,REQUEST):
         dr,dc = self._size_changes[SUBMIT]
         
-        rows=max(1,atoi(dtpref_rows)+dr)
-        cols=max(40,atoi(dtpref_cols)+dc)
+        rows=max(1,int(dtpref_rows)+dr)
+        cols=max(40,int(dtpref_cols)+dc)
         e=(DateTime('GMT') + 365).rfc822()
         resp=REQUEST['RESPONSE']
         resp.setCookie('dtpref_rows',str(rows),path='/',expires=e)
@@ -338,7 +337,6 @@
                 ))
 
 import re
-from string import find, strip
 token = "[a-zA-Z0-9!#$%&'*+\-.\\\\^_`|~]+"
 hdr_start = re.compile(r'(%s):(.*)' % token).match
 
@@ -355,9 +353,9 @@
         headers.append(header)
         spos = m.end() + 1
         while spos < len(html) and html[spos] in ' \t':
-            eol = find(html, '\n', spos)
+            eol = html.find( '\n', spos)
             if eol < 0: return html
-            header.append(strip(html[spos:eol]))
+            header.append(html[spos:eol].strip())
             spos = eol + 1
     if RESPONSE is not None:
         for header in headers:


=== Zope/lib/python/OFS/DefaultObservable.py 1.4 => 1.5 ===
 __version__='$Revision$'[11:-2]
 
-import string
 from types import StringType
 
 class DefaultObservable:
@@ -63,7 +62,7 @@
 
         # Assert that observer is a string or a sequence of strings.
         if type( observer ) != StringType:
-            observer = string.join( observer, '/' ) 
+            observer = '/'.join( observer) 
 
         return observer
 


=== Zope/lib/python/OFS/FindSupport.py 1.28 => 1.29 ===
 
 
-import sys, os, string, time, Globals, ExtensionClass
+import sys, os, time, Globals, ExtensionClass
 from DocumentTemplate.DT_Util import Eval
 from AccessControl.Permission import name_trans
 from Globals import DTMLFile
 from DocumentTemplate.DT_Util import InstanceDict, TemplateDict
 from DateTime import DateTime
-from string import find
+from string import translate
 from AccessControl.DTML import RestrictedDTML
 
 class FindSupport(ExtensionClass.Base):
@@ -114,7 +114,7 @@
                 and
                 (not obj_searchterm or
                  (hasattr(ob, 'PrincipiaSearchSource') and
-                  find(ob.PrincipiaSearchSource(), obj_searchterm) >= 0
+                  ob.PrincipiaSearchSource().find(obj_searchterm) >= 0
                   ))
                 and
                 (not obj_expr or expr_match(ob, obj_expr))
@@ -213,7 +213,7 @@
                 and
                 (not obj_searchterm or
                  (hasattr(ob, 'PrincipiaSearchSource') and
-                  find(ob.PrincipiaSearchSource(), obj_searchterm) >= 0
+                  ob.PrincipiaSearchSource().find(obj_searchterm) >= 0
                   ))
                 and
                 (not obj_expr or expr_match(ob, obj_expr))
@@ -306,6 +306,6 @@
 
 
 def p_name(name):
-    return '_' + string.translate(name, name_trans) + '_Permission'
+    return '_' + translate(name, name_trans) + '_Permission'
 
 


=== Zope/lib/python/OFS/History.py 1.10 => 1.11 ===
 from DateTime import DateTime
 from Acquisition import Implicit, aq_base
-from string import join, split, atoi, strip
 from struct import pack, unpack
 from cgi import escape
 
@@ -59,7 +58,7 @@
     def __getitem__(self, key):
         self=self.aq_parent
 
-        serial=apply(pack, ('>HHHH',)+tuple(map(atoi, split(key,'.'))))
+        serial=apply(pack, ('>HHHH',)+tuple(map(int, key.split('.'))))
 
         if serial == self._p_serial: return self
 
@@ -117,7 +116,7 @@
 
         for d in r:
             d['time']=DateTime(d['time'])
-            d['key']=join(map(str, unpack(">HHHH", d['serial'])),'.')
+            d['key']='.'.join(map(str, unpack(">HHHH", d['serial'])))
 
         return r
 
@@ -135,7 +134,7 @@
                 "copied to the present.<p>")
 
         key=keys[0]
-        serial=apply(pack, ('>HHHH',)+tuple(map(atoi, split(key,'.'))))
+        serial=apply(pack, ('>HHHH',)+tuple(map(int, key.split('.'))))
 
         if serial != self._p_serial:
             self.manage_beforeHistoryCopy()
@@ -175,12 +174,12 @@
             raise HistorySelectionError, (
                 "Only two historical revision can be compared<p>")
         
-        serial=apply(pack, ('>HHHH',)+tuple(map(atoi, split(keys[-1],'.'))))
+        serial=apply(pack, ('>HHHH',)+tuple(map(int, keys[-1].split('.'))))
         rev1=historicalRevision(self, serial)
         
         if len(keys)==2:
             serial=apply(pack,
-                         ('>HHHH',)+tuple(map(atoi, split(keys[0],'.'))))
+                         ('>HHHH',)+tuple(map(int, keys[0].split('.'))))
 
             rev2=historicalRevision(self, serial)
         else:
@@ -200,7 +199,7 @@
             "<td><pre>\n%s\n</pre></td>\n"
             "<td><pre>\n%s\n</pre></td>\n"
             "</tr>\n"
-            % (join(r1,'\n'), escape(join(r2, '\n'))))
+            % ('\n'.join(r1), escape('\n'.join(r2))))
 
 def replace(x, xlo, xhi, y, ylo, yhi, r):
 
@@ -221,12 +220,13 @@
             "<td><pre>\n%s\n%s\n</pre></td>\n"
             "<td><pre>\n%s\n%s\n</pre></td>\n"
             "</tr>\n"
-            % (join(rx1, '\n'), join(ry1, '\n'),
-               escape(join(rx2, '\n')), escape(join(ry2, '\n'))))
+            % ('\n'.join(rx1), '\n'.join(ry1),
+               escape('\n'.join(rx2)), escape('\n'.join(ry2))))
 
 def html_diff(s1, s2):
-    a=split(s1,'\n')
-    b=split(s2,'\n')
+    from string import split
+    a=s1.split('\n')
+    b=s2.split('\n')
     cruncher=ndiff.SequenceMatcher(isjunk=split, a=a, b=b)
 
     r=['<table border=1>']
@@ -243,4 +243,4 @@
             raise ValueError, 'unknown tag ' + `tag`
     r.append('</table>')
 
-    return join(r, '\n')
+    return '\n'.join(r)


=== Zope/lib/python/OFS/Image.py 1.134 => 1.135 ===
 __version__='$Revision$'[11:-2]
 
-import Globals, string, struct
+import Globals, struct
 from OFS.content_types import guess_content_type
 from Globals import DTMLFile
 from PropertyManager import PropertyManager
@@ -133,7 +133,7 @@
         # HTTP If-Modified-Since header handling.
         header=REQUEST.get_header('If-Modified-Since', None)
         if header is not None:
-            header=string.split(header, ';')[0]
+            header=header.split( ';')[0]
             # Some proxies seem to send invalid date strings for this
             # header. If the date string is not valid, we ignore it
             # rather than raise an error to be generally consistent
@@ -192,7 +192,7 @@
                         ranges = None
                 else:
                     # Date
-                    date = string.split(if_range, ';')[0]
+                    date = if_range.split( ';')[0]
                     try: mod_since=long(DateTime(date).timeTime())
                     except: mod_since=None
                     if mod_since is not None:
@@ -745,7 +745,7 @@
         if width:
             result = '%s width="%s"' % (result, width)
 
-        if not 'border' in map(string.lower, args.keys()):
+        if not 'border' in [ x.lower() for x in  args.keys()]:
             result = '%s border="0"' % result
 
         if css_class is not None:
@@ -762,9 +762,9 @@
     if not id and hasattr(file,'filename'):
         filename=file.filename
         title=title or filename
-        id=filename[max(string.rfind(filename, '/'),
-                        string.rfind(filename, '\\'),
-                        string.rfind(filename, ':'),
+        id=filename[max(filename.rfind('/'),
+                        filename.rfind('\\'),
+                        filename.rfind(':'),
                         )+1:]                  
     return id, title
 
@@ -793,7 +793,7 @@
             r.append(self.data)
             next=self.next
         
-        return string.join(r,'')
+        return ''.join(r)
 
 
 


=== Zope/lib/python/OFS/Moniker.py 1.14 => 1.15 ===
 
 import Globals
-import string
 
 class Moniker:
     """An object moniker is an intelligent reference to a


=== Zope/lib/python/OFS/ObjectManager.py 1.145 => 1.146 ===
 from AccessControl import getSecurityManager
 from zLOG import LOG, ERROR
-import sys,string,fnmatch,copy
+import sys,fnmatch,copy
 
 import XMLExportImport
 customImporters={


=== Zope/lib/python/OFS/PropertyManager.py 1.42 => 1.43 ===
 from ZPublisher.Converters import type_converters
 from Globals import DTMLFile, MessageDialog
-from string import find,join,lower,split
 from Acquisition import Implicit, aq_base
 from Globals import Persistent
 


=== Zope/lib/python/OFS/PropertySheets.py 1.81 => 1.82 ===
 __version__='$Revision$'[11:-2]
 
-import time, string, App.Management, Globals
+import time,  App.Management, Globals
 from webdav.WriteLockInterface import WriteLockInterface
 from ZPublisher.Converters import type_converters
 from Globals import DTMLFile, MessageDialog
-from string import find,join,lower,split,rfind
 from Acquisition import Implicit, Explicit
 from App.Common import rfc1123_date, iso8601_date
 from webdav.common import urlbase
@@ -52,7 +51,7 @@
         else:
             pre=r['URL']
             for i in (1,2,3):
-                l=rfind(pre,'/')
+                l=pre.rfind('/')
                 if l >= 0:
                     pre=pre[:l]
             pre=pre+'/'
@@ -70,10 +69,10 @@
         return r
 
     def tabs_path_info(self, script, path):
-        l=rfind(path,'/')
+        l=path.rfind('/')
         if l >= 0:
             path=path[:l]
-            l=rfind(path,'/')
+            l=path.rfind('/')
             if l >= 0: path=path[:l]
         return View.inheritedAttribute('tabs_path_info')(
             self, script, path)
@@ -285,7 +284,7 @@
              '  %s\n' \
              '  </d:responsedescription>\n'
 
-    def dav__allprop(self, propstat=propstat, join=string.join):
+    def dav__allprop(self, propstat=propstat ):
         # DAV helper method - return one or more propstat elements
         # indicating property names and values for all properties.
         result=[]
@@ -294,14 +293,14 @@
             value=self.getProperty(name)
 
             if type=='tokens':
-                value=join(str(value), ' ')
+                value=' '.join(str(value))
             elif type=='lines':
-                value=join(str(value), '\n')
+                value='\n'.join(str(value))
             # check for xml property
             attrs=item.get('meta', {}).get('__xml_attrs__', None)
             if attrs is not None:
                 attrs=map(lambda n: ' %s="%s"' % n, attrs.items())
-                attrs=join(attrs, '')
+                attrs=''.join(attrs)
             else:
                 # Quote non-xml items here?
                 attrs='' 
@@ -313,24 +312,23 @@
 
             result.append(prop)
         if not result: return ''
-        result=join(result, '\n')
+        result='\n'.join(result)
         
         return propstat % (self.xml_namespace(), result, '200 OK', '')
 
-    def dav__propnames(self, propstat=propstat, join=string.join):
+    def dav__propnames(self, propstat=propstat):
         # DAV helper method - return a propstat element indicating
         # property names for all properties in this PropertySheet.
         result=[]
         for name in self.propertyIds():
             result.append('  <n:%s/>' % name)
         if not result: return ''
-        result=join(result, '\n')
+        result='\n'.join(result)
         return propstat % (self.xml_namespace(), result, '200 OK', '')
 
 
     def dav__propstat(self, name, result,
-                      propstat=propstat, propdesc=propdesc,
-                      join=string.join):
+                      propstat=propstat, propdesc=propdesc):
         # DAV helper method - return a propstat element indicating
         # property name and value for the requested property.
         xml_id=self.xml_namespace()
@@ -347,14 +345,14 @@
             name, type=item['id'], item.get('type','string')
             value=self.getProperty(name)
             if type=='tokens':
-                value=join(str(value), ' ')
+                value=' '.join(str(value))
             elif type=='lines':
-                value=join(str(value), '\n')
+                value='\n'.join(str(value))
             # allow for xml properties
             attrs=item.get('meta', {}).get('__xml_attrs__', None)
             if attrs is not None:
                 attrs=map(lambda n: ' %s="%s"' % n, attrs.items())
-                attrs=join(attrs, '')
+                attrs=''.join(attrs)
             else:
                 # quote non-xml items here?
                 attrs=''
@@ -664,7 +662,7 @@
         else:
             pre=r['URL']
             for i in (1,2):
-                l=rfind(pre,'/')
+                l=pre.rfind('/')
                 if l >= 0:
                     pre=pre[:l]
             pre=pre+'/'
@@ -675,7 +673,7 @@
         return r
 
     def tabs_path_info(self, script, path):
-        l=rfind(path,'/')
+        l=path.rfind('/')
         if l >= 0: path=path[:l]
         return PropertySheets.inheritedAttribute('tabs_path_info')(
             self, script, path)


=== Zope/lib/python/OFS/SimpleItem.py 1.92 => 1.93 ===
 from ExtensionClass import Base
 from CopySupport import CopySource
-from string import join, lower, find, split
 from types import InstanceType, StringType
 from ComputedAttribute import ComputedAttribute
 from AccessControl import getSecurityManager
@@ -162,7 +161,7 @@
                 raise error_type, error_value, tb
             self._v_eek=1
    
-            if lower(str(error_type)) in ('redirect',):
+            if str(error_type).lower() in ('redirect',):
                 raise error_type, error_value, tb
 
             if not error_message:
@@ -342,12 +341,12 @@
         except: pass
         tb = tb.tb_next
         n = n+1
-    result.append(join(traceback.format_exception_only(etype, value),' '))
+    result.append(' '.join(traceback.format_exception_only(etype, value)))
     return result
 
 def pretty_tb(t,v,tb):
     tb=format_exception(t,v,tb,200)
-    tb=join(tb,'\n')
+    tb='\n'.join(tb)
     return tb
 
 class SimpleItem(Item, Globals.Persistent,


=== Zope/lib/python/OFS/Traversable.py 1.13 => 1.14 ===
 from AccessControl import getSecurityManager
 from AccessControl import Unauthorized
-from string import split, join
 from urllib import quote
 
 _marker=[]
@@ -44,8 +43,8 @@
         path = map(quote, spp[i:])
         if relative:
             # This is useful for physical path relative to a VirtualRoot
-            return join(path, '/')
-        return join([req['SERVER_URL']] + req._script + path, '/')
+            return '/'.join(path)
+        return '/'.join([req['SERVER_URL']] + req._script + path)
 
     getPhysicalRoot__roles__=() # Private
     getPhysicalRoot=Acquired
@@ -75,7 +74,7 @@
         N=None
         M=_marker
 
-        if type(path) is StringType: path = split(path,'/')
+        if type(path) is StringType: path = path.split('/')
         else: path=list(path)
 
         REQUEST={'TraversalRequestNameStack': path}


=== Zope/lib/python/OFS/Uninstalled.py 1.12 => 1.13 ===
 Objects for packages that have been uninstalled.
 """
-import string, SimpleItem, Globals, Acquisition
+import  SimpleItem, Globals, Acquisition
 from Acquisition import Acquired
 import Persistence
 from thread import allocate_lock
@@ -59,7 +59,7 @@
             exec ("class %s(BrokenClass): ' '; __module__=%s"
                   % (klassname, `module`)) in d
             klass = broken_klasses[pair] = d[klassname]
-            module=string.split(module,'.')
+            module=module.split('.')
             if len(module) > 2 and module[0]=='Products':
                 klass.product_name= module[1]
             klass.title=(


=== Zope/lib/python/OFS/XMLExportImport.py 1.2 => 1.3 ===
 # 
 ##############################################################################
-import Shared.DC.xml.ppml, string
+import Shared.DC.xml.ppml
 ppml=Shared.DC.xml.ppml
 from base64 import encodestring
 from cStringIO import StringIO
@@ -89,7 +89,7 @@
     file.seek(pos)
     a=data[1]
     if a.has_key('id'): oid=a['id']
-    oid=ppml.p64(string.atoi(oid))
+    oid=ppml.p64(int(oid))
     v=''
     for x in data[2:]:
         v=v+x


=== Zope/lib/python/OFS/ZDOM.py 1.10 => 1.11 ===
 All standard Zope objects support DOM to a limited extent.
 """
-import string
 import Acquisition
 
 
@@ -250,7 +249,7 @@
         will cause the method to return true. Return Value true if the
         feature is implemented in the specified version, false otherwise.
         """
-        feature=string.lower(feature)
+        feature=feature.lower()
         if feature == 'html': return 0
         if feature == 'xml':
             if version is None: return 1


=== Zope/lib/python/OFS/content_types.py 1.16 => 1.17 ===
 __version__='$Revision$'[11:-2]
 
-from string import split, strip, lower, find
 import re, mimetypes
 
 
@@ -21,7 +20,7 @@
 
 def text_type(s):
     # Yuk. See if we can figure out the type by content.
-    if (lower(strip(s)[:6]) == '<html>' or find(s, '</') > 0):
+    if (s.strip().lower()[:6] == '<html>' or s.find('</') > 0):
         return 'text/html'
 
     elif s.strip().startswith('<?xml'):
@@ -92,7 +91,7 @@
         else:
                 type=default or 'text/x-unknown-content-type'
         
-    return lower(type), enc and lower(enc) or None
+    return type.lower(), enc and enc.lower() or None
 
 if __name__=='__main__':
     items=mimetypes.types_map.items()


=== Zope/lib/python/OFS/ndiff.py 1.1 => 1.2 ===
 # have been in sys.argv[1:] had the cmd-line form been used.
 
-import string
 TRACE = 0
 
 # define what "junk" means
@@ -515,7 +514,7 @@
             btags = btags + ' ' * (la - lb)
         combined = map(lambda x,y: _combine[x+y], atags, btags)
         print '-', aelt, '+', belt, '?', \
-              string.rstrip(string.join(combined, ''))
+              ''.string.join(combined).rstrip()
     else:
         # the synch pair is identical
         print ' ', aelt,