First of all. Thanx for the help!!! The internet is just fantastic!! I like the wrapper approach.
I had not thought of that approach myself. Sounds very reasonable. -So I started wrapping Resolver, but got stuck pretty fast. I get a problem saying that 'NoneType' object has no attribute 'addCallback' "addCallback" seems to be implemented in defer.py, but im unsure on how to handle that in the wrapper? Kind regards /Tax P.S: As a side question: In my old hack approach, which I have had almost working, I have had problems constructing valid DNS answers. Wold you happen to know what requirements there is to the returning package, to be accepted. I made some attempts by using pickle to capture live packages, but have a hard time tweaking other values than the address. Ideally I would like to pass on a very short TTL, so the client would not be bothered by fake DNS when I turn the system off. As you might have guessed, Im building a gateway system for a small set of apartments. Requirements are: invalid domains should go to a shop valid domains should be redirected to the shop if the client have not paid, except if the query is for paypal. 2009/10/25 <[email protected]> > On 24 Oct, 08:04 pm, [email protected] 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 > > _______________________________________________ > Twisted-Python mailing list > [email protected] > http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python >
_______________________________________________ Twisted-Python mailing list [email protected] http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
