Category archives: Pony

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

Save/Restore for Django "Embedded" Apps

So we have a lot of Django-based code where we'd like the user to be able to download a (subset of) the Django database as a "config file", then upload that "config file" to some number of other machines (or the original one), potentially long after the database has been migrated. I've got the skeleton of that working, I record all of the current migrations in the data-file, I play the migrations forward to that point, then attempt to insert the records, then continue migrating. That almost works, but inserting the stored records fails, as the standard "loaddata ...

Continue reading

React.js with Django

So I've been doing a spike test with a project where I'm trying to use React.js to build a front-end to a Django application. The bulk of this application is basic Django forms, posts, page-loads, etc. but there's a number of complex views for scheduling, content uploading etc. As of now I think I'm willing to say that React is going to become part of my toolbox. There are definitely some issues that I gather Facebook has addressed in their "Flux" framework, but that seems to go a bit too far for me.

Things I ...

Continue reading

Uploading GBs to Django

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 ...

Continue reading

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 ...

Continue reading

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 ...

Continue reading

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".

Continue reading

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 ) {
...
}
loadHandler( function() {
    {{ setup_custom_layer_types|safe }}
    var mapwidget = new olwidget.Map("{{ id }}", [
            {{ layer_js|join:"," }}
        ], 
        {{ map_opts|safe }}
    );
    var layer = mapwidget.vectorLayers[0 ...

Continue reading

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 ...

Continue reading

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 ...

Continue reading

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.

Continue reading