PATCH: Re: [Zope] Object history: need last editor
Michael S. Fischer
michael@dynamine.net
Thu, 15 Aug 2002 22:05:46 -0700
On Thu, Aug 15, 2002 at 09:06:14PM -0700, Michael S. Fischer wrote:
> Are there any hooks in the Zope API which can be accessed from a Python
> script to obtain object history information? I want to obtain the last
> editor of an object (as displayed in the History and Undo panels) but I
> can't figure out how to obtain it in Zope 2.5.1. If there's a way, it
> appears to be undocumented.
>
> I took a look at History.py but it looks like the object history is
> stored in an unexposed property.
*hack hack*
Put this in your Extensions folder, under whatever filename you see
fit:
def tpd_last_editor(self):
"""Return the last editor of an object."""
jar=self._p_jar
oid=self._p_oid
if jar is None or oid is None: return None
return jar.db().history(oid)[0]['user_name']
Then, create an External Method to access it.
Good enough for me. With this applied it's now a method of nearly any
Zope object. (In case you're wondering, tpd are my employer's initials;
I figured it'll prevent a namespace collision.)
Zope Developers, feel free to do whatever you want with it. I recommend
making a part of the standard API.
--
Michael S. Fischer / michael at dynamine.net / +1 650-533-4684
Lead Hacketeer, Dynamine Consulting, Silicon Valley, CA