>> There's a branch of Twisted that implements this, hopefully it will
> >> eventually be merged:
> >> http://twistedmatrix.com/trac/ticket/3711
> > Is there anything that is currently holding this up? (ie. is the design
> > on
> > this branch what will end up in the system or could it change
> > dramatically?)
> There are a bunch of review comments in the ticket. You could just write
> your own until this is ready, I've done it a number of times and it's a
> pretty small piece of code.
I started writing one of my own today (basically a wrapper in render_GET
that calls an deferrable render_GET).
Something like this:
def _bg_GET(self, request):
# Do something slow
def render_GET(self, request):
d = deferToThread(self._bg_GET, request)
d.addCallback(lambda r: r.finish())
That seems to work, but I would like to
a) not use the deferToThread() and
b) do something that doesn't sacrifice too much performance.
At the end of the day, what I would really like is something in render_GET
that checks the return from calling the internal GET method and if it is a
deferred it adds a callback to finish the request, if not it simply returns
the result. (this would allow me to use deferToThread, inlineCallbacks, etc
as needed in my get methods)
Can you see any issues with doing something like this? (it seems almost too
simple so I expect that I must be missing something)
(repost of email earlier today on twisted mailing list. suggested this may
be better place to discuss. sorry if you get this twice.)
We have a large client-server based application based on twisted. The
application has grown to the point where we would like to add a REST-based
API to the server side to allow for interfacing with a wider variety of
client applications. Over the weekend I started looking into twisted.web
and had a couple of basic questions:
1) Is there any method to stream a large request (ex: PUT or POST with file
upload) into the system or does the entire body have to be loaded into
memory as part of the request?
2) Has anyone used an existing URL Routing system (ex: Routes , Selector
) and adapted it for use with Twisted? (I know I could use the twisted
preferred method of parent child hierarchies, but our application has a
better fit with the route-based method used by Pylons, Django, Rails, etc)
3) Is there a document anywhere that describes all the environment variables
the user can get from the request and how to get to them? (something like
the environ section of the WSGI PEP )
4) Are their any wrappers people have developed to make it a bit easier to
use deferreds (in particular inlinecallbacks) in the handlers for
twisted.web? (I am considering just writing a wrapper myself that provides
an interface similar to google app engine webapp  but wanted to check
first so I don't reinvent something)
I am using 10.0.0 for 2.5 on a Vista Home 'Premium' (yes, yes, I know).
I am accessing some page with getPage(certain_url,method='GET').
Accessing works for non-local urls. Accessing does not work for "http://localhost:8080/..." - windows error 10061: connection refused (abbreviated from partially localized error message).
This propably sounds like a firewall problem, but all three firewall profiles disabled, only the 'native' windows vista firewall installed, so it shouldn't be one, I hope.
When using a synchronous urllib.urlopen('http://localhost:8080/...') / read() pair, it works.
This makes me nervous somehow, I must admit. Perhaps you have any hint / idea what the problem might be? This would be most welcome!
Btw.: The line "127.0.0.1 localhost" is in the host file in \Windows\System32\drivers\etc.
Thank you very much in advance!
GRATIS für alle GMX-Mitglieder: Die maxdome Movie-FLAT!
Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome01
Hi to all, and since this is my first post, congratulations for the perfect
i have the following code
print 'Connection from: ', self.transport.client
def connectionLost(self, reason):
print self.transport.client, 'Disconnected'
def dataReceived(self, line):
"""Here the XML Parser"""
p = xml.parsers.expat.ParserCreate()
p.StartElementHandler = start_element
p.EndElementHandler = end_element
p.CharacterDataHandler = char_data
I got the following error
--- <exception caught here> ---
x86_64.egg/twisted/internet/selectreactor.py", line 146, in
why = getattr(selectable, method)()
x86_64.egg/twisted/internet/tcp.py", line 460, in doRead
File "stdiodemo.py", line 419, in dataReceived
xml.parsers.expat.ExpatError: syntax error: line 1, column 0
The XML Message is coming in the form of:
POST /test/pcp/Listener HTTP/1.1
<pttv_control_message version="1.0-M4-SNAPSHOT" build="599"
<message>OK, found 5 session entries</message>
Please give me some hints.
How to parse the incoming XML and how to ommit the headers from the
beginning of the message?
Thanks in advance