Make a wish: return Deferred from a WSGI request

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Make a wish: return Deferred from a WSGI request

Iap-3
Hi,

The TwistedGateway accept the expose method to return a Deferred instance.
But the TwistedGateway can not work with twisted.web2.
On the other hand. The WSGIGateway can work with twisted.web2,
but it does not accept the Deferred instance as the returned value.

Which one can I wish:
1) The TwistedGateway to work with web2
2) The WSGIGateway accept the Deferred instance as the returned value
just as the TwistedGateway does?
Or both :)

The reason to use with web2 is because that web2 works better with Django.
The parameters together with a "POST" request can be passed to the
Django through twisted.web2 wsgi implementation.
The twisted.web+Django only works for the "GET" request.

Any suggestion is welcomed.
_______________________________________________
PyAMF users mailing list - [hidden email]
http://lists.pyamf.org/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

Re: Make a wish: return Deferred from a WSGI request

Nick Joyce
Hi,

There is a couple reasons why this hasn't been implemented.

1) The WSGI Spec (at least 1.0) does not allow for asynchronous  
responses.
2) Twisted supports WSGI out of the box - see twisted.web.wsgi
3) twisted.web2 is deprecated and will be removed at some point.

We did do some investigation into this - check http://pyamf.org/ticket/85 
  for more info.

Cheers,

Nick

On 1 Nov 2009, at 12:49, Iap wrote:

> Hi,
>
> The TwistedGateway accept the expose method to return a Deferred  
> instance.
> But the TwistedGateway can not work with twisted.web2.
> On the other hand. The WSGIGateway can work with twisted.web2,
> but it does not accept the Deferred instance as the returned value.
>
> Which one can I wish:
> 1) The TwistedGateway to work with web2
> 2) The WSGIGateway accept the Deferred instance as the returned value
> just as the TwistedGateway does?
> Or both :)
>
> The reason to use with web2 is because that web2 works better with  
> Django.
> The parameters together with a "POST" request can be passed to the
> Django through twisted.web2 wsgi implementation.
> The twisted.web+Django only works for the "GET" request.
>
> Any suggestion is welcomed.
> _______________________________________________
> PyAMF users mailing list - [hidden email]
> http://lists.pyamf.org/mailman/listinfo/users

_______________________________________________
PyAMF users mailing list - [hidden email]
http://lists.pyamf.org/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

Re: Make a wish: return Deferred from a WSGI request

Iap-3
Hi,
I have surveyed the combination of  the 3 super stars in the world of
Python: "Twisted+Django+pyAMF" for several days.
Because the Django lacks the ability to accept a returned Deferred,
That's the reason the Twisted comes into play.
For long running request, Deferred is a good solution.
Plus, I have no other choice if other funtion returns a Deferred.
Examples like the database connection pool of Twisted.
For all the requests (includes the requests to the pyAMF) which make
calls to the database via the connection pool,
There is no other way to get thing to go without the Deferred.

The perfect combination with current available solution is:

1) WSGI from Twisted.web2 to work with Django.
The reason is that WSGI of Twisted.web does not pass through POST request.
(I thougt that I have followed all the examples I can find from
google,  Maybe I missed something)
Which destroy pratical usage of Django. Stuffs like the
administration, authentication of Django got broken.
WSGI from Twsited.web2 works fine.

2) WSGIGateway of pyAMF is great to work with twisted.web2. Except for
aceepting returned Deferred.

I can understand that web2 will be deprecated someday, But I think
there is only one step to the perfect of today.
The Deferred is not in the standard, that's why the Python/Twisted is so unique,
as well as pyAMF will be unique if it can handle the Deferred too.
No matter how, the pyAMF is great. I do appreciate the works you guys have done.




2009/11/2 Nick Joyce <[hidden email]>:

> Hi,
>
> There is a couple reasons why this hasn't been implemented.
>
> 1) The WSGI Spec (at least 1.0) does not allow for asynchronous responses.
> 2) Twisted supports WSGI out of the box - see twisted.web.wsgi
> 3) twisted.web2 is deprecated and will be removed at some point.
>
> We did do some investigation into this - check
> http://pyamf.org/ticket/85 for more info.
>
> Cheers,
>
> Nick
>
> On 1 Nov 2009, at 12:49, Iap wrote:
>
>> Hi,
>>
>> The TwistedGateway accept the expose method to return a Deferred instance.
>> But the TwistedGateway can not work with twisted.web2.
>> On the other hand. The WSGIGateway can work with twisted.web2,
>> but it does not accept the Deferred instance as the returned value.
>>
>> Which one can I wish:
>> 1) The TwistedGateway to work with web2
>> 2) The WSGIGateway accept the Deferred instance as the returned value
>> just as the TwistedGateway does?
>> Or both :)
>>
>> The reason to use with web2 is because that web2 works better with Django.
>> The parameters together with a "POST" request can be passed to the
>> Django through twisted.web2 wsgi implementation.
>> The twisted.web+Django only works for the "GET" request.
>>
>> Any suggestion is welcomed.
>> _______________________________________________
>> PyAMF users mailing list - [hidden email]
>> http://lists.pyamf.org/mailman/listinfo/users
>
> _______________________________________________
> PyAMF users mailing list - [hidden email]
> http://lists.pyamf.org/mailman/listinfo/users
>
_______________________________________________
PyAMF users mailing list - [hidden email]
http://lists.pyamf.org/mailman/listinfo/users