# Category archives: Pony

Rainbows and web services and Django... Oh my! RSS

As some may remember, one of our products involves the user posting very large (multiple GB) files. Previously we've been using an nginx extension that does a direct-to-disk streaming decode during an upload, but that extension isn't available in newer nginx (which we'd like to have available in order to take advantage of HTTP Live Streaming and Flash Video support).

We also wanted all the nice features you get with JQuery-File-Upload; resumability, progress tracking, etc. I looked through the various back-end scripts for JQuery-File-Upload, and was... nonplussed, lots of "basic functionality only" back-ends and a few overly ...

## pip/pytz fails with 1.4 and 2013b

We happened to be building a new build server today, and one of the steps in the process is to install packages.  We download all of the packages to local disk in one step (pip install --download ${packages}), then install them in the next step (pip install --no-index --find-links${packages}).  Thing is, while pytz downloaded with the install command, it would not install from the downloaded package.

pip is now 1.4, which rejects the 2013b pytz release that was downloaded in the step before as being a pre-release.  You can get around it with a pytz==2013b in your ...

## Defaulting a POINT to GeoIP

So you added a totally cool and gnarly view that lets the user specify a POINT on a map (and text coordinates), and then two more to let them view and explore them.  Your users should love you forever... but those dratted users are complaining that the default location is off in the Atlantic ocean off the coast of Africa.  The obvious solution, involving bricking ungrateful users into hidden rooms in catacombs is rejected due to the expense of acquiring catacombs, so what do you do?

How about using GeoIP localization to make the default location the (approximate) location from ...

## Metaclasses, what are they good for...

A question was asked at the Django Toronto meetup during the metaclasses talk, basically, "what would you use this for"... so, here's my talk on Metaclasses [pdf] from a PyCon of the Python 2.2 era, which addressed that question at some length (the first half of the presentation). It doesn't secifically mention the use-case cited in the Django Toronto talk (pre-calculation to concrete-ify a final class, as it is just glossed over as converting human-friendly to machine friendly structures), but it does cover most of the use cases envisioned back when Metaclasses were "new stuff".

## olwidget show features in the window

So now you've got your spiffy textual-entry-of-GPS-coordinates-and-map admin GUI and you're wanting to actually let people see your "features" on a map.  olwidget has an InfoMap() which is basically a Map + a single InfoLayer, but it uses a static set of "info" rather than a dynamically updating set. Here's how to hack the dynamic updates in using jquery and simple ajax.

<div id="{{ id }}" data-url="{% url 'server_features' %}"></div>
{{ layer_html|join:"" }}
<script type="text/javascript">
var loadHandler = function( handler ) {
...
}
{{ setup_custom_layer_types|safe }}
var mapwidget = new olwidget.Map("{{ id }}", [
{{ layer_js|join:"," }}
],
{{ map_opts|safe }}
);
var layer = mapwidget.vectorLayers[0 ...

## olwidget templates...

If you are using olwidget to get your geodjango editing up-and-running fast, and you want your users to be able to enter the GPS coordinates textually, as well as via the map, then yay, I've already gone through the pain for you.  Here is a hacky way to get synchronized text-field and map entry using an olwidget template.  Note: there are few bad practices here; you should see this as a quick hack to demonstrate that you can make such modifications, not that it's the right way to do it.

<h2 class="box">GPS Coordinates <input id="{{id ...

## GeoDjango is Pretty Straightforward

Doing some trivial GeoDjango today.  All was pretty straightforward, though the tutorial didn't cover how to add PostGIS to an existing DB (you just run the same commands you'd use to create the template against the existing DB, but it needs to be as a DB superuser, so it won't go into a regular migration nicely). I wound up a bit lost trying to use the core GeoDjango admin until I logged into the #geodjango irc channel and the message of the day said "go look at olwidget"... oh, yeah, that's exactly what I needed... don ...

## Okay, spammers, you win

I was just going through and deleting your dozens or hundreds of posts a day using django admin interface, but drat it, you're posting way too many comments and that was taking too long.  You wore me down, so I wrote a stupid little view to kill your comments en-mass.  You win, you wasted part of my life.

## Save/Restore for Embedded Django?

So you've embedded Django in your product lines and you want to provide a save/restore function.  You, of course, are using South migrations, and since you're agile, you often wind up with schema modifications as requirements change.  Since you're managing a lot of products, you want whatever solution you use to be at least somewhat generic.  What you want to do:

• specify what apps/tables/fields to include/exclude from the save file
• use a stable format (dumpdata xml is fine for now)
• include random data-files (can be extremely large, so needs hard-linking and streaming upload ...

## Single Artefact Deployment

The first talk at Django Toronto was on Wave's single artefact deployment mechanism.  Basically it's the Fussy Firmware Packager, but without the signatures.  We use Fussy to be able to send/provide customers with (signed) images that can be loaded on (potentially disconnected) machines (through their web interfaces).

The images include a built virtualenv including all of the code installed as packages, along with binaries, libraries and the like which are to be updated. Fussy does the verification, unpacking and symlink swaps, then calls a script in the firmware to fixate the it (e.g. hooking it into ...