[Zope-dev] Odd behavior of undoable_transactions()

Paul Winkler pw_lists at slinkp.com
Thu Mar 10 17:45:42 EST 2005


Is anyone but me bothered by this behavior of undoable_transactions()?
If I have a folder /foo and another folder /foobar,
transactions for /foobar are displayed in 
foo.undoable_transactions().

This is clearly caused by lib/python/ZopeUndo/Prefix.py.
The behavior matches the docstring - Prefix only cares
if one string starts with the other, nothing more.
But is that really desirable?
Since this is intended purely for use in Zope, wouldn't it
be more useful if it cared about paths as such?

Something like (untested):

class PathPrefix:
    """A PathPrefix() is equal to any path string it is a prefix of.

    Two prefixes can not be compared.
    """

    __no_side_effects__ = 1 # what's this mean anyway?

    def __init__(self, path):
        path_as_list = path.split('/')
        self.length = len(path_as_list)
        self.path = path_as_list

    def __cmp__(self, o):
        other_path = o.split('/')
        rval = cmp(other[:self.length], self.path)
        return rval


-- 

Paul Winkler
http://www.slinkp.com


More information about the Zope-Dev mailing list