[Twisted-Python] How can I change the default behaviour?
Leslie Huyan
leslie at exoweb.net
Sun May 8 23:28:11 EDT 2005
Hi:
That's reasonable, I put them in a single method and it works. So I
should make my methods to fit for the default behaviour rather than
change it. (one result pass to be next args)
Thank you.
leslie
Christopher Armstrong wrote:
>For this particular example, I would suggest just putting them in a
>single method, since request.write doesn't return a Deferred and you
>don't need to wait for anything before doing the setHeader.
>
>def gotResult(html):
> request.write(html)
> request.setHeader(key, value)
>d.addCallback(gotResult)
>
>In the general case, though, you can do something like
>
>def gotResult(r):
> request.write(r)
> return r
>d.addCallback(gotResult)
>d.addCallback(anotherCallback)
>
>On 5/9/05, Leslie Huyan <leslie at exoweb.net> wrote:
>
>
>>Hi:
>> I encountered one problem to dig into twisted.
>> If I have 2 methods in the call back chain, however I don't want the
>>result of the first one to pass to the second one as its arguments, what
>>should I do?
>> For example:
>> defer.addCallbacks(request.write, html)
>> defer.addCallbacks(request.setHeader, key, value)
>>
>>Thank you.
>>
>>
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://twistedmatrix.com/pipermail/twisted-python/attachments/20050509/08796464/attachment.htm
More information about the Twisted-Python
mailing list