[ZCM] [ZC] 1726/ 3 Comment "Undo log shows transactions in the
wrong folder"
Collector: Zope Bugs, Features,
and Patches ...
zope-coders-admin at zope.org
Tue Aug 9 16:02:25 EDT 2005
Issue #1726 Update (Comment) "Undo log shows transactions in the wrong folder"
Status Resolved, Zope/bug+solution low
To followup, visit:
http://www.zope.org/Collectors/Zope/1726
==============================================================
= Comment - Entry #3 by Witsch on Aug 9, 2005 4:02 pm
Uploaded: "zopeundo.diff"
- http://www.zope.org/Collectors/Zope/1726/zopeundo.diff/view
imho the patch introduced in 2.7.6-final is not quite right,
since it fails to compare prefixed user names (as returned by
the various undoLog functions) correctly.
users created within a portal are prefixed by their portal's id,
though seperated by a space. however, ZopeUndo/Prefix.py as
shipped with 2.7.6 only supports slashes as delimiter. this in
turn causes 'undoable_transactions' (App/Undo.py:61) to always
return an empty list for "prefixed" users, rendering cmf's and
plone's undo_form effectively useless.
the following definition for __cmp__ (using the old 2.7.5 version
as a basis) solves the problem for me:
> def __cmp__(self, o):
> l, v = self.value
> rest = o[l:]
> if rest and rest[0] not in ' /':
> return -1
> rval = cmp(o[:l], v)
> return rval
the full patch to ZopeUndo along with some additional tests
is attached.
________________________________________
= Resolve - Entry #2 by slinkp on Mar 30, 2005 2:46 am
Status: Accepted => Resolved
Fixed in svn on the slinkp_1726_zopeundo branch, and merged to the trunk; also copied to the 2_7 branch in CVS.
________________________________________
= 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