Re: [Twisted-Python] Noob alert - Looking for a framework for creating a long polling service

2010-04-01 Thread Werner Thie
Hi,

I'm a long term user of twisted with nevow on top mainly using the 
athena part with LivePage and LiveElement for RPC between Python and 
JScript. nevow/athena opens up a whole new world of transparently 
calling from server to browser and vice versa on a permanent connection. 
With a slight change (three lines) a nevow/athena 'permanent connection' 
also survives network outages of up to a minute like the ones 
experienced in mobile 3G networks.

Recently I've combined twisted/nevow with qooxdoo http://www.qooxdoo.org 
allowing injection/removal of widgets including code into a livepage 
thus providing not only a 'real app' but a real desktop user experience 
in a browser.

If you want to have a look at some demos please feel free to hit

http://nqx.thieprojects.ch  minimal nevow/qooxdoo samples
http://telinfo.thieprojects.ch  Swiss telephone book lookup
http://differenzler.thieprojects.ch Minmal Jass cardgame

To see code (use Firebug, JScript is not obfuscated) done starting from 
2006 till recently.

Part of the above mentioned technology was used in a larger card game 
setup for the Swiss National TV providing a multi player game site with 
various games of Jass. Currently around 25k games are played by about 
70k users a day.

http://www.samschtigjass.ch

The 'Einzelspieler-Version' can be played without logging in.

I've also written experimental stuff bridging XMPP and browser with 
nevow/athena, using XMPP/pubsub for real time data exchange, though for 
this I have no public available samples.

This is definitely a plug but after four years of working in the field 
of RIAs it seems to me that nevow/athena is the most advanced of all 
implementations revolving around 'long polling', permanent connections, 
websockets and related technologies. It solves a host of problems which 
you have to tackle when using other technologies.

HTH, Werner


