tornado

Trying to figure out URL dispatcher for sluggale URLs like stackoverflow

I'm using the Tornado framework (Python). I have the sluggable URLs working. But I have 3 different entries in the URL dispatcher. I was wondering if someone could help me transform it into one line. This is what I have: (r"/post/([0-9]+)/[a-zA-Z0-9\-]+", SpotHandler), (r"/post/([0-9]+)/", SpotHandler), (r"/post/([0-9]+)", SpotHan...

Web server which supports removing a file immediately after it has been downloaded once?

I need a web server that allows me to remove a file after it has been successfully downloaded once. Is there any way to do this with apache? Is there another web server I can use for this task? I had already looked into Tornado for this purpose, but couldn't find a way to get an event to fire as soon as the download finished. the on_con...

Decorators vs. classes in python web development.

I've noticed three main ways Python web frameworks deal request handing: decorators, controller classes with methods for individual requests, and request classes with methods for GET/POST. I'm curious about the virtues of these three approaches. Are there major advantages or disadvantages to any of these approaches? To fix ideas, her...

Mimicking basic fcntl or SetHandleInformation call in .Net

Tornado enables win32 support by faking Python's fcntl function using SetHandleInformation, which is available via ctypes on Windows. After some other small fixes, this actually works using IronPython on Windows as well (sadly, IronPython is five times slower). I'd like to get Tornado working on any CLI platform, such using Mono on O...

What does this `_time_independent_equals` mean?

In the tornado.web module there is a function called _time_independent_equals: def _time_independent_equals(a, b): if len(a) != len(b): return False result = 0 for x, y in zip(a, b): result |= ord(x) ^ ord(y) return result == 0 It is used to compare secure cookie signatures, and thus the name. But rega...

Developing a high-performance, scalable Comet application

Well, the title says most of it. I'm looking to develop a chat application that will hopefully become something more, and currently I'm considering my options for what I should build it on top of. I've taken a look at Tornado with Redis as my primary option - Tornado, being a Comet server, is perfect for long polling to retrieve the mes...

how do twisted/tornado et cetera work

I understand that they work in some way distinct from making a thread per user. How exactly does that work? (Does 'non-blocking' have something to do with it?) ...

Tornado handler thinks POST is missing argument when Firebug shows the argument being sent.

I have a simple form using a POST method, consisting of a text box and a file. After hitting submit, I can see the post in Firebug as follows: Parts multipart/form-data posttext Some text image BlahJFIFBlahExifBlahPhotoshopBlahBinaryStuff etc... The Tornado handler that receives it looks like: class NewPostHandler(BaseHand...

How do I get the client IP of a Tornado request?

I have a RequestHandler object for incoming post()s. How can I find the IP of the client making the request? I've browsed most of RequestHandler's methods and properties and seem to have missed something. ...

Comet for User based Notification over a Message Queue

We trying to build application that should use Comet (AJAX Push) to send notifications to individual users. Most notifications will have a fairly low timeout. As we are running RabbitMQ, it would be easiest to send messages through AMQP. I am wondering what the best way to address individual users is, so that both the Comet server and t...

Problems with Tornado Web Server

Hello, I am using OSX 10.58 with the following versions: curl --version curl 7.16.4 (i386-apple-darwin9.0) libcurl/7.21.0 OpenSSL/0.9.7l zlib/1.2.3 Protocols: dict file ftp ftps http https imap imaps ldap ldaps pop3 pop3s rtsp smtp smtps telnet tftp Features: IPv6 Largefile NTLM SSL libz sing /Library/Python/2.5/site-packages/setupto...

tornado server not returning response with self.write

Hi, I have a simple tornado server running like this: import json import suds from suds.client import Client import tornado.httpserver import tornado.ioloop import tornado.web class MainHandler(tornado.web.RequestHandler): def get(self): url = "http://xx.xxx.xx.xxx/Service.asmx?WSDL" client = Client(url) res...

What is twisted's equivalent of tornado's IOLoop.add_callback?

I'm trying to adapt some tornado code to work with twisted. Tornado's IOLoop has a function (add_callback) that will essentially call the function back in the next iteration of the loop. As far as I can tell, twisted doesn't have a direct translation of this. Is there any way to simulate this in twisted? ...

notifying the server (XMLHttpRequest?) on the onunload event?

Is it possible to notify a server (make a single HTTP request with a bit of data, response is unimportant) when client leaves the page? I'm actually using python-tornado comet application with javascript constantly keeping a request connection to the server (which gets closed and re-opened on event. Based off this: https://launchpad.net...

nginx "400 Bad Request"

My php script calls an url with curl very simply : $ch = curl_init("http://192.168.0.110:8000/guess/a b c"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $r = curl_exec($ch); With this url, i have no problem. But if change to : $ch = curl_init("http://192.168.0.110:8000/guess/a b cd"); I have a 400 Bad Request nginx/0.7.62 error...

How do I determine the appropriate check interval?

I'm just starting to work on a tornado application that is having some CPU issues. The CPU time will monotonically grow as time goes by, maxing out the CPU at 100%. The system is currently designed to not block the main thread. If it needs to do something that blocks and asynchronous drivers aren't available, it will spawn another thr...

Are there any major performance differences between epoll and kqueue?

My development machine is a MacBook (which of course has kqueue). However, in production we're running Linux (which of course uses epoll). Obviously, to know the performance characteristics of my code I need to run it using epoll. That said, is performance that I see under kqueue a decent approximation of what I'll see with epoll? Or...

Is Tornado really non-blocking?

Tornado advertises itself as "a relatively simple, non-blocking web server framework" and was designed to solve the C10k problem. However, looking at their database wrapper, which wraps MySQLdb, I came across the following piece of code: def _execute(self, cursor, query, parameters): try: return cursor.execute(query, paramet...

POST multiple checkbox value tornado

I am messing around with a tornado web app with which I need a bit of help. I have multiple checkboxes with the same name and I would like to POST the values of the selected one. <input id=DB_BASED_ID name="activity" value=DB_BASED_ID type="checkbox"/> <input id=DB_BASED_ID name="activity" value=DB_BASED_ID type="checkbox"/> <input id=...

Using Tornado's tornado.options.parse_config_file doesn't work as expected. Kind of a statement, I guess

I was trying to set up a server configuration without having to rely on the tornado.options.parse_command_line() function, but it isn't working properly. It's being parsed, but then tornado just sits on it and doesn't do anything for it. Specifically, I'm using a server.conf file that looks like so: log_file_prefix = "./logs/errors.log"...