<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Flask on System Overlord</title><link>https://systemoverlord.com/tags/flask.html</link><description>Recent content in Flask on System Overlord</description><generator>Hugo</generator><language>en-us</language><managingEditor>david@systemoverlord.com (David Tomaschik)</managingEditor><webMaster>david@systemoverlord.com (David Tomaschik)</webMaster><lastBuildDate>Sun, 26 Oct 2014 18:51:13 +0000</lastBuildDate><atom:link href="https://systemoverlord.com/tags/flask/index.xml" rel="self" type="application/rss+xml"/><item><title>Dangers of decorator-based registries in Python</title><link>https://systemoverlord.com/2014/10/26/dangers-of-decorator-based-registries-in-python/</link><pubDate>Sun, 26 Oct 2014 18:51:13 +0000</pubDate><author>david@systemoverlord.com (David Tomaschik)</author><guid>https://systemoverlord.com/2014/10/26/dangers-of-decorator-based-registries-in-python/</guid><description>&lt;p&gt;So &lt;a href="http://flask.pocoo.org/"&gt;Flask&lt;/a&gt; has a really convenient mechanism for registering handlers, actions to be run before/after requests, etc. Using decorators, Flask registers these functions to be called, as in:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;#!python
@app.route('/')
def homepage_handler():
 return 'Hello World'

@app.before_request
def do_something_before_each_request():
 ...
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This is pretty convenient, and works really well, because it means you don&amp;rsquo;t have to list all your routes in one place (like Django requires) but it comes with a cost. You can end up with Python modules that are only needed for the side effects of importing them. No functions from those modules are directly called from your other modules, but they still need to be imported &lt;em&gt;somewhere&lt;/em&gt; to get the routes registered.&lt;/p&gt;</description></item></channel></rss>