<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>miscellaneous factZ - The online home of Rufus Pollock &#187; Code</title>
	<atom:link href="http://rufuspollock.org/tags/code/feed/" rel="self" type="application/rss+xml" />
	<link>http://rufuspollock.org</link>
	<description></description>
	<lastBuildDate>Thu, 02 Sep 2010 14:42:26 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Using Deliverance as Middleware (with Proxying)</title>
		<link>http://rufuspollock.org/2009/12/21/using-deliverance-as-middleware-with-proxying/</link>
		<comments>http://rufuspollock.org/2009/12/21/using-deliverance-as-middleware-with-proxying/#comments</comments>
		<pubDate>Mon, 21 Dec 2009 15:00:51 +0000</pubDate>
		<dc:creator>Rufus Pollock</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://www.rufuspollock.org/?p=467</guid>
		<description><![CDATA[Deliverance is a great library that lets you easily re-theme external websites on the fly. Designed as WSGI middleware, it can be easily combined with some proxying to integrate a bunch of websites together 

You can use deliverance plus proxying out-of-the-box using the deliverance-proxy command. However, I was interested in using Deliverance as middleware from [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://pypi.python.org/pypi/Deliverance/">Deliverance</a> is a great library that lets you easily re-theme external websites on the fly. Designed as WSGI middleware, it can be easily combined with some proxying to integrate a bunch of websites together </p>

<p>You can use deliverance plus proxying out-of-the-box using the deliverance-proxy command. However, I was interested in using Deliverance as middleware <strong>from code</strong>. This turned out to be none too trivial to do &#8212; all the examples on the internet seemed to focus on using deliverance-proxy or using it in an ini file.</p>

<p>After much wrestling, most notably with odd issues with gzipped (deflated) content I got it working and you can find a demo implementation (see <a href="http://rufuspollock.org/code/deliverance/demo.py">demo.py</a> and <a href="http://rufuspollock.org/code/deliverance/README.txt">README.txt</a>) here:</p>

<p><a href="http://rufuspollock.org/code/deliverance/">http://rufuspollock.org/code/deliverance/</a></p>

<p>I should also mention the following sources which were all of help in my quest: </p>

<ul>
<li><a href="http://codespeak.net/svn/z3/deliverance/sandbox/ianb/ploneconf2008/index.txt">http://codespeak.net/svn/z3/deliverance/sandbox/ianb/ploneconf2008/index.txt</a></li>
<li><a href="http://www.gawel.org/weblog/en/2008/12/skinning-with-pyquery-and-deliverance">http://www.gawel.org/weblog/en/2008/12/skinning-with-pyquery-and-deliverance</a></li>
<li><a href="http://macadames.wordpress.com/2009/05/23/some-deliverance-tips/">http://macadames.wordpress.com/2009/05/23/some-deliverance-tips/</a></li>
<li><a href="http://www.coactivate.org/projects/deliverance/lists/deliverance-discussion/archive/2009/05/1241444934295/forum_view">http://www.coactivate.org/projects/deliverance/lists/deliverance-discussion/archive/2009/05/1241444934295/forum_view</a></li>
<li><a href="http://www.sixfeetup.com/blog/2009/4/27/deploying-plone-and-zine-together-with-deliverance-using-repoze">http://www.sixfeetup.com/blog/2009/4/27/deploying-plone-and-zine-together-with-deliverance-using-repoze</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://rufuspollock.org/2009/12/21/using-deliverance-as-middleware-with-proxying/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Reverse Proxying to Wordpress.com</title>
		<link>http://rufuspollock.org/2009/10/02/reverse-proxying-to-wordpresscom/</link>
		<comments>http://rufuspollock.org/2009/10/02/reverse-proxying-to-wordpresscom/#comments</comments>
		<pubDate>Fri, 02 Oct 2009 10:50:11 +0000</pubDate>
		<dc:creator>Rufus Pollock</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Hacks]]></category>
		<category><![CDATA[Sysadmin]]></category>

		<guid isPermaLink="false">http://www.rufuspollock.org/2009/10/02/reverse-proxying-to-wordpresscom/</guid>
		<description><![CDATA[I wanted to do a reverse proxy to wordpress.com in order to integrate an existing wordpress.com blog into an existing site. This turned out to be a little trickier than I&#8217;d thought due to wordpress.com&#8217;s usage of gzip deflation of their output.

Figured this out thanks to sound advice here and here:

  ...

  &#60;Proxy [...]]]></description>
			<content:encoded><![CDATA[<p>I wanted to do a reverse proxy to wordpress.com in order to integrate an existing wordpress.com blog into an existing site. This turned out to be a little trickier than I&#8217;d thought due to wordpress.com&#8217;s usage of gzip deflation of their output.</p>

<p>Figured this out thanks to sound advice <a href="http://www.apachetutor.org/admin/reverseproxies">here</a> and <a href="http://wiki.uniformserver.com/index.php/Reverse_Proxy_Server_2:_mod_proxy_html_2">here</a>:</p>

<pre><code>  ...

  &lt;Proxy *&gt;
        Allow from .mysite.com
  &lt;/Proxy&gt;
  ProxyPass / myblog.wordpress.com
  ProxyPassReverse / http://myblog.wordpress.com/
  ProxyHTMLURLMap http://myblog.wordpress.com/ /
  &lt;Location /&gt;
    SetOutputFilter proxy-html
    # get rid of Content-Encoding at wordpress end
    # To use this you'll need to do (on debian) a2enmod headers
    RequestHeader unset  Accept-Encoding

    # Alternative method: inflate then deflate again ... (requires more effort at our end)
    # Could NOT get this to work (though suggested by both reference sites!)
    # SetOutputFilter INFLATE;proxy-html;DEFLATE
  &lt;/Location&gt;

  ....
</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://rufuspollock.org/2009/10/02/reverse-proxying-to-wordpresscom/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Flexible Dates in Python (including BC)</title>
		<link>http://rufuspollock.org/2009/06/18/flexible-dates-in-python/</link>
		<comments>http://rufuspollock.org/2009/06/18/flexible-dates-in-python/#comments</comments>
		<pubDate>Thu, 18 Jun 2009 19:37:09 +0000</pubDate>
		<dc:creator>Rufus Pollock</dc:creator>
				<category><![CDATA[Books]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Innovation and Intellectual Property]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://www.rufuspollock.org/?p=537</guid>
		<description><![CDATA[I&#8217;ve had occasion recently to frequently work with &#8220;dates&#8221; that come in a lot of shapes and sizes including:


Dates in distant past and future including BC/BCE dates
Dates in a wild variety of formats: Jan 1890, January 1890, 1st Dec 1890, Spring 1890 etc
Dates of varying precision: e.g. 1890, 1890-01 (i.e. Jan 1890), 1890-01-02
Imprecise dates: c1890, [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve had <a href="http://www.rufuspollock.org/2009/03/12/computing-copyright-or-public-domain-status-of-cultural-works/">occasion</a> <a href="http://www.rufuspollock.org/2009/06/12/the-size-of-the-public-domain/">recently</a> to frequently work with &#8220;dates&#8221; that come in a lot of shapes and sizes including:</p>

<ul>
<li>Dates in distant past and future including BC/BCE dates</li>
<li>Dates in a wild variety of formats: Jan 1890, January 1890, 1st Dec 1890, Spring 1890 etc</li>
<li>Dates of varying precision: e.g. 1890, 1890-01 (i.e. Jan 1890), 1890-01-02</li>
<li>Imprecise dates: c1890, 1890?, fl 1890 etc</li>
</ul>

<p>Unfortunately existing support for these in python is fairly weak. I therefore authored a python FlexiDate module (part of a new <a href="http://pypi.python.org/pypi/swiss/">swiss (army knife) package</a>) which is focused on supporting:</p>

<ol>
<li>Dates outside of Python (or DB) supported period (esp. dates &lt; 0 AD)</li>
<li>Imprecise dates (c.1860, 18??, fl. 1534, etc)</li>
<li>Normalization of these dates to machine processable versions especially:
<ul><li>ISO 8601</li>
<li>Dates sortable in the database (in correct date order)</li></ul></li>
</ol>

<h2>Background</h2>

<p>Things we would like:</p>

<ol>
<li>Dates outside of Python (or DB) supported period (esp. dates &lt; 0 AD)</li>
<li>Imprecise dates (c.1860, 18??, fl. 1534, etc)</li>
<li>Normalization of dates to machine processable versions</li>
<li>Sortable in the database (in correct date order)</li>
<li>Human readability as dates will be re-edited/viewed by people</li>
</ol>

<p>Not all of these requirements are satisfiable at once in a simple way.</p>

<p>Be clear about what we want:</p>

<ol>
<li>Storage (and preservation) of &#8220;user&#8221; dates (both normal and non-normal)</li>
<li>Normalization of dates (e.g. to ~ ISO 8601)</li>
<li>Integration with database (sortability and serializability)</li>
</ol>

<p>Solution for 1: Represent dates as strings.</p>

<p>Solution for 2: Have a parser (via an intermediate FlexiDate object).</p>

<p>Solution for 3: convert to a float.</p>

<p>Remark: no string based date format will sort dates correctly based on std
string ordering (PF: let x,y be +ve dates and X,Y their string representations
then if X<y => -X&lt;-Y (wrong!))</y></p>

<p>Thus we need to add some other field if we wish dates to be correctly sorted
(or not worry about sorting of -ve dates &#8230;)</p>

<ol>
<li>For any given date attribute have 2 actual fields:</li>
</ol>

<ul>
<li>user version &#8212; the version edited by users</li>
<li>normalized/parsed version &#8212; a version that is usable by machines</li>
</ul>

<p>2. Store both versions in a single field but with some form of serialization.</p>

<ol>
<li>Convert dates to long ints (unlimited in precision) and put this in a
separate field and use that for sorting.</li>
</ol>

<h3>Comments</h3>

<p>Initially thought that we should parse before saving into a FlexiDate format
but: a) why bother b) when parsing always hard not to be lossy (in particular
when converting to iso8601 using e.g. dateutil very difficult to not add info
e.g. parsing 1860 can easily give us 1860-01-01 &#8230;).</p>

<h3>References and Existing Libraries</h3>

<ul>
<li>Excellent dateutil (which we use0</li>
<li>http://wiki.python.org/moin/WorkingWithTime</li>
<li>ISO 8601: http://www.iso.org/iso/date<em>and</em>time_format
<ul><li>http://code.google.com/p/pyiso8601/source/browse/trunk/iso8601/iso8601.py</li></ul></li>
<li>http://www.feedparser.org/docs/date-parsing.html</li>
<li>http://seehuhn.de/pages/pdate</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://rufuspollock.org/2009/06/18/flexible-dates-in-python/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
