Posts tagged: DJANGO

Django management commands, remotely

Django management commands, remotely

I love Django management commands.

For dpaste.com I’ve written several management commands for things that I don’t need a web UI for, like:

  • expire - delete expired pastes (invoked by cron)
  • expunge - manage TOS violations like spam
  • stats - useful metrics on the current corpus of pastes, and on user activity

In running the site I also use management commands from my django-blocklist app, for tasks like deleting expired entries (via cron) or generating reports.

A use case for Python assignment expressions

Python 3.8 (2019) added “assignment expressions”, aka the “walrus operator”.

I generally like things that make Python more expression-oriented, like list comprehensions, but I’m ambivalent about these. It’s pretty easy to impair readability by using them overzealously. Is saving one line of code worth making it harder to notice that an assignment is happening?

However, I’ve found a use case I like a lot. I use them in the Django Python shell when doing exploratory ORM queries.

The Riak key-value database: I like it

The Riak key-value database: I like it

(Note: This is a writeup I did a few years ago when evaluating Riak KV as a possible data store for a high-traffic CMS. At the time, the product was called simply “Riak”. Naturally, other details may be out of date as well.)

Riak is a distributed, key/value store written in Erlang. It is open source but supported by a commercial company, Basho.

Its design is based on an Amazon creation called Dynamo, which is described in a 200-page paper published by Amazon. The engineers at Basho used this paper to guide the design of Riak.