[Twisted-Python] WebWidgets and Deferreds.
![](https://secure.gravatar.com/avatar/e8d7e03b9981c937597d9bf9ef1f704b.jpg?s=120&d=mm&r=g)
Ok, riddle me this, glyph (or anyone else who knows about this). Why do we need Deferreds to be a special-case in WebWidgets? Why can't _all_ widgets be displayed only right when they're needed? RenderSession could just take a Widget, and display() it (and the widgets that display() returns) in order.. Is there some sort of performance issue here, maybe? Maybe I'll try implementing this, and send a patch to be looked at. -- <TomG> I'm in the wrong channel. -- Chris Armstrong <<< radix@twistedmatrix.com >>> http://twistedmatrix.com/users/carmstro.twistd/
![](https://secure.gravatar.com/avatar/e8d7e03b9981c937597d9bf9ef1f704b.jpg?s=120&d=mm&r=g)
On Fri, 2001-11-23 at 16:55, Chris Armstrong wrote:
Well, I've spent some time trying to implement this, but I'm having some problems. Here's a patch. Notice the 'renderSession' (now-module-level) function and the flatWrite function. flatWrite is the _only_ place where display() is called now, and the data is written as soon as it comes to it. There is a problem, however, with a small test I did. I made a widget that returned a list of 3 widgets: widgets.Time(), SleepWidget(), widgets.Time(). The only thing SleepWidget has is a display() method that sleeps for 2 seconds and returns [], to simulate blocking. I try to render this widget with the new system, but I don't get any content until the entire request is finished. I put in some log messages to say exactly when the writes are happening, and the first widgets.Time() is definitely being written to the request before the SleepWidget is being displayed, but i still don't see anything until the entire request is done. *sigh*, I'm sure that I'm completely off-track here. Why do I always try to rewrite everything I come across that I don't understand? (remember explorer, Kevin?) :P -- <dash> the program isn't debugged until the last user is dead -- Chris Armstrong <<< radix@twistedmatrix.com >>> http://twistedmatrix.com/users/carmstro.twistd/
![](https://secure.gravatar.com/avatar/e8d7e03b9981c937597d9bf9ef1f704b.jpg?s=120&d=mm&r=g)
On Fri, 2001-11-23 at 19:05, Chris Armstrong wrote:
Guess what! I was right! I was completely wrong about the point of Deferreds! hooray! :-P So, it seems that the point of Deferreds-in-WebWidgets wasn't just to "process immediately before writing", but to _let the rest of the twisted mainloop run while waiting for a Deferred execution_. Blech. *dorkus*. Nonetheless, that big huge refactoring is still useful. A lot of code (not even including the Deferred-support i got rid of) has been shwacked and replaced by a much simpler system. Now it's time to rewrite the Deferred code from scratch on top of my new refactorings. *Dives into Deferred* -- <radix> yosomono: One of these days, I'm going to actually see what you do <Yosomono> radix: You will turn to stone almost immediately -- Chris Armstrong <<< radix@twistedmatrix.com >>> http://twistedmatrix.com/users/carmstro.twistd/
![](https://secure.gravatar.com/avatar/e8d7e03b9981c937597d9bf9ef1f704b.jpg?s=120&d=mm&r=g)
On Fri, 2001-11-23 at 16:55, Chris Armstrong wrote:
Well, I've spent some time trying to implement this, but I'm having some problems. Here's a patch. Notice the 'renderSession' (now-module-level) function and the flatWrite function. flatWrite is the _only_ place where display() is called now, and the data is written as soon as it comes to it. There is a problem, however, with a small test I did. I made a widget that returned a list of 3 widgets: widgets.Time(), SleepWidget(), widgets.Time(). The only thing SleepWidget has is a display() method that sleeps for 2 seconds and returns [], to simulate blocking. I try to render this widget with the new system, but I don't get any content until the entire request is finished. I put in some log messages to say exactly when the writes are happening, and the first widgets.Time() is definitely being written to the request before the SleepWidget is being displayed, but i still don't see anything until the entire request is done. *sigh*, I'm sure that I'm completely off-track here. Why do I always try to rewrite everything I come across that I don't understand? (remember explorer, Kevin?) :P -- <dash> the program isn't debugged until the last user is dead -- Chris Armstrong <<< radix@twistedmatrix.com >>> http://twistedmatrix.com/users/carmstro.twistd/
![](https://secure.gravatar.com/avatar/e8d7e03b9981c937597d9bf9ef1f704b.jpg?s=120&d=mm&r=g)
On Fri, 2001-11-23 at 19:05, Chris Armstrong wrote:
Guess what! I was right! I was completely wrong about the point of Deferreds! hooray! :-P So, it seems that the point of Deferreds-in-WebWidgets wasn't just to "process immediately before writing", but to _let the rest of the twisted mainloop run while waiting for a Deferred execution_. Blech. *dorkus*. Nonetheless, that big huge refactoring is still useful. A lot of code (not even including the Deferred-support i got rid of) has been shwacked and replaced by a much simpler system. Now it's time to rewrite the Deferred code from scratch on top of my new refactorings. *Dives into Deferred* -- <radix> yosomono: One of these days, I'm going to actually see what you do <Yosomono> radix: You will turn to stone almost immediately -- Chris Armstrong <<< radix@twistedmatrix.com >>> http://twistedmatrix.com/users/carmstro.twistd/
participants (1)
-
Chris Armstrong