<br>First of all. Thanx for the help!!! The internet is just fantastic!!<br><br>I like the wrapper approach.<br><br>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 <br>
<br>'NoneType' object has no attribute 'addCallback'<br><br>"addCallback" seems to be implemented in defer.py, but im unsure on how to handle that in the wrapper?<br><br>Kind regards<br><br>/Tax <br>
<br>P.S:<br>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.<br>
<br>
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.<br>
<br>
As you might have guessed, Im building a gateway system for a small set of apartments. Requirements are:<br>
<br>
invalid domains should go to a shop<br>
valid domains should be redirected to the shop if the client have not paid, except if the query is for paypal.<br>
<br><br><br><br><br><div class="gmail_quote">2009/10/25 <span dir="ltr"><<a href="mailto:exarkun@twistedmatrix.com">exarkun@twistedmatrix.com</a>></span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="im">On 24 Oct, 08:04 pm, <a href="mailto:jesper@taxboel.dk">jesper@taxboel.dk</a> wrote:<br>
>Im looking at the common.py and I feel a bit confused about how to wrap<br>
>a<br>
>resolver.<br>
><br>
>Would'nt a subclass achieve the same thing. I would only need to<br>
>implement<br>
>the changed functions in the subclass.<br>
><br>
>I guess my problem is that I dont exactly know how to write a wrapper<br>
>in<br>
>python.<br>
<br>
</div>There's nothing special to it. Just do the obvious thing:<br>
<br>
class SomeWrapper:<br>
def __init__(self, wrapee):<br>
self.wrapee = wrapee<br>
<br>
def someMethod(self, args):<br>
do something with self.wrapee.someMethod and args<br>
<br>
common.py will show you all the methods that a resolver is expected to<br>
have. Subclassing ResolverBase might help, though it's unfortunate that<br>
it works by demultiplexing everything to "_lookup", a private method<br>
that Twisted's compatibility policy doesn't guarantee will continue to<br>
operate as it presently does.<br>
<br>
Wrapping (ie "containment" or "has-a") is just an alternative<br>
implementation strategy to subclassing (ie "inheritance" or "is-a").<br>
Generally it's a better approach for various reasons, none of which are<br>
really specific to Twisted.<br>
<div><div></div><div class="h5"><br>
Jean-Paul<br>
<br>
_______________________________________________<br>
Twisted-Python mailing list<br>
<a href="mailto:Twisted-Python@twistedmatrix.com">Twisted-Python@twistedmatrix.com</a><br>
<a href="http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python" target="_blank">http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python</a><br>
</div></div></blockquote></div><br>