On Thu, Jan 04, 2001 at 10:46:35AM +0000, Chris Withers wrote:
Dieter Maurer wrote:
acquisition.donotacquire('index_html')
This would be great.
Indeed :-)
class MyClass (Acquisition.Explicit):
acquisition = ClassAcquisitionInfo()
acquisition.acquire('index_html') acquisition.acquire('fred') You already can do that, though with a different syntax (I would need to search for in the documentation).
You may mean that if x is an Acquisition.Explicit object, you can do:
x.aq_acquire('your_attribute') (syntax may be wrong ;-)
What I meant is that through a declaration in the class you could saying acquire the 'your_attribute' attribute but nothing else. So, you could still do:
x.your_attribute ...which would be acquired, but... x.index_html ...which wouldn't be acquired.
You could use ComputedAttribute for that: class MyClass(Acquisition.Explicit): # The following attribute is acquired transparently def _acquired_your_attribute(self): return self.aq_acquire('your_attribute') your_attribute = ComputedAttribute(_acquired_your_attribute, 1) # index_html isn't index_html = None Or you could define a __getattr__ that does a lookup in a list for explicetly acquired attributes: _acquired = ('index_html', 'fred') def __getitem__(self, key): if key in self._acquired: return self.aq_acquire(key) raise AttributeError, name -- Martijn Pieters | Software Engineer mailto:mj@digicool.com | Digital Creations http://www.digicool.com/ | Creators of Zope http://www.zope.org/ ---------------------------------------------