Posts tagged: python

Parsing PHP in Python

Today I found a legitimate use for https://github.com/danielquinn/python-phpPython's default ConfigParser requires each ini file to have a [section]. PHP doesn't, so to read a PHP-formatted INI file in Python requires some kind of custom parser (maybe it would be possible to extend ConfigParser?), where the python-php project came in handy.…

Thoughts on SQLAlchemy

I've recently been using SQLAlchemy's ORM for a Python web app I'm developing. I really like the idea of declaring tables using a class, which provides you with an object class too.For querying, I'm still a bit undecided. I like .filter_by(), .first(), and .all(), but I'm worried that losing visibility…

Requiring HTTPS for my Toolforge tools

My Toolforge (formerly "Tool Labs") tools will now start requiring HTTPS, and redirecting any HTTP traffic. It's a little bit of common code for each tool, so I put it in a shared "toolforge" library. from flask import Flask import toolforge app = Flask(__name__) app.before_request(toolforge.redirect_to_https) And that's it! Your tool…

Pelican theming

Pelican theming isn't actually that difficult. It's based on jinja2 templates, and there were enough themes already out there to pick one and just start forking it. I'm not too happy that they want themes installed into your system python path (or a virtualenv in my case), but since you…