[Zope-dev] Re: Better encapsulation is good...

Brian Lloyd Brian@digicool.com
Fri, 25 Aug 2000 11:28:17 -0400


> > Did you run the Article class through 
> Globals.default__class_init__()?
> > E.g. (at the module level), e.g.:
> > 
> > Globals.default__class_init__(Article)
> > 
> 
> Yes, I tried this too, (saw it in the mailing list archive).

(I'm coming to this late, so ignore me if this is covered 
ground...)

Are you certain that you are not losing the acquistion context 
on your Articles somehow? For example, if you are not doing a 
getattr on the container to get an article, you may need to 
maintain the acquistion chain yourself:

class Article(Acquistion.Implicit):
  ...


class Articles:
  """The container for articles. Note that I dont 
  really contain them though - I get them from a 
  database or something (or create them on the 
  fly)"""

  def getArticle(self, id):
    # we create an Article on the fly, so we have to 
    # "wrap" the object in the context of its container
    # to preserve the acquisition chain (and security 
    # depends on an intact acquisition chain)
    item=Article(id)

    # this is the wrapping!
    return item.__of__(self)


Hope this helps...


Brian Lloyd        brian@digicool.com
Software Engineer  540.371.6909              
Digital Creations  http://www.digicool.com