I’m in a team who are developing a Flask-based web application, which uses logging extensively. For a while now it spews out a lot of lines so the need arose to index them in ElasticSearch, and more importantly, to search through them for auditing purposes. This latter user story …
read moreOther articles
-
-
Rename automatically named foreign keys with Alembic
I have recently messed up my Alembic migrations while modifying my SQLAlchemy models. To start with, I didn’t update the auto-generated migration files to name the indexes/foreign keys a name, so Alembic used its own naming scheme. This is not an actual problem until you have to modify …
read more -
Finding non-translated strings in Python code
When creating multilingual software, be it on the web, mobile, or desktop, you will eventually fail to mark strings as translatable. I know, I know, we developers are superhuman and never do that, but somehow I stopped trusting myself recently, so I came up with an idea.
Right now I …
read more -
Slugify in Python 3
Today I needed a function to create a slug (an ASCII-only representation of a string). I went Googling a bit, and found an excellend Flask snippet. Problem is, it is designed for Python 2, so I came up with a Python 3 version.
read moreimport re from unicodedata import normalize …
-
Add Python docstring to the beginning of anything in Emacs
Now that I write Python code for a living, I write a lot of functions, classes, and modules. What I still tend to forget, and also find tedious, is adding docstrings. Unlike many developers, writing documentation is not an enemy of mine, but it usually comes to my mind when …
read more -
@ParamConverter à la Django
One thing I really miss from Django is Symfony’s @ParamConverter. It made my life so much easier while developing with Symfony. In Django, of course, there is get_object_or_404 but, for example, in one of my projects I had a view that had to resolve 6(!) objects from the URL …
read more