Quick'n'Dirty Tornado Intro

2,382 views

Published on

Slides for Lightining talk that I gave in PyCon Finland in Turku on 21.10.2010

Published in: Technology, Design
0 Comments
4 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
2,382
On SlideShare
0
From Embeds
0
Number of Embeds
8
Actions
Shares
0
Downloads
41
Comments
0
Likes
4
Embeds 0
No embeds

No notes for slide













  • Quick'n'Dirty Tornado Intro

    1. 1. quick’n’dirty TORNADO intro Teemu Kurppa www.dirtyaura.org/blog Twitter: teemu Huikea Experience Social mobile gaming startup www.huikea.com
    2. 2. TORNADO scalable, non-blocking web server
    3. 3. TORNADO asynchronous requests simple clean DB API, no ORM programmer-friendly templates readable codebase proven in production: FriendFeed
    4. 4. TORNADO Probably good for real-time web services (hanging GETs to poll) super-popular dynamic sites non-web REST services non-CMS sites for devs like me
    5. 5. Our Tornado instance app cheap, async call Twitter
    6. 6. Our Tornado instance db.slow_synchronous_query() cheap, async call ? Twitter
    7. 7. Our Tornado instance cheap, async calls Another Tornado instance Twitter db.slow_synchronous_query()
    8. 8. Programmer-friendly templates {% for index,value in entries.iteritems() %} {{ index }} : {{ value } {% end %} {% for value in entries %} {{ forloop.counter0 }} : {{ value }} {% endfor %}
    9. 9. CODE DEMO
    10. 10. class TwitterBadgeHandler(tornado.web.RequestHandler): @tornado.web.asynchronous def get(self, username): http = tornado.httpclient.AsyncHTTPClient() url = "http://api.twitter.com/1/users/show/%s.json" % username http.fetch(url, callback=self.on_response) def on_response(self, response): if response.error: self.render("badge_error.html") else: user = tornado.escape.json_decode(response.body) self.render("twitter_badge.html", **user)
    11. 11. .... <style type="text/css"> .badge { background: #{{profile_background_color}} url({{profile_background_image_url}}); ... rest of wrapping and css left-out ... <div class="badge"> <img class="badge-photo” src="{{ profile_image_url }}"> <div class="badge-title">{{ screen_name }}</div> <div class="badge-description">{{ description }}</div> <div class="clear"></div> <div class="badge-status">{{ status['text'] }}</div> </div>

    ×