<?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>crazed monkey &#187; python</title>
	<atom:link href="http://crazedmonkey.com/blog/category/python/feed" rel="self" type="application/rss+xml" />
	<link>http://crazedmonkey.com/blog</link>
	<description>Ian Stevens&#039; weblog</description>
	<lastBuildDate>Thu, 02 Feb 2012 20:37:48 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
<atom:link rel="hub" href="http://pubsubhubbub.appspot.com"/><atom:link rel="hub" href="http://superfeedr.com/hubbub"/>		<item>
		<title>BFG is a &#8220;pay only for what you eat&#8221; web framework</title>
		<link>http://crazedmonkey.com/blog/python/bfg-is-a-pay-only-for-what-you-eat-web-framework.html</link>
		<comments>http://crazedmonkey.com/blog/python/bfg-is-a-pay-only-for-what-you-eat-web-framework.html#comments</comments>
		<pubDate>Wed, 04 Aug 2010 20:53:19 +0000</pubDate>
		<dc:creator>Ian Stevens</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[links]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://crazedmonkey.com/blog/links/bfg-is-a-pay-only-for-what-you-eat-web-framework.html</guid>
		<description><![CDATA[<p>BFG is based on WSGI and is from the same guys who brought you worked on the Repoze project. BFG only provides URL mapping, templating and security; the rest is up to you.</p> <p>What I like about BFG (after a few minutes of perusal): views as callables (meaning you can define a view class), built-in&#160;&#8230;&#160;<a class="read_more" href="http://crazedmonkey.com/blog/python/bfg-is-a-pay-only-for-what-you-eat-web-framework.html" rel="bookmark" title="Continue reading &#8220;BFG is a &#8220;pay only for what you eat&#8221; web framework&#8221;"><span>Read more</span></a>]]></description>
			<content:encoded><![CDATA[<p>BFG is based on WSGI and is from the same guys who brought you worked on the Repoze project. BFG only provides URL mapping, templating and security; the rest is up to you.</p>
<p>What I like about BFG  (after a few minutes of perusal): views as callables (meaning you can define a view class), built-in permissions-based security (although rolling your own is fairly trivial), built-in event listeners (although, again, rolling your own observer pattern is trivial).</p>
<p>What I don&#8217;t like about BFG: ZCML configuration (XML, as opposed to Python), no Mako template support yet (although I&#8217;m sure I&#8217;d be OK with Chameleon).</p>
]]></content:encoded>
			<wfw:commentRss>http://crazedmonkey.com/blog/python/bfg-is-a-pay-only-for-what-you-eat-web-framework.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Extend py2exe to copy files to the zipfile where pkg_resources can load them</title>
		<link>http://crazedmonkey.com/blog/python/pkg_resources-with-py2exe.html</link>
		<comments>http://crazedmonkey.com/blog/python/pkg_resources-with-py2exe.html#comments</comments>
		<pubDate>Mon, 03 Nov 2008 18:52:57 +0000</pubDate>
		<dc:creator>Ian Stevens</dc:creator>
				<category><![CDATA[python]]></category>
		<category><![CDATA[py2exe]]></category>

		<guid isPermaLink="false">http://crazedmonkey.com/blog/?p=380</guid>
		<description><![CDATA[<p>In creating a Windows PDF generation app for a client of mine, I ran into a limitation of <a href="http://py2exe.org">py2exe</a> which prevents resource loading with <a href="http://peak.telecommunity.com/DevCenter/PkgResources">pkg_resources</a>. The module attempts to load resources from py2exe&#8217;s library.zip. As the zipfile is reserved for compiled bytecode, there&#8217;s no option to copy files into it. You can copy&#160;&#8230;&#160;<a class="read_more" href="http://crazedmonkey.com/blog/python/pkg_resources-with-py2exe.html" rel="bookmark" title="Continue reading &#8220;Extend py2exe to copy files to the zipfile where pkg_resources can load them&#8221;"><span>Read more</span></a>]]></description>
			<content:encoded><![CDATA[<p>In creating a Windows PDF generation app for a client of mine, I ran into a limitation of <a href="http://py2exe.org">py2exe</a> which prevents resource loading with <a href="http://peak.telecommunity.com/DevCenter/PkgResources">pkg_resources</a>. The module attempts to load resources from py2exe&#8217;s <code>library.zip</code>. As the <code>zipfile</code> is reserved for compiled bytecode, there&#8217;s no option to copy files into it. You can copy files using py2exe&#8217;s <code>data_files</code>, but not into the <code>zipfile</code>, and <code>package_data</code> isn&#8217;t honoured.  You can, however, extend the <code>py2exe</code> class, and that&#8217;s what I did.</p>
<p>The best entry point I could find was <code>copy_extensions()</code>. You can override that method to copy files into the build directory. You&#8217;ll want to create the necessary directories if they don&#8217;t already exist and then register the copied files for copying to <code>dist</code>. Here&#8217;s an example with images in a <code>foo</code> module&#8217;s media directory:</p>
<pre><code>import os
import glob
from py2exe.build_exe import py2exe as build_exe

class MediaCollector(build_exe):
    def copy_extensions(self, extensions):
        super(MediaCollector, self).copy_extensions(extensions)

        # Create the media subdir where the
        # Python files are collected.
        media = os.path.join('foo', 'media')
        full = os.path.join(self.collect_dir, media)
        if not os.path.exists(full):
            self.mkpath(full)

        # Copy the media files to the collection dir.
        # Also add the copied file to the list of compiled
        # files so it will be included in zipfile.
        for f in glob.glob('foo/media/*'):
            name = os.path.basename(f)
            self.copy_file(f, os.path.join(full, name))
            self.compiled_files.append(os.path.join(media, name))</code></pre>
<p>Strictly speaking, resources are not compiled files but treating them as such was the only way I could find to force them to be included in the zipfile. To use this new collector, just specify it in your py2exe options:</p>
<pre><code>py2exe_options = {
    'cmdclass': {'py2exe': MediaCollector},
    # [...] Other py2exe options here.
}

setup(
    # [...] Other setup options here.
    **py2exe_options
)</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://crazedmonkey.com/blog/python/pkg_resources-with-py2exe.html/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Python bindings for ImageMagick&#8217;s MagickWand API</title>
		<link>http://crazedmonkey.com/blog/python/python-imagemagick-magickwand.html</link>
		<comments>http://crazedmonkey.com/blog/python/python-imagemagick-magickwand.html#comments</comments>
		<pubDate>Fri, 14 Mar 2008 16:23:23 +0000</pubDate>
		<dc:creator>Ian Stevens</dc:creator>
				<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://crazedmonkey.com/blog/python/python-bindings-for-imagemagicks-magickwand-api.html</guid>
		<description><![CDATA[<p>I&#8217;ve been spending some of my spare time recently putting together some <a href="http://www.assembla.com/wiki/show/pythonmagickwand">Python bindings for ImageMagick&#8217;s MagickWand API</a>. While most bindings I&#8217;ve seen just look like generated ctypes code from C header files, these bindings are more object-oriented, completely hiding the <a href="http://www.imagemagick.org/script/magick-wand.php" title="MagickWand, C API for ImageMagick">MagickWand methods</a>. While this is still in&#160;&#8230;&#160;<a class="read_more" href="http://crazedmonkey.com/blog/python/python-imagemagick-magickwand.html" rel="bookmark" title="Continue reading &#8220;Python bindings for ImageMagick&#8217;s MagickWand API&#8221;"><span>Read more</span></a>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been spending some of my spare time recently putting together some <a href="http://www.assembla.com/wiki/show/pythonmagickwand">Python bindings for ImageMagick&#8217;s MagickWand API</a>.  While most bindings I&#8217;ve seen just look like generated ctypes code from C header files, these bindings are more object-oriented, completely hiding the <a href="http://www.imagemagick.org/script/magick-wand.php" title="MagickWand, C API for ImageMagick">MagickWand methods</a>.  While this is still in the early stages, it&#8217;s workable in a way which I hope is expected and unsurprising:</p>
<pre><code>from pythonmagick.image import Image
from pythonmagick.color import BLUE
i = Image('foo.jpg')
i.format = 'PNG'
i.rotate(45, BLUE)
i.save('flip.png')</code></pre>
<p>The above reads in a JPEG image, reformats to PNG and rotates by 45 degrees with a background colour of blue.  The image is then saved to a new file.</p>
<p>This may look a lot like <a href="http://www.pythonware.com/products/pil/" title="Python Imaging Library">PIL</a> code, so why not use it instead of ImageMagick?  ImageMagick covers a much wider range of image formats than PIL, and supports better algorithms for image resizing.</p>
<p>Check out the bindings by installing them with <a href="http://peak.telecommunity.com/DevCenter/EasyInstall">easy_install</a>:</p>
<pre><code>easy_install http://svn2.assembla.com/svn/pythonmagickwand/trunk/</code></pre>
<p>On a side note, I&#8217;m quite impressed with <a href="http://assembla.com">Assembla</a>, the site which I&#8217;m using for my SVN and Trac repo.  It&#8217;s about as good as something I would deploy myself, but with much less hassle.  Honestly, these days there&#8217;s less and less reason for me to spend hours setting up stuff myself, and that&#8217;s a great thing.</p>
]]></content:encoded>
			<wfw:commentRss>http://crazedmonkey.com/blog/python/python-imagemagick-magickwand.html/feed</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
	</channel>
</rss>

