[Zope] Accessing Zope Object properties
hans
hans@beehive.de
Wed, 29 May 2002 14:42:04 +0100
Kirk Lowery wrote:
> hans wrote:
> > Kirk Lowery wrote:
> >>hans wrote:
> >>>Kirk Lowery wrote:
> >>>
> >>>
> >>>
> >>>>I want to put a "Last edited on <Zope Object modification date>" in a
> >>>>footer, so that I don't have to think about manually changing the date
> >>>>all the time. I've looked through the docs, but I can't find (or
> >>>>recognize) what I need.
> >>>>
> >>>>And it raises the general question: how do I discover and access the
> >>>>properties of any arbitrary Zope object for binding to variables,
> >>>>manipulation, etc.?
> >>>
> >>>
> >>>http://www.dieter.handshake.de/pyprojects/zope/DocFinder.html
> >>>http://www.zope.org/Members/shh/DocFinderEverywhere/
> >>>
> >>>
> >>
> >>This Product is very cool. Thanks!
> >>
> >>Now...er...one further problem, which is a typical Zope newbie question,
> >>I'm sure. When I use "<dtml-var bobobase_modification_time>", it's
> >>rendered with the top-level container's modification time, which isn't
> >>the same as the lower-level object. So I'm caught by container
> >>inheritance. How do I override this, something like "self modification
> >>time"?
> >
> >
> > Well, I'm rather unfamiliar with bobobase_modification_time,
> > and a wild guess is that its one of the properties of (?unsure) SimpleItem
> > or any of its base classes.
> > So, every object in the ZODB should have one.
> > that means <dtml-var "myObject.bobobase_modification_time()">
> > should give you the objects time.
> > (DTML resolves names w the namespace "_", seems the first object
> > encountered w nameresolution for bobobase_~ is your root folder).
> >
> > How would I try to solve those riddles:
> > Hunting with a systemsearch search (grep for unix, explorer/search for win)
> > through your zope instance for files containing "def
> > bobobase_modification_time",
> > shows just/lib/python/App/PersistentExtra.py in a class PersistemtUtil.
> > Inspecting this tells that its concerned with persistence (_p_*),
> > ie every persistent object should have a property _p_mtime which bobobase_~
> > And somehow zodbobjects should inherit bobobase_~
> > How would I try to solve those riddles:
> > a) hunt through the sources, sorry,
> > often leads you in a maze of twisty little passages,
> > code w 1-letter identifiers (real prgrammers do assembler in any lang),
> > requires familiarity w python (beazly recommended)
> > b) search mailing list archives for bobobase_~
> > c) search zope.org for bobobase_~
>
> Ok, I have it working, although not *just* the way I'd like it.
> Following your suggestion, if I insert the following code everywhere:
>
> <i>Last edited on <dtml-var
> "[ZopeObjectID].bobobase_modification_time()"></i>
>
> Then every object displays it's own modification time. So this works.
> But it would be more elegant if I could put in a "standard_html_footer"
> a namespace which refers to the current object being published, and just
> write the code once, rather than in *every* object in the tree that I
> want the attribute displayed....
well then, usually "standard_html_footer" is a DTML Method,
which works in the context of the caller.
maybe
<dtml-var "this().bobobase_modification_time()">
?
For this(), see http://www.zope.org/Documentation/ZopeBook/AppendixB.stx,
module ObjectManagerItem
class ObjectManagerItem
For info propagation up to the parent folder (might be overkill for you)
something in that direction is
http://www.zope.org/Members/ivo/QuotaFolder
-------------------------------------------------------------
Who's got only a hammer sees the world as a nail
hans augustin (software developer) hans@beehive.de
beehive elektronische medien GmbH http://www.beehive.de
phone: +49 30 847-82 0 fax: +49 30 847-82 299