[Zope-dev] Overriding __getattr__ for requests only.

Jim Fulton jim@digicool.com
Mon, 22 Nov 1999 09:16:55 -0500


"Jeff K. Hoffman" wrote:
> 
> On Fri, 12 Nov 1999, Christopher Petrilli wrote:
> 
> > On 11/12/99 3:57 PM, Jeff K. Hoffman at jkhoffman@carolina.rr.com wrote:
> >
> > > I am trying to write a new subclass of OFS.Folder (as a python product) to
> > > do the following: When a user requests /myFolder/index_html, myFolder
> > > will search itself, then its list of 'parents', returning the attribute
> > > from one of them if they have it, and raising an AttributeError if not.
> >
> > Pardon my ignorance, but what exactly does this accomplish that isn't
> > accomplished by Acquisition?
> 
> I am trying to build a site as follows:
> 
> ---
> /
>   baseline/
>     index_html
>     content/
>       paragraph_a
>       paragraph_b
>     images/
>       image_a
>       image_b
>     variant1/
>       content/
>         paragraph_a
>       images/
>         image_b
>     variant2/
>       content/
>         paragraph_b
>       images/
>         image_a
> ---
> 
> Such that navigating to /baseline/index_html shows paragraph_a,
> paragraph_b, image_a, and image_b. I also need to be able to navigate to
> /baseline/variant1 and see the same index_html, this time referencing the
> "overloaded" paragraph_a and image_b. The same for variant2, with
> paragraph_b and image_a.
> 
> I have found no obvious way to do this, using acquisition, without
> flatting my folder hierarchy out as such:

(snip)
 
> This is unacceptable, because there are a LOT of paragraph's and images,
> and I want to divide them up logically using folders.

Interesting. The organizational approach you've taken defeats acquisition.
I'll have to think about this (and decide if I care :).
 
> I am evaluating Zope in the hopes of transitioning one of our major web
> assets (which is currently built on top of our proprietary web development
> platform, which supports inheritance) to Zope and dropping development on
> our platform. I am finding it hard to move from an inheritance based model
> to a purely acquisition based model without making major sacrifices in the
> design of our site.

Zope supports both acquisition and inheritence. Have you looked at ZClasses?

ZClasses were introduced specifically to provide inheritence.  We didn't
provide inheritence originally, because we thought it was beyond "content-
managers", which were the target audience of Principia, the predecessor of 
Zope.  We found, however, that alot of people were mis-using acquisition
to achieve the effects of inheritence.
 
> Am I stupid?

No. :)

> Please tell me I'm missing something obvious.

I think ZClasses will give you what you want.

Jim

--
Jim Fulton           mailto:jim@digicool.com   Python Powered!        
Technical Director   (888) 344-4332            http://www.python.org  
Digital Creations    http://www.digicool.com   http://www.zope.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.