how the following example could be re-created using TwistedGateway,
reactor.listenSSL and reactor.run instead of TwistedChannel?
Appreciate the help.
from twisted.application import service, strports
from twisted.web import static, server, resource, vhost
from amfast.remoting.twisted_channel import TwistedChannelSet, TwistedChannel
amfast.log_debug = True
handler = logging.StreamHandler(sys.stdout)
# Setup domain
root = vhost.NameVirtualHost()
root.default = static.File("../flex/deploy")
domain = "localhost"
# If the code is completely asynchronous,
# you can use the dummy_threading module
# to avoid RLock overhead.
amfast.mutex_cls = dummy_threading.RLock
# Setup ChannelSet
channel_set = TwistedChannelSet(notify_connections=True)
# Clients connect every x seconds
# to polling channels to check for messages.
# If messages are available, they are
# returned to the client.
polling_channel = TwistedChannel('amf-polling-channel')
# Long-poll channels do not return
# a response to the client until
# a message is available, or channel.max_interval
# is reached.
long_poll_channel = TwistedChannel('long-poll-channel', wait_interval=90)
# Setup channels
# Setup server
port = 8000
application = service.Application('AmFast Example')
server = strports.service('tcp:%s' % port, server.Site(root))
print "serving on %s:%s" % (domain, port)
print "Press ctrl-c to halt."
Hopefully quick question. Is there an existing way to easily get at
the HTTP headers in an incoming SOAP request being handled by
twisted.web.soap.SOAPPublisher? Or do I need to override the render
method to keep/return it? Thanks in advance...
I am busy developing a gateway of some sort and have the following
running so far on the reactor:
- HTTP Server listening for incoming connections and HTTP requests.
- LineReceiver client permanently connected to another server.
(Connection is established at startup)
What I need to do is to first translate and then pass messages received
at the HTTP listening end - over to the LineReceiver client. The client
in turn will pass it on to a server using a custom protocol called SSMI,
Web Browser Requests -> HTTPServer -> SSMIClient -> ServerXYZ
For the HTTPServer I'm using the classic design where you inherit from
twisted.web.http.Request for the Protocol, while having
twisted.web.http.HTTPChannel and twisted.web.http.HTTPFactory inherited
classes to support it.
Also, there will only ever be one SSMIClient protocol instance whereas
the HTTPServer needs to process multiple requests at a time, so it will
be a many-to-one design.
What I need to know is how to pass the "packets" received by the
HTTPServer onto the SSMIClient protocol..? I am assuming one would use
deferreds, but the twisted.web.http.Request derived class seemingly does
not have "access" to the Reactor or it's Factory object. But to be
honest, I'm a little in over my head on this and don't even know how to
approach this. I don't know whether I should use a FIFO queue to store
the messages and I don't even know where to keep such a queue. If anyone
have done something even remotely like this I'd love to get some input
from you. It will be greatly appreciated!
How can my server utilize other web services? Is there part of the framework
to do this, or should I just write a mini-client?
Basically, I want to use a very simple web service, a url with a couple of
params, and I get back xml or json data.
Sorry for fundamental nature of this question. Perhaps I should be
redirected to a book or docs, but the docs are pretty large and I am just
getting my feet wet.
I tried this code:
from twisted.spread import pb
from twisted.internet import reactor
def remote_echo(self, s):
if __name__ == "__main__":
On Windows XP all is ok.
On Windows 7 64 I receive this error message:
C:\Program Files (x86)\Python\lib\site-packages\twisted\spread\pb.py:30: DeprecationWarning: the md5 module is deprecated; use hashlib instead
Traceback (most recent call last):
File "C:\Users\bob\Documents\Twisted\pbs.py", line 11, in <module>
File "C:\Program Files (x86)\Python\lib\site-packages\twisted\internet\posixbase.py", line 356, in listenTCP
File "C:\Program Files (x86)\Python\lib\site-packages\twisted\internet\tcp.py", line 862, in startListening
self._realPortNumber = skt.getsockname()
File "<string>", line 1, in getsockname
socket.error: [Errno 10035] A non-blocking socket operation could not be completed immediately
What can I do?
what could be the way(Producer/Consumer?) and simple,basic example to
push data(~10Kb) from Twisted based server(that listening for incoming
requests) into client side(for example FLEX) not as a response to the
incoming request, but occasionally, triggered by server side???
In traditional client/server arch, the server is listening, accepting
and responding to the client's requests, but here I'm looking for
something that initiated from server itself and pushing data to client.
Appreciate the help.
Back in July, there was a long discussion thread regarding Twisted
Documentation, and the idea of switching to Sphinx came up. Here's
probably the culmination of that thread:
To summarize, Glyph laid out the following items that would need to happen
order for Twisted to move from Lore to another documentation system:
1. Someone would have to volunteer to maintain the documentation
infrastructure and teach others to use it.
2. Submit a complete proposal outlining benefits for the move so that it
could be discussed rationally without having to chase down lots of little
bits in email, irc, etc.
3. Address the transition process.
So I went away and did some thinking, and some research and some
experimenting, and I decided that I really want this to happen.
So I am hereby volunteering to manage a Sphinx-based documentation
infrastructure (should there eventually be one) for the Twisted project
as well as the transition to said system.
I have written up a proposal here:
that I think addresses at least the main points of what should need to
in order to move from Lore to Sphinx. It's not quite finished, but I think
it's close enough for people to start discussing it. In particular, there
are a few claims I've made about Lore and it's capabilities that I'm not
quite sure of (just search for the question marks).
I would very much like to get some feedback from the community (especially
the core developers) on this proposal. I'd especially like to hear about:
- things which are not addressed and should be.
- anything that is addressed in the proposal, but you think should be done
in a different way.
- Lore's capabilities.
Please let me know what you think.
I tried this example:
(scripts chatserver.py and chatclient.py)
but they do not work with python 2.6.4 (twisted 8.2.0).
Before the client can do much, the server function
User.detached is called resulting in an exception later
when User.send is called but self.remote is None.
I can fix this by changing chatclient.py:
def connected(self, perspective):
self.perspective = perspective
... and continue as in the original script
it seems that otherwise the perspective is destroyed
also the documentation should perhaps mention that the
client can only connect to the server once because the
server code does not remove a user from her group when
Is there any more complete example anywhere with better