<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>&#39;NoneType&#39; object has no attribute &#39;addCallback&#39;<br><br>&quot;addCallback&quot; 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">&lt;<a href="mailto:exarkun@twistedmatrix.com">exarkun@twistedmatrix.com</a>&gt;</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>
&gt;Im looking at the common.py and I feel a bit confused about how to wrap<br>
&gt;a<br>
&gt;resolver.<br>
&gt;<br>
&gt;Would&#39;nt a subclass achieve the same thing. I would only need to<br>
&gt;implement<br>
&gt;the changed functions in the subclass.<br>
&gt;<br>
&gt;I guess my problem is that I dont exactly know how to write a wrapper<br>
&gt;in<br>
&gt;python.<br>
<br>
</div>There&#39;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&#39;s unfortunate that<br>
it works by demultiplexing everything to &quot;_lookup&quot;, a private method<br>
that Twisted&#39;s compatibility policy doesn&#39;t guarantee will continue to<br>
operate as it presently does.<br>
<br>
Wrapping (ie &quot;containment&quot; or &quot;has-a&quot;) is just an alternative<br>
implementation strategy to subclassing (ie &quot;inheritance&quot; or &quot;is-a&quot;).<br>
Generally it&#39;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>