[XML-SIG] Groves

Jim Fulton jim@digicool.com
Wed, 29 Dec 1999 15:01:47 +0000


Paul Prescod wrote:
> 
> uche.ogbuji@fourthought.com wrote:
> >
> > Paul Prescod:
> >
> > >  * I actually use groves more than the DOM.
> >
> > BTW, do you use the GPS package for your groves?
> 
> No, I used groves long before GPS came about and GPS has one big
> difference from the three implementations I've used in the past. It uses
> item syntax for fetching properties instead of attr syntax. Geir says
> that this is because Zope doesn't like __getattr__ overrides. Nobody has
> had time to do the research necessary to resolve this issue.

Right, __getattr__ is already overridden by Zope.  It might
be possible to use computed attributes to achiev this. This 
is what we plan to do (have done?) in Zope's internal DOM
implementation. If the attribute names are fixed and fetching is
all that's needed, then computed attributes should do the trick:

  from ComputedAttribute import ComputedAttribute
  from Persistence import Persistent

  class Foo(Persistent): # Any ExtensionClass base will do
    # a name attribute that actually uses __name__
    name=ComputedAttribute(lambda self: self.__name__)

I haven't looked at GPS yet :(, but I suspect it uses
acquisition to handle parent links without creating cycles.
If it does, then it wants to use computed attributes that
are acquisition aware:


  from ComputedAttribute import ComputedAttribute
  from Persistence import Persistent
  from Acquisition import Explicit

  class Foo(Persistent, Explicit):
     # a parent attribute that uses self.aq_parent
     parent=ComputedAttribute(
       lambda self: self.aq_parent, # the implementation
       1 # a bit of magic that makes this work with acquisition,
         # Unfortunately, this makes it require acquisition....
       )

Jim

--
Jim Fulton           mailto:jim@digicool.com
Technical Director   (888) 344-4332              Python Powered!
Digital Creations    http://www.digicool.com     http://www.python.org

Under US Code Title 47, Sec.227(b)(1)(C), Sec.227(a)(2)(B) This email
address may not be added to any commercial mail list with out my
permission.  Violation of my privacy with advertising or SPAM will
result in a suit for a MINIMUM of $500 damages/incident, $1500 for
repeats.