[Checkins] SVN: Zope/branches/2.13/src/ micro optimization

Nikolay Kim fafhrd91 at gmail.com
Mon Jul 18 18:36:20 EDT 2011


Log message for revision 122286:
  micro optimization

Changed:
  U   Zope/branches/2.13/src/App/ApplicationManager.py
  U   Zope/branches/2.13/src/App/ImageFile.py
  U   Zope/branches/2.13/src/App/special_dtml.py
  U   Zope/branches/2.13/src/OFS/Application.py
  U   Zope/branches/2.13/src/OFS/CopySupport.py
  U   Zope/branches/2.13/src/OFS/DTMLDocument.py
  U   Zope/branches/2.13/src/OFS/DTMLMethod.py
  U   Zope/branches/2.13/src/OFS/ObjectManager.py
  U   Zope/branches/2.13/src/OFS/PropertyManager.py
  U   Zope/branches/2.13/src/OFS/PropertySheets.py
  U   Zope/branches/2.13/src/OFS/SimpleItem.py
  U   Zope/branches/2.13/src/Products/Sessions/BrowserIdManager.py
  U   Zope/branches/2.13/src/Products/Sessions/SessionDataManager.py
  U   Zope/branches/2.13/src/ZPublisher/HTTPRequest.py
  U   Zope/branches/2.13/src/ZServer/HTTPResponse.py

-=-
Modified: Zope/branches/2.13/src/App/ApplicationManager.py
===================================================================
--- Zope/branches/2.13/src/App/ApplicationManager.py	2011-07-18 21:19:27 UTC (rev 122285)
+++ Zope/branches/2.13/src/App/ApplicationManager.py	2011-07-18 22:36:19 UTC (rev 122286)
@@ -346,7 +346,7 @@
 
     def db_size(self):
         s = self._p_jar.db().getSize()
-        if type(s) is type(''):
+        if type(s) is str:
             return s
 
         if s >= 1048576.0:

Modified: Zope/branches/2.13/src/App/ImageFile.py
===================================================================
--- Zope/branches/2.13/src/App/ImageFile.py	2011-07-18 21:19:27 UTC (rev 122285)
+++ Zope/branches/2.13/src/App/ImageFile.py	2011-07-18 22:36:19 UTC (rev 122286)
@@ -52,7 +52,7 @@
             _prefix=getattr(getConfiguration(), 'softwarehome', None) or PREFIX
             if not os.path.isabs(path):
                 warnings.warn(NON_PREFIX_WARNING, UserWarning, 2)
-        elif type(_prefix) is not type(''):
+        elif type(_prefix) is not str:
             _prefix=package_home(_prefix)
         # _prefix is ignored if path is absolute
         path = os.path.join(_prefix, path)

Modified: Zope/branches/2.13/src/App/special_dtml.py
===================================================================
--- Zope/branches/2.13/src/App/special_dtml.py	2011-07-18 21:19:27 UTC (rev 122285)
+++ Zope/branches/2.13/src/App/special_dtml.py	2011-07-18 22:36:19 UTC (rev 122286)
@@ -41,7 +41,7 @@
     def __init__(self, name, _prefix=None, **kw):
         if _prefix is None:
             _prefix = getattr(getConfiguration(), 'softwarehome', PREFIX)
-        elif type(_prefix) is not type(''):
+        elif type(_prefix) is not str:
             _prefix = Common.package_home(_prefix)
         args=(self, os.path.join(_prefix, name + '.dtml'))
         if '__name__' not in kw:

Modified: Zope/branches/2.13/src/OFS/Application.py
===================================================================
--- Zope/branches/2.13/src/OFS/Application.py	2011-07-18 21:19:27 UTC (rev 122285)
+++ Zope/branches/2.13/src/OFS/Application.py	2011-07-18 22:36:19 UTC (rev 122286)
@@ -587,7 +587,7 @@
     path_join=os.path.join
     isdir=os.path.isdir
     exists=os.path.exists
-    _st=type('')
+    _st=str
     global_dict=globals()
     silly=('__doc__',)
     modules=sys.modules

Modified: Zope/branches/2.13/src/OFS/CopySupport.py
===================================================================
--- Zope/branches/2.13/src/OFS/CopySupport.py	2011-07-18 21:19:27 UTC (rev 122285)
+++ Zope/branches/2.13/src/OFS/CopySupport.py	2011-07-18 22:36:19 UTC (rev 122286)
@@ -102,7 +102,7 @@
         elif ids is None:
             raise ValueError('ids must be specified')
 
-        if type(ids) is type(''):
+        if type(ids) is str:
             ids=[ids]
         oblist=[]
         for id in ids:
@@ -133,7 +133,7 @@
         elif ids is None:
             raise ValueError('ids must be specified')
 
-        if type(ids) is type(''):
+        if type(ids) is str:
             ids=[ids]
         oblist=[]
         for id in ids:

