Simon Willison’s Weblog

Subscribe
Atom feed for python

1,085 items tagged “python”

The Python programming language.

2008

Django tickets with keyword “djangocon”. Adrian and Jacob ran an “I want a pony” session during their closing keynote at DjangoCon—I’ve filed the feature requests as tickets tagged with the “djangocon” keyword.

# 8th September 2008, 3:02 am / djangocon, djangocon08, iwantapony, django, python, adrian-holovaty, jacob-kaplan-moss, tickets

Django 1.0 release notes. What’s new in Django 1.0. Short answer: one heck of a lot.

# 4th September 2008, 1:10 am / django, python, releasenotes

Django 1.0 released! Outstanding. Massive thanks to everyone who contributed. We made it!

# 4th September 2008, 1:08 am / django, python, release, celebration

Low level hooks for multi-database support in Django. As discussed in this sub-thread on reddit: The internal Django Query class has a ’connection’ attribute which can be set by the constructor. This low level hook is the secret to talking to more than one database at once, but higher level APIs have not yet been defined. Jacob Kaplan-Moss: “As a matter of fact, at least a couple high-traffic Django sites are using the new hooks.”

# 3rd September 2008, 11:33 pm / reddit, django, query, multidb, python, jacob-kaplan-moss

dmigrations thread on Django Nashville. The Django Nashville Google Group is currently hosting the most interesting discussion of dmigrations.

# 3rd September 2008, 10:36 pm / dmigrations, django, python, nashville, google-groups

Announcing dmigrations

The team at Global Radio (formerly GCap Media) is the largest group of Django developers I’ve personally worked with, consisting of 14 developers split into two scrum teams, all contributing to the same overall codebase.

[... 625 words]

What’s New in Python 2.6. The new multiprocessing package looks pretty useful, especially as it provides a way to work around Python’s GIL.

# 1st September 2008, 9:03 pm / gil, python, multiprocessing

Using Akismet with Django’s new comments framework. A nice example that demonstrates two features that were recently rolled in to the Django 1.0 betas: the new signals library and the new comments framework.

# 28th August 2008, 10:12 am / comments, signals, django, python, akismet, spam

URLsafe base64 encoding/decoding in two lines. A much better solution than my base65 hack—if you understand how base64 padding works (I didn’t) you can use it to generate URL-safe compressed hashes. Performance should be significantly better than my version.

# 28th August 2008, 9:57 am / base64, urlsafe, base65, python

Django snippets: Sign a string using SHA1, then shrink it using url-safe base65. I needed a way to create tamper-proof URLs and cookies by signing them, but didn’t want the overhead of a full 40 character SHA1 hash. After some experimentation, it turns out you can knock a 40 char hash down to 27 characters by encoding it using a custom base65 encoding which only uses URL-safe characters.

# 27th August 2008, 10:18 pm / django-snippets, django, python, hashes, sha1, base65, cryptography, security, cookies, signedcookies, urls

Django 1.0 beta 2 released! 1.0 draws ever closer. Important new features include major documentation and comment system refactorings, plus the removal of a bunch of deprecated code (including oldforms). Feature and string freezes are now in place, so it’s just bugs and documentation improvements between now and the final release.

# 27th August 2008, 2:41 pm / django, python

Django documentation (for 1.0). The documentation refactor is in: the docs for the upcoming 1.0 release have been tidied up, rearranged and ported to a new documentation system based on Sphinx (the Python documentation toolkit, NOT the full-text search engine). The URL has also changed to docs.djangoproject.com.

# 24th August 2008, 10:49 am / python, documentation, django, sphinx-docs

The Python Property Builtin. The always-educational Adam Gomaa explains the Python property built-in and shows how it can be used to improve Django’s model-based URL generation.

# 23rd August 2008, 1:08 pm / django, python, property, adam-gomaa, urls

django-timezones. Models, form fields and a template filter for dealing with timezones in Django.

# 21st August 2008, 11:18 pm / django, timezones, python

Persistent Django on Amazon EC2 and EBS—the easy way. Useful tutorial on getting Django up and running on EC2 with EBS for a persistent PostgreSQL database.

# 21st August 2008, 9:32 pm / aws, ec2, amazon, ebs, django, python, postgresql

UnicodeDictWriter—write unicode strings out to Excel compatible CSV files using Python. Stuart Langridge and I spent quite a while this morning battling with Excel. The magic combination for storing unicode text in a CSV file such that Excel correctly reads it is UTF-16, a byte order mark and tab delimiters rather than commas.

