[Zope-CMF] DC Metadata aquisition, how to have a child use it's parent's Met adata
Paul Winkler
pw_lists@slinkp.com
Tue, 29 Jul 2003 12:10:36 -0400
On Tue, Jul 29, 2003 at 11:12:33AM -0400, Jean-Francois.Doyon@CCRS.NRCan.gc.ca wrote:
> I was however hoping I could use some automated way of doing this, possibly
> by making use of the DefaultDublinCoreImpl.__dict__ , figuring out the
> "functions" and mapping them to the child class instances ... I've toyed
> wiht this though I'm not sure how I would get the mapping part done properly
> (I can easily figure out the methods declared by the class, just not sure
> how to "merge" them with my own) ...
>
> There's also the possibility of using __getattr__ ... But then I need a way
> of discovering what attributes are managed by the DefaultDublinCoreImpl
> class, which there isn't.
You do not want to override __getattr__ unless you have a nearly
infinite supply of zope zen :-)
If you just mean using getattr(), that's fine...
though it also gets acquired attributes, so getattr(foo.aq_base, 'name')
may be what you want.
When I did something vaguely similar recently, I just defined all
the DublinCore methods to do what I wanted. Tedious, but reliable.
One thing that might help you do something more dynamic:
DefaultDublinCoreImpl defines a method, getMetadataHeaders(),
which tells you all the supported metadata methods.
It returns a tuple of (name, value) for all metadata, e.g.
('Title', 'Some stupid title').
--
Paul Winkler
http://www.slinkp.com
Look! Up in the sky! It's THUNDEROUS ROBOT-CHUCKER!
(random hero from isometric.spaceninja.com)