On 24 Oct, 08:04 pm, jesper@taxboel.dk wrote:
Im looking at the common.py and I feel a bit confused about how to wrap a resolver.
Would'nt a subclass achieve the same thing. I would only need to implement the changed functions in the subclass.
I guess my problem is that I dont exactly know how to write a wrapper in python.
There's nothing special to it. Just do the obvious thing: class SomeWrapper: def __init__(self, wrapee): self.wrapee = wrapee def someMethod(self, args): do something with self.wrapee.someMethod and args common.py will show you all the methods that a resolver is expected to have. Subclassing ResolverBase might help, though it's unfortunate that it works by demultiplexing everything to "_lookup", a private method that Twisted's compatibility policy doesn't guarantee will continue to operate as it presently does. Wrapping (ie "containment" or "has-a") is just an alternative implementation strategy to subclassing (ie "inheritance" or "is-a"). Generally it's a better approach for various reasons, none of which are really specific to Twisted. Jean-Paul