<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en-us" xmlns="http://www.w3.org/2005/Atom"><title>Simon Willison's Weblog: monkeypatch</title><link href="http://simonwillison.net/" rel="alternate"/><link href="http://simonwillison.net/tags/monkeypatch.atom" rel="self"/><id>http://simonwillison.net/</id><updated>2018-02-21T17:54:36+00:00</updated><author><name>Simon Willison</name></author><entry><title>s3monkey: A Python library that allows you to interact with Amazon S3 Buckets as if they are your local filesystem.</title><link href="https://simonwillison.net/2018/Feb/21/s3monkey/#atom-tag" rel="alternate"/><published>2018-02-21T17:54:36+00:00</published><updated>2018-02-21T17:54:36+00:00</updated><id>https://simonwillison.net/2018/Feb/21/s3monkey/#atom-tag</id><summary type="html">
    
&lt;p&gt;&lt;strong&gt;&lt;a href="https://github.com/kennethreitz/s3monkey"&gt;s3monkey: A Python library that allows you to interact with Amazon S3 Buckets as if they are your local filesystem.&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;
A particularly devious hack by Kenneth Reitz—provides a context manager within which various Python filesystem APIs such as open() and os.listdir() are monkeypatched to operate against an S3 bucket instead. Kenneth built it to make it easier to work with files from apps running on Heroku. Under the hood it uses pyfakefs, a filesystem mocking library originally released by Google.

    &lt;p&gt;&lt;small&gt;&lt;/small&gt;Via &lt;a href="https://twitter.com/kennethreitz/status/966364124232941569"&gt;@kennethreitz&lt;/a&gt;&lt;/small&gt;&lt;/p&gt;


    &lt;p&gt;Tags: &lt;a href="https://simonwillison.net/tags/python"&gt;python&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/s3"&gt;s3&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/heroku"&gt;heroku&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/monkeypatch"&gt;monkeypatch&lt;/a&gt;&lt;/p&gt;



</summary><category term="python"/><category term="s3"/><category term="heroku"/><category term="monkeypatch"/></entry><entry><title>Appending the request URL to SQL statements in Django</title><link href="https://simonwillison.net/2010/Jun/2/framewalking/#atom-tag" rel="alternate"/><published>2010-06-02T09:09:00+00:00</published><updated>2010-06-02T09:09:00+00:00</updated><id>https://simonwillison.net/2010/Jun/2/framewalking/#atom-tag</id><summary type="html">
    
&lt;p&gt;&lt;strong&gt;&lt;a href="http://chris-lamb.co.uk/2010/06/01/appending-request-url-sql-statements-django/"&gt;Appending the request URL to SQL statements in Django&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;
A clever frame-walking monkey-patch which pulls the most recent HttpRequest object out of the Python stack and adds the current request.path to each SQL query as an SQL comment, so you can see it in debugging tools such as slow query logs and the PostgreSQL “select * from pg_stat_activity” query.


    &lt;p&gt;Tags: &lt;a href="https://simonwillison.net/tags/chris-lamb"&gt;chris-lamb&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/debugging"&gt;debugging&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/django"&gt;django&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/orm"&gt;orm&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/postgresql"&gt;postgresql&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/python"&gt;python&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/sql"&gt;sql&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/recovered"&gt;recovered&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/monkeypatch"&gt;monkeypatch&lt;/a&gt;&lt;/p&gt;



</summary><category term="chris-lamb"/><category term="debugging"/><category term="django"/><category term="orm"/><category term="postgresql"/><category term="python"/><category term="sql"/><category term="recovered"/><category term="monkeypatch"/></entry></feed>