PATCH: Re: [Zope] Object history: need last editor
Andy McKay
andy@agmweb.ca
Thu, 15 Aug 2002 23:51:51 -0700
You could call undoable transactions. Here's how to do it as a Script
(Python) where "Test" is the object:
obj = context.Test
t = obj.undoable_transactions()
if t: print t[0]['user_name']
else: print "Unknown"
return printed
--
Andy McKay
Agmweb Consulting
http://www.agmweb.ca
----- Original Message -----
From: "Michael S. Fischer" <michael@dynamine.net>
To: "Michael S. Fischer" <michael@dynamine.net>
Cc: <zope@zope.org>
Sent: Thursday, August 15, 2002 10:05 PM
Subject: PATCH: Re: [Zope] Object history: need last editor
> 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
>
> _______________________________________________
> Zope maillist - Zope@zope.org
> http://lists.zope.org/mailman/listinfo/zope
> ** No cross posts or HTML encoding! **
> (Related lists -
> http://lists.zope.org/mailman/listinfo/zope-announce
> http://lists.zope.org/mailman/listinfo/zope-dev )
>