Modified: Zope/branches/2.13/src/OFS/DTMLDocument.py
===================================================================
--- Zope/branches/2.13/src/OFS/DTMLDocument.py	2011-07-18 21:19:27 UTC (rev 122285)
+++ Zope/branches/2.13/src/OFS/DTMLDocument.py	2011-07-18 22:36:19 UTC (rev 122286)
@@ -59,7 +59,7 @@
             raise ResourceLockedError(
                 'This document has been locked via WebDAV.')
 
-        if type(file) is not type(''):
+        if type(file) is not str:
             if REQUEST and not file:
                 raise ValueError, 'No file specified'
             file = file.read()
@@ -103,7 +103,7 @@
                 return result
 
             r = apply(HTML.__call__, (self, (client, bself), REQUEST), kw)
-            if type(r) is not type('') or RESPONSE is None:
+            if type(r) is not str or RESPONSE is None:
                 if not self._cache_namespace_keys:
                     self.ZCacheable_set(r)
                 return r
@@ -143,7 +143,7 @@
     """Add a DTML Document object with the contents of file. If
     'file' is empty, default document text is used.
     """
-    if type(file) is not type(''):
+    if type(file) is not str:
         file = file.read()
     if not file:
         file = default_dd_html

Modified: Zope/branches/2.13/src/OFS/DTMLMethod.py
===================================================================
--- Zope/branches/2.13/src/OFS/DTMLMethod.py	2011-07-18 21:19:27 UTC (rev 122285)
+++ Zope/branches/2.13/src/OFS/DTMLMethod.py	2011-07-18 22:36:19 UTC (rev 122286)
@@ -144,7 +144,7 @@
                 return result
 
             r = apply(HTML.__call__, (self, client, REQUEST), kw)
-            if type(r) is not type('') or RESPONSE is None:
+            if type(r) is not str or RESPONSE is None:
                 if not self._cache_namespace_keys:
                     self.ZCacheable_set(r)
                 return r
@@ -305,7 +305,7 @@
         if self.wl_isLocked():
             raise ResourceLockedError('This DTML Method is locked via WebDAV')
 
-        if type(file) is not type(''):
+        if type(file) is not str:
             if REQUEST and not file:
                 raise ValueError('No file specified')
             file = file.read()
@@ -459,7 +459,7 @@
     """Add a DTML Method object with the contents of file. If
     'file' is empty, default document text is used.
     """
-    if type(file) is not type(''):
+    if type(file) is not str:
         file = file.read()
     if not file:
         file = default_dm_html

Modified: Zope/branches/2.13/src/OFS/ObjectManager.py
===================================================================
--- Zope/branches/2.13/src/OFS/ObjectManager.py	2011-07-18 21:19:27 UTC (rev 122285)
+++ Zope/branches/2.13/src/OFS/ObjectManager.py	2011-07-18 22:36:19 UTC (rev 122286)
@@ -411,7 +411,7 @@
         # If 'spec' is specified, returns objects whose meta_type
         # matches 'spec'.
         if spec is not None:
-            if type(spec)==type('s'):
+            if type(spec) is str:
                 spec=[spec]
             set=[]
             for ob in self._objects:
@@ -471,7 +471,7 @@
     def superValues(self, t):
         # Return all of the objects of a given type located in
         # this object and containing objects.
-        if type(t)==type('s'): t=(t,)
+        if type(t) is str: t=(t,)
         obj=self
         seen={}
         vals=[]
@@ -507,7 +507,7 @@
 
         The objects specified in 'ids' get deleted.
         """
-        if type(ids) is type(''): ids=[ids]
+        if type(ids) is str: ids=[ids]
         if not ids:
             return MessageDialog(title='No items specified',
                    message='No items were specified!',

Modified: Zope/branches/2.13/src/OFS/PropertyManager.py
===================================================================
--- Zope/branches/2.13/src/OFS/PropertyManager.py	2011-07-18 21:19:27 UTC (rev 122285)
+++ Zope/branches/2.13/src/OFS/PropertyManager.py	2011-07-18 22:36:19 UTC (rev 122286)
@@ -202,7 +202,7 @@
         self._wrapperCheck(value)
         if not self.hasProperty(id):
             raise BadRequest, 'The property %s does not exist' % escape(id)
-        if type(value)==type(''):
+        if type(value) is str:
             proptype=self.getPropertyType(id) or 'string'
             if proptype in type_converters:
                 value=type_converters[proptype](value)

Modified: Zope/branches/2.13/src/OFS/PropertySheets.py
===================================================================
--- Zope/branches/2.13/src/OFS/PropertySheets.py	2011-07-18 21:19:27 UTC (rev 122285)
+++ Zope/branches/2.13/src/OFS/PropertySheets.py	2011-07-18 22:36:19 UTC (rev 122286)
@@ -231,7 +231,7 @@
         propinfo=self.propertyInfo(id)
         if not 'w' in propinfo.get('mode', 'wd'):
             raise BadRequest, '%s cannot be changed.' % escape(id)
-        if type(value)==type(''):
+        if type(value) is str:
             proptype=propinfo.get('type', 'string')
             if proptype in type_converters:
                 value=type_converters[proptype](value)

Modified: Zope/branches/2.13/src/OFS/SimpleItem.py
===================================================================
--- Zope/branches/2.13/src/OFS/SimpleItem.py	2011-07-18 21:19:27 UTC (rev 122285)
+++ Zope/branches/2.13/src/OFS/SimpleItem.py	2011-07-18 22:36:19 UTC (rev 122286)
@@ -189,9 +189,9 @@
             # allow for a few different traceback options
             if tb is None and error_tb is None:
                 tb=sys.exc_info()[2]
-            if type(tb) is not type('') and (error_tb is None):
+            if type(tb) is not str and (error_tb is None):
                 error_tb = pretty_tb(error_type, error_value, tb)
-            elif type(tb) is type('') and not error_tb:
+            elif type(tb) is str and not error_tb:
                 error_tb = tb
 
             if hasattr(self, '_v_eek'):

Modified: Zope/branches/2.13/src/Products/Sessions/BrowserIdManager.py
===================================================================
--- Zope/branches/2.13/src/Products/Sessions/BrowserIdManager.py	2011-07-18 21:19:27 UTC (rev 122285)
+++ Zope/branches/2.13/src/Products/Sessions/BrowserIdManager.py	2011-07-18 22:36:19 UTC (rev 122286)
@@ -264,7 +264,7 @@
 
         o Enforce "valid" values.
         """
