[Zodb-checkins] CVS: Packages/ZopeUndo - Prefix.py:1.1.66.1

Paul Winkler pw_lists at slinkp.com
Wed Mar 30 02:48:12 EST 2005


Update of /cvs-repository/Packages/ZopeUndo
In directory cvs.zope.org:/tmp/cvs-serv9264/lib/python/ZopeUndo

Modified Files:
      Tag: Zope-2_7-branch
	Prefix.py 
Log Message:
Backported slinkp_1726_zopeundo branch from svn.
Avoid showing transactions in the wrong folder's undo log.


=== Packages/ZopeUndo/Prefix.py 1.1 => 1.1.66.1 ===
--- Packages/ZopeUndo/Prefix.py:1.1	Thu Oct  3 13:41:52 2002
+++ Packages/ZopeUndo/Prefix.py	Wed Mar 30 02:47:42 2005
@@ -4,14 +4,14 @@
 # All Rights Reserved.
 #
 # This software is subject to the provisions of the Zope Public License,
-# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
+# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
 # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
 # FOR A PARTICULAR PURPOSE
 #
 ##############################################################################
-"""ZODB undo support for Zope.
+"""ZODB undo support for Zope2.
 
 This package is used to support the Prefix object that Zope uses for
 undo.  It is a separate package only to aid configuration management.
@@ -20,21 +20,28 @@
 """
 
 class Prefix:
-    """A Prefix() is equal to any string it as a prefix of.
+    """A Prefix() is equal to any path it is a prefix of.
 
-    This class can be compared to a string (or arbitrary sequence).
-    The comparison will return True if the prefix value is a prefix of
-    the string being compared.
 
-    Two prefixes can not be compared.
+    This class can be compared to a string.
+    The comparison will return True if all path elements of the
+    Prefix are found at the beginning of the string being compared.
+
+    Two Prefixes can not be compared.
     """
 
     __no_side_effects__ = 1
 
     def __init__(self, path):
-        self.value = len(path), path
+        path_list = path.split('/')
+        self.length = len(path_list)
+        self.path = path_list
 
     def __cmp__(self, o):
-        l, v = self.value
-        rval = cmp(o[:l], v)
-        return rval
+        other_path = o.split('/')
+        return cmp(other_path[:self.length], self.path)
+
+    def __repr__(self):
+        # makes failing tests easier to read
+        return "Prefix('%s')" % '/'.join(self.path)
+



More information about the Zodb-checkins mailing list