# 20th August 2008, 12:19 pm / excel, csv, internationalisation, i18n, byteordermark, python, stuart-langridge, unicode, unicodedictwriter, utf16

minidetector. Neat piece of Django middleware that adds a “mobile = True” attribute to the request object if the request’s user-agent matches a list of strings of known low-power browsers in mobiles, PDAs or game consoles.

# 15th August 2008, 8:21 am / minidetector, middleware, django, python, mobile

This Week in Django. After 33 episodes Django’s usually-weekly podcast finally has its own website.

# 14th August 2008, 2:57 pm / thisweekindjango, django, python, podcasts

Keyczar (via) New open source cryptography toolkit from Google, designed to get algorithm selection, key rotation and versioning right so you don’t have to. Java and Python versions are available; the Python version depends on PyCrypto.

# 13th August 2008, 1:20 pm / pycrypto, python, google, encryption, keyrotation, ben-laurie, java, keyczar

Django snippets: RequestFactory. I’ve been wanting this for ages; when I finally got around to writing it it turned out to only be a dozen or so lines of code. Makes it easy to create mock request objects in Django, which you can then use for testing view functions directly (bypassing the current test client mechanism which requires views to be assigned to a URLconf before they can be tested).

# 12th August 2008, 12:40 pm / django, testing, requestfactory, code, python, httprequest

Changeset 8266—Added ModelAdmin.save_model() and ModelAdmin.save_formset() methods. One of those small changes that opens up enormous possibilities—it’s now incredibly easy to customise exactly how a model is saved in the Django admin interface by over-riding the save_model method.

# 10th August 2008, 1:17 pm / django, admin, python

GeoDjango Documentation. Merged to Django trunk a few hours ago. The tutorial isn’t there yet, but the rest of the docs are worth exploring.

# 5th August 2008, 11:06 pm / geodjango, documentation, django, python

My Universal Feed Parser was conceived as a weapon against what I considered the gravest error of XML: draconian error handling. Recently, someone asked me to implement a switch that makes it not fall back on lax parsing in the case of an XML wellformedness error. I said no, not because it would be difficult to implement, but because that defeats its entire reason for being.

Mark Pilgrim

# 5th August 2008, 10:52 pm / xml, mark-pilgrim, universalfeedparser, feeds, draconian, wellformedness, python

simple-thrift-queue (via) Phillip Pearson’s surprisingly concise in-memory message queue written in Python using Facebook’s Thrift library (which is similar to Protocol Buffers, but was open sourced much earlier on). Handles 4,000 requests per second on a laptop.

# 4th August 2008, 12:27 pm / messaging, phillip-pearson, python, facebook, thrift, protocolbuffers, message-queues

PDFMiner. Useful looking PDF parsing library in Python—can produce an XML representation of the text and style information in a PDF document.

# 3rd August 2008, 3:29 pm / pdf, python, xml, screen-scraping, pdfminer

Changeset 8162. “Implemented a secure password reset form that uses a token and prompts user for new password”—also sneaks base36 encoding and decoding in to Django.

# 31st July 2008, 10:54 pm / django, python, lukeplant, changeset, security, base36, passwords

Super User Conditional Page Exception Reporting. The name is almost as long as the code snippet: this serves Django’s debug page to logged in super-users, falling back to the default 500 template for everyone else.

# 31st July 2008, 9:06 pm / django, python, debugging, exceptions, middleware

Spawning + Django. The latest version of Spawning (a fast Python web server built on top of the Eventlet non-blocking coroutine networking library) can run Django applications out of the box, using threads and processes to work around the blocking nature of the ORM’s database drivers. Eric Florenzano reports better performance than Apache and mod_wsgi, and is now hosting his site on it.

# 31st July 2008, 10:56 am / eric-florenzano, django, python, comet, eventlet, spawning

DjangoCon & Django 1.0 updates. DjangoCon tickets will be released in two batches of 100. The first set will be available at 12 noon UTC on Thursday July 31st; the second set will be released at 6pm UTC on Friday August 1st.

# 30th July 2008, 10:25 am / tickets, djangocon, events, django, python

Extra fields on many-to-many relationships (via) Checked in just over an hour ago, Django now lets you specify a custom “through” table for a ManyToManyField. Great work by Eric Florenzano.

# 29th July 2008, 1:58 pm / manytomany, eric-florenzano, django, python, through