On 31.03.2010 22:58, sstein...@gmail.com wrote:
>
> On Mar 31, 2010, at 4:26 PM, Reza Lotun wrote:
>
>> Hi,
>>
>>> I am looking for a framework for doing a long polling service where :
>>>
>>> clients would connect to a soecific 'channel' and wait for a response
>>>
>>> Where a client admin would push a response only to clients connected to the
>>> same channel
>>
>> There is a project built on top of Twisted that does exactly this,
>> called Orbited (http://orbited.org/). It works, and I use it for
>> internal real-time stats web pages. The one caveat I have with it is
>> that it recently appears to be somewhat inactive - though I use it so
>> much I might fork it and continue development ;-)
>
> It seems to have completely stalled just before the big 0.8 refactoring 
> effort.
>
> Have you continued, or do you plan to continue development where it was left 
> off?
>
> They all seem to have gone off to play with node.js instead.
>
>> If you're looking for a scalable, long-polling queue broadcaster *in
>> general*, I highly suggest nginx_http_push - an addon module for the
>> popular C-based asynchronous web server nginx
>> (http://pushmodule.slact.net/).
>
> Very cool, I hadn't seen that before.
>
> S
>
>
> ___
> Twisted-Python mailing list
> Twisted-Python@twistedmatrix.com
> http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python

___
Twisted-Python mailing list
Twisted-Python@twistedmatrix.com
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python


[Twisted-Python] ~twisted-dev on Launchpad will now receive mail about bugs filed on Ubuntu's Twisted

2010-04-01 Thread Jonathan Lange
Hello all,

I've subscribed the Launchpad team https://launchpad.net/~twisted-dev
to receive mail about bugs on the "twisted" source package in Ubuntu.

It will add a small amount of email traffic to anyone who's a member
of that team. However, it will let us know about bugs that Ubuntu
users experience that are due to Twisted.

I'll gladly unsubscribe the team if folk complain loudly enough.

Thanks,
jml

___
Twisted-Python mailing list
Twisted-Python@twistedmatrix.com
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python


[Twisted-Python] Inline Callbacks

2010-04-01 Thread Jason J. W. Williams
Would it be fair to say that when developing code that utilizes
inlineCallbacks, your function is a generator that returns a deferred
whose callback is the coroutine that's yielding?

-J

___
Twisted-Python mailing list
Twisted-Python@twistedmatrix.com
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python


Re: [Twisted-Python] session management

2010-04-01 Thread Mark
Thanks for the help, but how do I access the session?  What would be
the method call to put the data into a session for instance?




On Wed, Mar 31, 2010 at 5:39 PM,   wrote:
> On 04:10 am, elihusma...@gmail.com wrote:
>>On Tue, Mar 30, 2010 at 6:42 PM, Itamar Turner-Trauring
>> wrote:
Greetings,

I am new to this list and twisted.  I have worked with some systems
similar to twisted, notably Apache MINA.  I am trying to find out how
to set up my server to support sessions for multiple clients.  Right
now I am simply developing a telnet-like application to learn twisted
but cannot figure out how to manage sessions for the remote clients.
>>>
>>>Each Protocol instance stays alive for the lifetime of the connection
>>>it
>>>is matched to (via the transport). So just store attributes on the
>>>Protocol instance.
>>
>>I figured as much that twisted supported the notion of sessions.  Are
>>there any examples that show me how to access them and
>>add/remove/update attributes in the session?
>
> Protocol instances are normal Python objects.  You can use normal Python
> attributes on them in the normal way.  For example:
>
>    from twisted.internet.protocol import Protocol
>
>    class Counter(Protocol):
>        """
>        Keep track of how many times data is delivered over a connection.
>        """
>        def connectionMade(self):
>            self.count = 0
>
>        def dataReceived(self, bytes):
>            self.count += 1
>
> Jean-Paul
>
> ___
> Twisted-Python mailing list
> Twisted-Python@twistedmatrix.com
> http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
>

___
Twisted-Python mailing list
Twisted-Python@twistedmatrix.com
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python


Re: [Twisted-Python] session management

2010-04-01 Thread exarkun

On 02:38 am, elihusma...@gmail.com wrote:

On Wed, Mar 31, 2010 at 5:39 PM,   wrote:

On 04:10 am, elihusma...@gmail.com wrote:

On Tue, Mar 30, 2010 at 6:42 PM, Itamar Turner-Trauring
 wrote:

Greetings,

I am new to this list and twisted. �I have worked with some systems
similar to twisted, notably Apache MINA.  I am trying to find out 
how
to set up my server to support sessions for multiple clients. 
Right
now I am simply developing a telnet-like application to learn 
twisted
but cannot figure out how to manage sessions for the remote 
clients.


Each Protocol instance stays alive for the lifetime of the 
connection

it
is matched to (via the transport). So just store attributes on the
Protocol instance.


I figured as much that twisted supported the notion of sessions. �Are
there any examples that show me how to access them and
add/remove/update attributes in the session?


Protocol instances are normal Python objects.  You can use normal 
Python

attributes on them in the normal way. �For example:

� �from twisted.internet.protocol import Protocol

� �class Counter(Protocol):
� � � �"""
       Keep track of how many times data is delivered over a 
connection.

� � � �"""
� � � �def connectionMade(self):
� � � � � �self.count = 0

� � � �def dataReceived(self, bytes):
� � � � � �self.count += 1


Thanks for the help, but how do I access the session?  What would be
the method call to put the data into a session for instance?


The protocol instance *is* the session (or, as I would normally say "the 
protocol instance has a one to one relationship with a connection", but 
I think that's what you mean when you say "the session").  You can 
define whichever methods and attributes you want.


It's a regular Python object.  All the regular stuff you know about 
Python objects applies.


Jean-Paul

___
Twisted-Python mailing list
Twisted-Python@twistedmatrix.com
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python


Re: [Twisted-Python] Inline Callbacks

2010-04-01 Thread Christopher Armstrong
On Thu, Apr 1, 2010 at 8:20 PM, Jason J. W. Williams
 wrote:
> Would it be fair to say that when developing code that utilizes
> inlineCallbacks, your function is a generator that returns a deferred
> whose callback is the coroutine that's yielding?

It pays to be very very specific about all the different objects and
interactions going on with generators in Python and especially with
inlineCallbacks to avoid confusion.There are a couple of inaccuracies
in this statement, some which I think are just about poor wording and
some which come from misunderstanding.

In Python, there are generator functions and there are generators.
Calling a generator function returns a generator, which has next() and
send() methods. Generators do not return things, though a generator's
next() or send() methods do (I say this because you mentioned a
"generator that returns a deferred").

Also, there's nothing called a "coroutine" that's related to
inlineCallbacks at all, and the word is fraught with ambiguities in
Python, so it's best to just avoid it entirely.

In inlineCallbacks, nobody but the person writing the
inlineCallbacks-using function knows that there's a generator
involved. The person calling your inlineCallbacks-using function can't
see any generators; they just get a Deferred object which fires when
the generator is exhausted. The interesting part is that
inlineCallbacks is the thing responsible for iterating the generator,
not user-code. It is responsible for calling .send() on the generator
object when previously yielded deferreds have fired. The value of the
Deferred returned will be whatever is passed to returnValue in the
inlineCallbacks-using function.

-- 
Christopher Armstrong
http://radix.twistedmatrix.com/
http://planet-if.com/

___
Twisted-Python mailing list
Twisted-Python@twistedmatrix.com
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python


Re: [Twisted-Python] Inline Callbacks

2010-04-01 Thread Jason J. W. Williams
Hi Christopher,

Apologize for the sloppy language. So would this be a better way of putting it?

Assuming a function func_a that has the inlineCallbacks decorator...

If func_a were added as a callback for a deferred (deferred 1), when
func_a was called another deferred would be returned (deferred 2)
which would only fire once func_a had run to the end of the function
and returned.

While func_a is running, every time yield is called, this would
operate similarly to writing a separate callback for the contents of
each of those yield statements and chaining them normally to each
other as callbacks.

That is this:

@defer.inlineCallbacks
def func_a(value):
   num = yield do_something(value)
   num2 = yield do_something_more(num)
   return num2

is equivalent to:

def func_a(value):
return do_something(value).addCallback(cb_step_1)

def cb_step_1(num):
return do_something_more(num).addCallback(cb_step_2)

def cb_step_2(num2):
return num2


Thank you very much for your help in understanding this.  I've always
used a combination of deferreds and callbacks/errbacks to this point.

-J


On Thu, Apr 1, 2010 at 10:33 PM, Christopher Armstrong
 wrote:
> On Thu, Apr 1, 2010 at 8:20 PM, Jason J. W. Williams
>  wrote:
>> Would it be fair to say that when developing code that utilizes
>> inlineCallbacks, your function is a generator that returns a deferred
>> whose callback is the coroutine that's yielding?
>
> It pays to be very very specific about all the different objects and
> interactions going on with generators in Python and especially with
> inlineCallbacks to avoid confusion.There are a couple of inaccuracies
> in this statement, some which I think are just about poor wording and
> some which come from misunderstanding.
>
> In Python, there are generator functions and there are generators.
> Calling a generator function returns a generator, which has next() and
> send() methods. Generators do not return things, though a generator's
> next() or send() methods do (I say this because you mentioned a
> "generator that returns a deferred").
>
> Also, there's nothing called a "coroutine" that's related to
> inlineCallbacks at all, and the word is fraught with ambiguities in
> Python, so it's best to just avoid it entirely.
>
> In inlineCallbacks, nobody but the person writing the
> inlineCallbacks-using function knows that there's a generator
> involved. The person calling your inlineCallbacks-using function can't
> see any generators; they just get a Deferred object which fires when
> the generator is exhausted. The interesting part is that
> inlineCallbacks is the thing responsible for iterating the generator,
> not user-code. It is responsible for calling .send() on the generator
> object when previously yielded deferreds have fired. The value of the
> Deferred returned will be whatever is passed to returnValue in the
> inlineCallbacks-using function.
>
> --
> Christopher Armstrong
> http://radix.twistedmatrix.com/
> http://planet-if.com/
>
> ___
> Twisted-Python mailing list
> Twisted-Python@twistedmatrix.com
> http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
>

___
Twisted-Python mailing list
Twisted-Python@twistedmatrix.com
http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python