-        if not (type(k) is type('') and k and not badidnamecharsin(k)):
+        if not (type(k) is str and k and not badidnamecharsin(k)):
             raise BrowserIdManagerErr(
                             'Bad id name string %s' % escape(repr(k)))
         self.browserid_name = k
@@ -288,7 +288,7 @@
     security.declareProtected(CHANGE_IDMGR_PERM, 'setCookiePath')
     def setCookiePath(self, path=''):
         """ sets cookie 'path' element for id cookie """
-        if not (type(path) is type('') and not badcookiecharsin(path)):
+        if not (type(path) is str and not badcookiecharsin(path)):
             raise BrowserIdManagerErr(
                             'Bad cookie path %s' % escape(repr(path)))
         self.cookie_path = path
@@ -315,7 +315,7 @@
     security.declareProtected(CHANGE_IDMGR_PERM, 'setCookieDomain')
     def setCookieDomain(self, domain):
         """ sets cookie 'domain' element for id cookie """
-        if type(domain) is not type(''):
+        if type(domain) is not str:
             raise BrowserIdManagerErr(
                             'Cookie domain must be string: %s'
                                 % escape(repr(domain)))

Modified: Zope/branches/2.13/src/Products/Sessions/SessionDataManager.py
===================================================================
--- Zope/branches/2.13/src/Products/Sessions/SessionDataManager.py	2011-07-18 21:19:27 UTC (rev 122285)
+++ Zope/branches/2.13/src/Products/Sessions/SessionDataManager.py	2011-07-18 22:36:19 UTC (rev 122286)
@@ -158,7 +158,7 @@
         """ """
         if not path:
             self.obpath = None # undefined state
-        elif type(path) is type(''):
+        elif type(path) is str:
             if bad_path_chars_in(path):
                 raise SessionDataManagerErr(
                     'Container path contains characters invalid in a Zope '

Modified: Zope/branches/2.13/src/ZPublisher/HTTPRequest.py
===================================================================
--- Zope/branches/2.13/src/ZPublisher/HTTPRequest.py	2011-07-18 21:19:27 UTC (rev 122285)
+++ Zope/branches/2.13/src/ZPublisher/HTTPRequest.py	2011-07-18 22:36:19 UTC (rev 122286)
@@ -222,7 +222,7 @@
     def setVirtualRoot(self, path, hard=0):
         """ Treat the current publishing object as a VirtualRoot """
         other = self.other
-        if isinstance(path, str) or isinstance(path, unicode):
+        if isinstance(path, basestring):
             path = path.split('/')
         self._script[:] = map(quote, filter(None, path))
         del self._steps[:]
@@ -241,7 +241,7 @@
 
     def physicalPathToVirtualPath(self, path):
         """ Remove the path to the VirtualRoot from a physical path """
-        if type(path) is type(''):
+        if isinstance(path, basestring):
             path = path.split( '/')
         rpp = self.other.get('VirtualRootPhysicalPath', ('',))
         i = 0

Modified: Zope/branches/2.13/src/ZServer/HTTPResponse.py
===================================================================
--- Zope/branches/2.13/src/ZServer/HTTPResponse.py	2011-07-18 21:19:27 UTC (rev 122285)
+++ Zope/branches/2.13/src/ZServer/HTTPResponse.py	2011-07-18 22:36:19 UTC (rev 122286)
@@ -163,7 +163,7 @@
         """
 
 
-        if type(data) != type(''):
+        if type(data) is not str:
             raise TypeError('Value must be a string')
 
         stdout = self.stdout
@@ -174,7 +174,7 @@
             l = self.headers.get('content-length', None)
             if l is not None:
                 try:
-                    if type(l) is type(''): l = int(l)
+                    if type(l) is str: l = int(l)
                     if l > 128000:
                         self._tempfile = tempfile.TemporaryFile()
                         self._templock = thread.allocate_lock()



More information about the checkins mailing list