[ZCM] [ZC] 1726/ 1 Request "Undo log shows transactions in the wrong folder"

Collector: Zope Bugs, Features, and Patches ... zope-coders-admin at zope.org
Tue Mar 15 14:43:38 EST 2005


Issue #1726 Update (Request) "Undo log shows transactions in the wrong folder"
 Status Accepted, Zope/bug+solution low
To followup, visit:
  http://www.zope.org/Collectors/Zope/1726

==============================================================
= Request - Entry #1 by slinkp on Mar 15, 2005 2:43 pm

 Status: Pending => Accepted

 Supporters added: slinkp

If I have a folder /foo and another folder /foobar,                             
transactions for /foobar are displayed in                                       
foo.undoable_transactions(). 

This is almost certainly caused by lib/python/ZopeUndo/Prefix.py.                        
Prefix only cares if one string starts with the other, nothing more.
But this is intended purely for use in Zope, and we really care about paths, not raw strings.

Something like (untested):                                                      
                                                                                
>class Prefix:                                                               
>    """A Prefix() 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, other):                                                       
>        other_path = other.split('/')                                               
>        return cmp(other_path[:self.length], self.path)

If there are no objections, I'll write tests and check it in on the trunk (svn) and then backport to the 2_7 branch in cvs.
==============================================================



More information about the Zope-Collector-Monitor mailing list