[Zope3-checkins] SVN: Zope3/branches/Zope-3.1/src/zope/app/undo/__init__.py Prefix must be subclassed from the unicode

Dmitry Vasiliev dima at hlabs.spb.ru
Sat Jul 30 15:19:03 EDT 2005


Log message for revision 37606:
  Prefix must be subclassed from the unicode
  

Changed:
  U   Zope3/branches/Zope-3.1/src/zope/app/undo/__init__.py

-=-
Modified: Zope3/branches/Zope-3.1/src/zope/app/undo/__init__.py
===================================================================
--- Zope3/branches/Zope-3.1/src/zope/app/undo/__init__.py	2005-07-30 19:14:27 UTC (rev 37605)
+++ Zope3/branches/Zope-3.1/src/zope/app/undo/__init__.py	2005-07-30 19:19:03 UTC (rev 37606)
@@ -35,12 +35,13 @@
 zope.deprecation.__show__.on()
 import warnings
 
+
 def undoSetup(event):
     # setup undo functionality
     sm = zapi.getGlobalSiteManager()
     sm.provideUtility(IUndoManager, ZODBUndoManager(event.database))
 
-class Prefix(str):
+class Prefix(unicode):
     """A prefix is equal to any string it is a prefix of.
 
     This class can be compared to a string (or arbitrary sequence).
@@ -90,10 +91,9 @@
     False
     """
     def __eq__(self, other):
-        if not other:
-            return False
-        length = len(self)
-        return str(other[:length]).__eq__(self)
+        if other and unicode(other[:len(self)]).__cmp__(self) == 0:
+            return True
+        return False
 
     def __ne__(self, other):
         return not self.__eq__(other)
@@ -113,7 +113,7 @@
                                  first=0, last=-20):
         """See zope.app.undo.interfaces.IPrincipal"""
         if not IPrincipal.providedBy(principal):
-            raise TypeError, "Invalid principal: %s" % principal        
+            raise TypeError, "Invalid principal: %s" % principal
         return self._getUndoInfo(context, principal, first, last)
 
     def _getUndoInfo(self, context, principal, first, last):
@@ -167,7 +167,6 @@
                         "be raised instead."
                         % principalRegistry.__class__.__name__,
                         DeprecationWarning)
-                    
         return entries
 
     def undoTransactions(self, ids):



More information about the Zope3-Checkins mailing list