Living Systems_

Python

Debugging inside Jinja templates using pdb/ipdb

I’m working on a static reporting tool using the Jinja2 templating engine for Python. I was trying to figure out a way to enter into the Jinja templating code with the pdb/ipdb commandline debugger. I tried creating an .ipdbrc file in my local directory with the line: path/to/template.html:<lineno> … but that didn’t work. What worked was to figure out the line that says : return self.environment.concat(self.root_render_func(ctx)) … inside the the jinja codebase, and put a breakpoint on that (which for me was on line 1299, but might vary depending on version):

Basic PUB/SUB connection with ZeroMQ in Python

ZeroMQ is a great way to quickly and simply send messages between multiple programs running on the same or different computers. It is very simple and robust since it doesn’t need any central server. Instead it talks directly between the programs through sockets, TCP-connections or similar. ZeroMQ has client libraries for basically all commonly used programming languages, but when testing out that a connection works between e.g. two different machines, it might be good to keep things simple and test just the connection, as simply as possible.

The unexpected convenience of JSON on the commandline

I was working with a migration from drupal to processwire CMS:es, where I wanted to be able to pipe data, including the body field with HTML formatting and all, through multiple processing steps in a flexible manner. I’d start with an extraction SQL query, through a few components to replace and massage the data, and finally over to an import command using processwire’s wireshell tool . So, basically I needed a flexible format for structured data that could be sent as one “data object” per line, to work nicely with linux commandline tools like grep, sed and awk.

How to compile vim for use with pyenv and vim-pyenv

This manifested itself in a bunch of error message from the python module in vim, ending with: AttributeError: 'module' object has no attribute 'vars' I first thought it was an error in vim-pyenv and reported it (see that issue for more in-depth details). In summary it turns out that older versions of VIM indeed lack some attributes in its python module, so I figured I had to compile my own version, below are just my notes about how to do this, for future reference: