I’m doing a concurrency/gevent talk tonight at the Austin Web Python User Group. Slides and other resources are available here. Slides iPython Notebook gevent For the Working Python Developer A Curious on Coroutines and Concurrency, by David Beazley Concurrency is not Parallelism, by Rob Pike gevent gevent 1.0 downloads gevent-spider (recursive web-based web spider) Collaborative painting app source
Here are my slides from “Django on gevent”, my talk from Djangocon 2012. Slide link.
The buzz around the asynchronous, real-time web has been getting more and more attention lately, and for good reason. The old paradigm of thick servers and thin clients is getting outdated as the new web demands rich, fast, asynchronous, full-duplex messaging. The technologies that enable server-to-browser asynchronous messaging have been given the umbrella term “Comet,” and the number of ways to provide Comet services is growing constantly. The transport options include XHR-multipart, WebSockets, and Adobe Flash Sockets, among others.
I’ve been interested in the Django template language for some time now, and I’ve admired much of its simplicity and extendibility. I even wrote a shell for it(screencast)and a two-phase template renderer. Having spent the time to understand how it works, I’ve also had my share of ideas on how to improve it (addition of “elif”, mathematical operations in variable tags, namespaces). The pony that I’ve been wanting the most is probably namespaces.
Django-template-repl is a unique project aimed at providing debugging tools for the Django template language. I did a screencast to highlight its features. In this video, I describe how to use Django-template-repl’s management shell, template tag, and context-capturing features. Please grab the source or simply run: pip install django-template-repl
An emerging design pattern in Django is the usage of class-based views. Writing views as classes is made possible by Python features that allow classes and objects to behave as callables, just like functions. They can help organize view code and promote reusability by offering a greater level of customization. However, callable objects sometimes have thread safety issues that developers are often not aware of. Update 2/2/11: This post is now mostly irrelevant, because Django will soon solve this problem with the newly-refactored generic view module in Django 1.
Caching is one of the first things you can do when you need to start thinking about scaling. Among efforts such as query minimization, denormalization, code optimizations, compression, database tuning, indexing, and load balancing, caching remains one of the lowest hanging fruits in methods to lighten your server load and handle huge amounts of traffic. There are many options, and I chose to evaluate a few of the most interesting setups.
When working with the Django template language, specifically writing template tags or trying out new template tags that are not well documented, it’s easy to fall into a testing loop that involves modifying your code, saving the file, causing runserver to restart, which could take some time for large projects, switching to your web browser, hitting reload, and viewing the results. This workflow can be repetitive and unproductive. I decided to improve template interpreter interactivity by writing a REPL for it, and I released the project as django-template-repl, which is freely available on Github and PyPI.
I dropped my old styles and went with Mingus. I set up a new blog today with django-mingus and so far I’m pretty pleased. Basically, I had some missing features on my blog and I decided to take the lazy route and use this instead of building everything by scratch. It’s still Django, so I can hack it up all I want, so I think I made the right choice.
I’ve begun using pip frequently for working with python packages in my virtualenvs. pip does a great job with installing (and now uninstalling) python packages, but it currently lacks a command that I miss from other types of package managers, such as aptitude and port – search. I’ve forked a Git mirror of pip on Github for the purpose of tooling it with a search command, and I’ve made some progress in the last few days getting it working.