Chris Withers writes:
Dieter Maurer wrote:
You may be successful, if you override "__of__". It is this method that (usually) builds the acquisition wrapper.
When does it not build the wrapper? If it is not the "__of__" defined by "Acquisition.{Im,Ex}plicit", it may not build acquisition wrappers. E.g. the "__of__" of "ComputedAttribute" does not.
The easiest way, of course, is to derive the class from "Acquisition.Explicit" with higher priority (more to the left) than from "Acquisition.Implicit".
Hmmm... then maybe use the acquire() method to get hold of names that can be acquired, in the __getattr__ method? Read the "Acquisition" documentation:
With explicit acquisition, you can declare that some attributes should be acquired implicitly. Of course, you can do it in "__getattr__", too.
There is a more fundamental problem here though; If you limit acquisition to a specified list of names, what do you do about all the stuff Zope normally silently acquires, like the security context, the REQUEST, etc? I expect, that the security context is explicitly acquired (not sure).
For "REQUEST" and some essential other objects, you can declare them to be implicitly acquired.
It would be great if you could make it work along the lines of "acquire all the Zope internal stuff, but beyond that, only acquire if the name is in this list". But how would we define "all the Zope internal stuff" and how would we implement the logic? The first question may have some surprises. The second should not be too difficult.
Hurm... this sounds like a problem of Fultonesque proportions :-S Maybe, we wait a bit. As I heard, DC is thinking about making acquisition explicit rathen than implicit.
Dieter