<?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/"
	xmlns:creativeCommons="http://backend.userland.com/creativeCommonsRssModule">

<channel>
	<title>yergler.net &#187; python</title>
	<atom:link href="http://yergler.net/blog/category/python/feed/" rel="self" type="application/rss+xml" />
	<link>http://yergler.net</link>
	<description>Because eventually I&#039;ll be right. Theoretically.</description>
	<lastBuildDate>Tue, 31 Jan 2012 05:43:29 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>super(self.__class__, self) # end of the line for subclassing</title>
		<link>http://yergler.net/blog/2011/07/04/super-self/</link>
		<comments>http://yergler.net/blog/2011/07/04/super-self/#comments</comments>
		<pubDate>Tue, 05 Jul 2011 03:44:23 +0000</pubDate>
		<dc:creator>Nathan Yergler</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[super]]></category>

		<guid isPermaLink="false">http://yergler.net/?p=1990</guid>
		<description><![CDATA[I&#8217;ve learned (and remembered) a lot in the past two months as I&#8217;ve gotten back to coding as my primary job. One thing that I guess I never quite internalized before is how super works. I have been bitten by code that looks something like the following a few times in the past month: class [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve learned (and remembered) a lot in the past two months as I&#8217;ve gotten back to coding as my primary job. One thing that I guess I never quite internalized before is how <code>super</code> works. I have been bitten by code that looks something like the following a few times in the past month:</p>
<pre><code>
class A(object):
    def __init__(self):
        super(self.__class__, self).__init__()

class B(A):
    def __init__(self):
        super(B, self).__init__()
</code></pre>
<p>The surprise comes when I try to use my sub-class, <code>B</code>. Instantiating <code>B()</code> blows up the stack with: </p>
<p><code>RuntimeError: maximum recursion depth exceeded while calling a Python object</code>.</p>
<p>What? </p>
<p>According to the <a href="http://docs.python.org/library/functions.html#super">Python 2.7.2 standard library documentation</a>, <code>super</code> &#8220;return[s] a proxy object that delegates method calls to a parent or sibling class of type.&#8221; So in the case of single inheritance, it delegates access to the super class, it does not return an instance of the super class. In the example above, this means that when you instantiate B, the follow happens:</p>
<ol>
<li>enter <code>B.__init__()</code></li>
<li>call <code>super</code> on B and call <code>__init__</code> on the proxy object</li>
<li>enter <code>A.__init__()</code></li>
<li>call <code>super</code> on <code>self.__class__</code> and call <code>__init__</code> on the proxy object</li>
</ol>
<p>The problem is that when we get to step four, <code>self</code> still refers to our instance of <code>B</code>, so calling <code>super</code> points back to <code>A</code> again. In technical terms: Ka-bloom.</p>
<p><strong>TL;DR:</strong> <code>super(self.__class__, self)</code> may look like a neat trick, but it&#8217;s the end of the line for sub-classing.</p>
<p><strong>Further reading:</strong> Raymond Hettinger&#8217;s excellent <a href="http://rhettinger.wordpress.com/2011/05/26/super-considered-super/">blog post on super</a> provides a great overview of <code>super</code> and shows off the improved Python 3 syntax, which removes the need to write the class name as part of the <code>super</code> statement. I was really pleased to find the Python standard library documentation links directly to it.</p>
]]></content:encoded>
			<wfw:commentRss>http://yergler.net/blog/2011/07/04/super-self/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Making Fun of Objects</title>
		<link>http://yergler.net/blog/2007/02/25/making-fun-of-objects/</link>
		<comments>http://yergler.net/blog/2007/02/25/making-fun-of-objects/#comments</comments>
		<pubDate>Sun, 25 Feb 2007 18:19:22 +0000</pubDate>
		<dc:creator>Nathan Yergler</dc:creator>
				<category><![CDATA[pycon2007]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[testing]]></category>

		<guid isPermaLink="false">http://yergler.net/blog/2007/02/25/making-fun-of-objects/</guid>
		<description><![CDATA[Oh, wait; not that sort of mocking. Fine. Following the talk on using the &#8220;fixture&#8221;:http://code.google.com/p/fixture package, Jeff Younker spoke on using the &#8220;PyMock&#8221;:http://theblobshop.com/pymock/ package for unit testing with mock objects. Younker spent the first few minutes of his talk talking about unit testing in general; what I initially thought was simply a meandaring exposition on [...]]]></description>
			<content:encoded><![CDATA[<p>Oh, wait; not that sort of mocking.  Fine.  Following the talk on using the &#8220;fixture&#8221;:http://code.google.com/p/fixture package, Jeff Younker spoke on using the &#8220;PyMock&#8221;:http://theblobshop.com/pymock/ package for unit testing with mock objects.  Younker spent the first few minutes of his talk talking about unit testing in general; what I initially thought was simply a meandaring exposition on the nature of testing was actually going somewhere: adding tests to existing code can be painful, because of how intertwined things can be.  Creating mock objects can help you isolate pieces of the code from the remainder of the application.</p>
<p>PyMock makes this somewhat simpler by providing a way of &#8220;recording&#8221; what you want your mock objects to return, and the going into &#8220;play back&#8221; mode to run the test.  It provides a way to mock methods, attributes and generators on Python objects.</p>
<p>Things I&#8217;m sure of following the talk:</p>
<p>* The idea of mocking objects seems like a powerful way to isolate pieces of existing code for the purpose of testing.<br />
* Showing a slide full of code, with near-zero explanation, for only a few seconds before moving on, isn&#8217;t long enough for me to grok it; judging by the under-the-breath comments from those around me, I&#8217;m not alone in this.<br />
* Unit tests are hideously ugly when compared to the beauty of doctests.</p>
]]></content:encoded>
			<wfw:commentRss>http://yergler.net/blog/2007/02/25/making-fun-of-objects/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Testing with Fixtures</title>
		<link>http://yergler.net/blog/2007/02/25/testing-with-fixtures/</link>
		<comments>http://yergler.net/blog/2007/02/25/testing-with-fixtures/#comments</comments>
		<pubDate>Sun, 25 Feb 2007 17:48:58 +0000</pubDate>
		<dc:creator>Nathan Yergler</dc:creator>
				<category><![CDATA[pycon2007]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[testing]]></category>

		<guid isPermaLink="false">http://yergler.net/blog/2007/02/25/testing-with-fixtures/</guid>
		<description><![CDATA[Following Jim&#8217;s talk on zc.ngi, I attended Kumar McMillan talk on using Fixtures to test your programs. According to McMillan, fixtures differ from mock objects in one important way: they use real objects with real data. I haven&#8217;t used fixtures or mock objects much, so that was a useful distinction. McMillan is the developer of [...]]]></description>
			<content:encoded><![CDATA[<p>Following Jim&#8217;s talk on zc.ngi, I attended Kumar McMillan talk on using Fixtures to test your programs.  According to McMillan, fixtures differ from mock objects in one important way: they use real objects with real data.  I haven&#8217;t used fixtures or mock objects much, so that was a useful distinction.</p>
<p>McMillan is the developer of the &#8220;fixture&#8221;:http://code.google.com/p/fixture/ package, which provides a way of loading and referencing test data for your application.  <code>fixture</code> also allows you to write tests against fixture objects using either a mixin or a decorator[1].  Fixture supports loading data into SQLAlchemy and SQLObject; CSV(comma separated value) and possible Django support are also under consideration.</p>
<p>Fixture is a relatively young project, but it does appear to be useful for testing data-driven applications.</p>
<p>fn1. For testing with &#8220;nose&#8221;:http://python.org/pypi/nose.</p>
]]></content:encoded>
			<wfw:commentRss>http://yergler.net/blog/2007/02/25/testing-with-fixtures/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Testing Network Applications with NGI</title>
		<link>http://yergler.net/blog/2007/02/25/testing-network-applications-with-ngi/</link>
		<comments>http://yergler.net/blog/2007/02/25/testing-network-applications-with-ngi/#comments</comments>
		<pubDate>Sun, 25 Feb 2007 17:48:06 +0000</pubDate>
		<dc:creator>Nathan Yergler</dc:creator>
				<category><![CDATA[pycon2007]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[testing]]></category>

		<guid isPermaLink="false">http://yergler.net/blog/2007/02/25/testing-network-applications-with-ngi/</guid>
		<description><![CDATA[Following the keynote this morning, I attended Jim Fulton&#8217;s talk on testing network applications with the Network Gateway Interface. Jim advocates the use of doctests, in particular doctests which allow you to mix the documentation and narrative together (note to self: write a post about why this is compelling). When programming network applications, writing tests [...]]]></description>
			<content:encoded><![CDATA[<p>Following the keynote this morning, I attended Jim Fulton&#8217;s talk on testing network applications with the Network Gateway Interface.  Jim advocates the use of doctests, in particular doctests which allow you to mix the documentation and narrative together (note to self: write a post about why this is compelling).  When programming network applications, writing tests can be really, really hard: there can be sockets, time.sleep(), threads, etc.</p>
<p>In response to running into these problems with testing ZEO, Jim developed a library called the Network Gateway Interface (NGI).  The goal of NGI is that application code doesn&#8217;t touch socket code.  NGI splits the network application into two pieces: the application side and the implementation side.  The application side doesn&#8217;t need to be thread aware (or even safe) and uses events to communicate with the implementation side.  And the implementation side handles the actual socket or transport work.</p>
<p>Jim&#8217;s talk used the example of a simple application, z2monitoring, to demonstrate the NGI.  The goal of z2monitoring was to monitor and get status from a running Zope 2 application at the time when status is needed most: when the application is bogged down, responding to requests.  When testing with NGI, you create a special testing connection, such as a TextConnection (which just uses plain text).  The connection conforms to the <code>IConnection</code> interface, which also provides a way to set the connection handler.  The connection handler (<code>IConnectionHandler</code>, natch), is used to respond to events like input, connection close and exceptions.</p>
<p>In addition to the async, event-driven interface, zc.ngi provides a simple, blocking file-like API.  This is convenient for developing simple, single-task applications.</p>
<p>Jim spent a short part of his talk discussing about the benefits of non-determinism, such as the existing ZEO implementation.  One of these was the &#8220;opportunity for the unexpected.&#8221;  Of course, Jim also noted (with an unclear amount of irony) that production is also a form of testing.</p>
<p>NGI 1.0 was released just before PyCon, and this will probably be the last release.  [Un]fortunately, Jim recently found that Twisted provides facilities for this style of programming and testing.  Given this, zc.ngi will probably only live on (if at all) as a simplified facade over Twisted&#8217;s facilities.</p>
]]></content:encoded>
			<wfw:commentRss>http://yergler.net/blog/2007/02/25/testing-network-applications-with-ngi/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Testing Tools Panel @ PyCon</title>
		<link>http://yergler.net/blog/2007/02/24/testing-tools-panel-pycon/</link>
		<comments>http://yergler.net/blog/2007/02/24/testing-tools-panel-pycon/#comments</comments>
		<pubDate>Sat, 24 Feb 2007 23:06:19 +0000</pubDate>
		<dc:creator>Nathan Yergler</dc:creator>
				<category><![CDATA[pycon2007]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[testing]]></category>

		<guid isPermaLink="false">http://yergler.net/blog/2007/02/24/testing-tools-panel-pycon/</guid>
		<description><![CDATA[&#8220;Matt&#8221;:http://panela.blog-city.com/ summarizes the PyCon&#8217;s Testing Tools Panel far better than I could &#8220;here&#8221;:http://panela.blog-city.com/testing_tools_panel_pycon.htm. I was also hoping for some more&#8230; depth, perhaps? I think that a problem with both the web frameworks and testing tools panels is that they had too many participants for the half-hour-ish time slot. Regardless it served as a good overview [...]]]></description>
			<content:encoded><![CDATA[<p>&#8220;Matt&#8221;:http://panela.blog-city.com/ summarizes the PyCon&#8217;s Testing Tools Panel far better than I could &#8220;here&#8221;:http://panela.blog-city.com/testing_tools_panel_pycon.htm.  I was also hoping for some more&#8230; depth, perhaps?  I think that a problem with both the web frameworks and testing tools panels is that they had too many participants for the half-hour-ish time slot.  Regardless it served as a good overview of the available tools (if nothing else giving me a list to start Googling from).</p>
]]></content:encoded>
			<wfw:commentRss>http://yergler.net/blog/2007/02/24/testing-tools-panel-pycon/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Scaling Python on the Web</title>
		<link>http://yergler.net/blog/2007/02/24/scaling-python-on-the-web/</link>
		<comments>http://yergler.net/blog/2007/02/24/scaling-python-on-the-web/#comments</comments>
		<pubDate>Sat, 24 Feb 2007 17:35:29 +0000</pubDate>
		<dc:creator>Nathan Yergler</dc:creator>
				<category><![CDATA[pycon2007]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://yergler.net/blog/2007/02/24/scaling-python-on-the-web/</guid>
		<description><![CDATA[First session of the day was on Scaling Python on the Web; rough notes which I may clean up later: * How fast is fast enough? ** Don&#8217;t prematurely optimize ** *Know* where the bottlenecks are, and optimize those specifically? * Orders of magnitude: static (httpd), dynamic (python), db-queried * Even 40 req/s in 3.4m [...]]]></description>
			<content:encoded><![CDATA[<p>First session of the day was on Scaling Python on the Web; rough notes which I may clean up later:</p>
<p>* How fast is fast enough?<br />
** Don&#8217;t prematurely optimize<br />
** *Know* where the bottlenecks are, and optimize those specifically?<br />
* Orders of magnitude: static (httpd), dynamic (python), db-queried<br />
* Even 40 req/s in 3.4m pages/day<br />
* Hundreds to low thousands of dynamic page views is usually good enough<br />
* Scaling isn&#8217;t about the language, it&#8217;s about:<br />
** DRY: cache!<br />
** share nothing<br />
* built a sample photo-app, FlickrKillr, for demonstration purposes<br />
** preloaded with 100k&#8217;s users, 10-20 photos each<br />
* first iteration: CGI<br />
** roughly 23 requests/second<br />
** problems:<br />
*** loading Python interpreter for each request<br />
*** all resources initialized for each request (inc. db connection)<br />
** possible remedies:<br />
*** run a Python web server (long-running process)<br />
*** make one db connection per thread instead of request<br />
** other remedies:<br />
*** fastcgi<br />
*** snakelets, twisted.web, RhubarbTart<br />
*** mod_python<br />
* second iteration: python app server (CherryPy used for this demo)<br />
** roughly 139 requests per second<br />
** problems<br />
*** global interpreter lock &#8212; can only utilize one core on a dual core machine<br />
*** sessions in the database &#8212; prefer an in-memory session store<br />
** remedies:<br />
*** run multiple instances of CherryPy (overcode GIL)<br />
*** but then we need to balance with something like nginx<br />
** other options<br />
*** cherrypy in mod_python<br />
* version 3: load balancing with nginx<br />
** 217 requests/sec<br />
** outstanding problems<br />
*** static files read from disk every time<br />
*** and they&#8217;re being read/written from python<br />
** solutions:<br />
*** memcached<br />
*** combine with memcached w/ nginx<br />
* version 4: caching<br />
** 616 req/sec (benchmarking w/ homegrown tool)<br />
** 1750 req/sec (benchmarking w/ ab)<br />
* other notes:<br />
** don&#8217;t forget to index<br />
** without an index, the fourth iteration falls down to 28 requests/sec</p>
<p>http://www.polimetrix.com/pycon/demo.tar.gz</p>
]]></content:encoded>
			<wfw:commentRss>http://yergler.net/blog/2007/02/24/scaling-python-on-the-web/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Keynote: Adele Goldberg</title>
		<link>http://yergler.net/blog/2007/02/24/keynote-adele-goldberg/</link>
		<comments>http://yergler.net/blog/2007/02/24/keynote-adele-goldberg/#comments</comments>
		<pubDate>Sat, 24 Feb 2007 16:52:25 +0000</pubDate>
		<dc:creator>Nathan Yergler</dc:creator>
				<category><![CDATA[education]]></category>
		<category><![CDATA[pycon2007]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://yergler.net/blog/2007/02/24/keynote-adele-goldberg/</guid>
		<description><![CDATA[The morning keynote for day 2 of PyCon was given by &#8220;Adele Goldberg&#8221;:http://en.wikipedia.org/wiki/Adele_Goldberg_%28computer_scientist%29. Unfortunately I overslept this morning and missed the first half of the talk[1]. Goldberg&#8217;s topic was eLearning, and the state of computing in education today. My background working in education is very different from the schools she was talking about: she&#8217;s apparently [...]]]></description>
			<content:encoded><![CDATA[<p>The morning keynote for day 2 of PyCon was given by &#8220;Adele Goldberg&#8221;:http://en.wikipedia.org/wiki/Adele_Goldberg_%28computer_scientist%29.  Unfortunately I overslept this morning and missed the first half of the talk[1].  Goldberg&#8217;s topic was eLearning, and the state of computing in education today.  My background working in education is very different from the schools she was talking about: she&#8217;s apparently been working with computer-based learning in public schools, and studying the aggregate information about the results.  My experience was working for a private, K-12, well-funded (regardless of what administrators ever said, the truism was that if they wanted money to be there, money would be there) school.  So a lot of the statistics about teachers complaining about computers being out of date didn&#8217;t apply.</p>
<p>But the other things, about what works and what doesn&#8217;t, just isn&#8217;t a suprise.  I wish I could remember the examples through the lack-of-coffee haze, but I was suprised by the similarity &#8212; I would have thought &#8220;money changes everything&#8221; (to quote the Cindi).  And two points that hit home: teachers (in the aggregate, I presume) haven&#8217;t had a pay raise of more than 1% since the 1990-1991 school year, and that the way to get students to learn is to get them to build things and explain what they built to other students.</p>
<p>I was exposed to the latter theory in my Software Engineering course at &#8220;IPFW&#8221;:http://ipfw.edu.  Dr. Modesitt, on the first day of class, presented the idea that there are five levels of learning, with lecturing being the least effective, up to building as the second most effective, and teaching others being the most effective.  Now Dr. Modesitt used this to set the stage for how the class would be structured, with most of the work occuring at those upper two levels.  And that class was like drinking from the firehose, but I _did_ learn a lot.  So although it was in a completely different context, I can attest that it really works.</p>
<p>It was also interesting to hear that Goldberg had built a course/school system on Zope 2 (hmm, that &#8220;sounds familiar&#8221;:http://tech.canterburyschool.org/tech/STOA), and that she&#8217;s currently working on rewriting it in Zope 3.  And in building that from an &#8220;instructional&#8221; perspective versus &#8220;content management&#8221; perspective (which is what STOA(Student Teacher Online Applications) definitely has).  The new tool, CourseCloud, uses XML to represent exercises and instructional content, with the goal being to present the exercises in multiple contexts.</p>
<hr noshade />
<p>fn1. What? I had two hours of sleep the night before, and wound up buying Age of Empires III for my MacBook at Fry&#8217;s and stayed up, well, later than planned.</p>
]]></content:encoded>
			<wfw:commentRss>http://yergler.net/blog/2007/02/24/keynote-adele-goldberg/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Web, Web Afternoon</title>
		<link>http://yergler.net/blog/2007/02/23/web-web-afternoon/</link>
		<comments>http://yergler.net/blog/2007/02/23/web-web-afternoon/#comments</comments>
		<pubDate>Fri, 23 Feb 2007 22:10:01 +0000</pubDate>
		<dc:creator>Nathan Yergler</dc:creator>
				<category><![CDATA[pycon2007]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[wsgi]]></category>

		<guid isPermaLink="false">http://yergler.net/blog/2007/02/23/web-web-afternoon/</guid>
		<description><![CDATA[Lunch: tasty &#8220;Mexican&#8221; food, including those tasty cinnamon-sugar coated crunchy-chewy desserty things. Lots of those. And after lunch, it&#8217;s fun with Python on the Web. The first afternoon talk was &#8220;Ian Bicking&#8217;s&#8221;:http://ianbicking.org/ _Everything You Wanted to Know About WSGI but were Afraid to Ask_. OK, that&#8217;s just my title; it&#8217;s really &#8220;WSGI: An Introduction&#8221;:http://blog.ianbicking.org/going-to-pycon-2007.html. &#8220;WSGI&#8221;:http://en.wikipedia.org/wiki/WSGI [...]]]></description>
			<content:encoded><![CDATA[<p>Lunch: tasty &#8220;Mexican&#8221; food, including those tasty cinnamon-sugar coated crunchy-chewy desserty things.  Lots of those.</p>
<p>And after lunch, it&#8217;s fun with Python on the Web.  The first afternoon talk was &#8220;Ian Bicking&#8217;s&#8221;:http://ianbicking.org/ _Everything You Wanted to Know About WSGI but were Afraid to Ask_.  OK, that&#8217;s just my title; it&#8217;s really &#8220;WSGI: An Introduction&#8221;:http://blog.ianbicking.org/going-to-pycon-2007.html.    &#8220;WSGI&#8221;:http://en.wikipedia.org/wiki/WSGI is a specification for connecting pieces of web applications in Python.  It&#8217;s something (like Eggs) that I can conceptually understand as being important.  But (like Eggs) I have a hard time really groking it.</p>
<p>WSGI provides for this idea known as Middleware, which allows you to wrap your applications in, uh, other applications.  Ian actually had a good litmus test for what is middleware: if you code is acting as both a client *and* a server, then by definition it is middleware.  Ian also spent some time discussing the idea of &#8220;microframeworks&#8221;, pieces of software that don&#8217;t provide this full stack but can be combined in interesting ways to build something bigger.  So yeah, WSGI: darn cool.</p>
<p>Following the WSGI talk was the Python Web Framework Panel, with representatives from Zope, CherryPy, Pylons, Django, TurboGears, Pyjamas, Spyce and Nevow[1].  Nothing really ground-breaking, but Bob Brewer of CherryPy did make an amusing comment: &#8220;Reinventing the wheel isn&#8217;t so bad if you&#8217;re really interested in wheels.&#8221;  What did sort of annoy me is the multitude of comments from creators about &#8220;looking at Zope and running away screaming.&#8221;  Look, I agree that Zope isn&#8217;t for everyone.  I also agree with Phillip: &#8220;where Zope leads, Python follows&#8221;:http://dirtsimple.org/2007/01/where-zope-leads-python-follows.html.  I don&#8217;t know when Zope became the Python web community&#8217;s collective bitch.</p>
<p>Now, off to my friend Vern&#8217;s talk about teaching with Python (and dumping that tired hag &#8220;hello, world&#8221;), then a nap, lightning talks and finally Shawn and I make our annual pilgrimage to Fry&#8217;s.</p>
<p>fn1. Apologies if I missed one; this is from memory.</p>
]]></content:encoded>
			<wfw:commentRss>http://yergler.net/blog/2007/02/23/web-web-afternoon/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ccPublisher, Python and XML</title>
		<link>http://yergler.net/blog/2005/09/08/ccpublisher-python-and-xml/</link>
		<comments>http://yergler.net/blog/2005/09/08/ccpublisher-python-and-xml/#comments</comments>
		<pubDate>Thu, 08 Sep 2005 21:56:35 +0000</pubDate>
		<dc:creator>Nathan Yergler</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://yergler.net/blog/?p=326</guid>
		<description><![CDATA[So two days ago I launched the first &#8220;Developer Preview of ccPublisher 2&#8243;:http://creativecommons.org/weblog/entry/5606 for Linux, promising Windows and Mac OS X builds &#8220;within the day.&#8221; It&#8217;s been two days, they&#8217;re not uploaded, what&#8217;s going on? Funny you should ask. It actually has a lot to do with something else that&#8217;s been generating a lot of [...]]]></description>
			<content:encoded><![CDATA[<p>So two days ago I launched the first &#8220;Developer Preview of ccPublisher 2&#8243;:http://creativecommons.org/weblog/entry/5606 for Linux, promising Windows and Mac OS X builds &#8220;within the day.&#8221; It&#8217;s been two days, they&#8217;re not uploaded, what&#8217;s going on?  Funny you should ask.  It actually has a lot to do with something else that&#8217;s been generating a lot of discussion lately on Python blogs: XML.</p>
<p>&#8220;Philip J. Eby&#8221;:http://dirtsimple.org/, the mastermind behind things like PEAK and Python Eggs, wrote a &#8220;blog post&#8221;:http://dirtsimple.org/2005/08/chandler-begins-recovery-from-xml.html last month titled &#8220;Chandler Begins Recovery from XML&#8221;:http://dirtsimple.org/2005/08/chandler-begins-recovery-from-xml.html  This follows his self-described rant from late last year, &#8220;Python is not Java&#8221;:http://dirtsimple.org/2004/12/python-is-not-java.html where he took developers to task for, among other things, turning to XML as the solution to all your data and configuration woes.  The gist was, it might work for Java, but when mixed with Python it&#8217;s nothing but a boat anchor.  So how is &#8220;Chandler&#8221;:http://osafoundation.org &#8220;recovering&#8221; from XML? By dumping it.  Their system for extending Chandler, parcels, previously used an XML file to define extension points and connections (roughly &#8212; I won&#8217;t claim really deep knowledge here).  The new system, championed by PJE, uses Python syntax and code &#8212; descriptors, registrations, etc &#8212; to accomplish the same thing.  PJE&#8217;s argument, as I read it, hinges not on the idea that XML is inherently evil, but rather that using XML is often a sign of over-engineering.  As a believer in YAGNI (Ya Ain&#8217;t Gonna Need It) in software development, I can agree with that.</p>
<p>So what does this have to do with ccPublisher 2, and more importantly the delayed Developer Preview packages?  Let me address the two parts of that question in sequence.</p>
<p><span id="more-326"></span><br />
First, what does it have to do with ccPublisher 2?  A major design goal of ccPublisher 2 is enabling third-party contributions, in the form of extensions and derivative applications.  We&#8217;re doing this in a number of ways, including basic things like improved documentation.  A major tactic, though, is the use of loosely coupled pieces of code that are intentionally ignorant about one another.  For example, an MP3 file contains metadata in the form of ID3 tags.  The object that wraps the generic file doesn&#8217;t know this, but it knows it can say &#8220;Hey, all you components &#8212; anyone know anything about this here file-thingy?&#8221; and an adapter object will respond with everything it knows.  So in theory (and in practice, actually &#8212; this mostly works already) you can swap out or add objects that respond without major surgery.  A huge improvement over the ccPublisher 1 codebase.  All these bits of code are tied together by XML files that describe subscriptions, adapters and interfaces.  I chose the ZCML format, developed as part of the Zope3 project, because I was familiar with it, and because I was reasonably confident I could use code from Zope3 to make my life easier.  And it turns out I was right &#8212; ZCML was reasonably easy to separate from Zope3.  It&#8217;s also made life somewhat easier, and it will let non-coders who need customized metadata fields to add them relatively easily (note that I haven&#8217;t actually decided if non-coders will actually need to do this, it&#8217;s just the easiest rationalization right now).</p>
<p>So after reading Philip&#8217;s rant(s) and background on deprecating XML configuration files in Chandler, I started thinking about the suitability of ZCML for the task at hand.  ZCML makes a lot of sense for Zope3 &#8212; a big advantage (in my mind) of Zope3 over previous versions is that (in theory) you can take existing classes that model data or behavior and use them in Zope without making them Zope-specific.  In that case moving the configuration and registration into external files helps with that goal.  ccPublisher doesn&#8217;t have that goal or that baggage &#8212; anything used in ccPublisher will probably be ccPublisher-ized in some way.  I&#8217;m not convinced that ZCML is the wrong choice for ccPublisher, but the talk has had the effect of making me think about it more now than I did earlier.</p>
<p>Now, on to the second question &#8212; why the delay.  Well, it turns out that ZCML makes life a bit more difficult when packaging your code.  Linux wasn&#8217;t a problem &#8212; you just use <code>distutils</code> and specify a <code>recursive-include</code> in the MANIFEST.in.  Windows is a different story &#8212; we&#8217;re using py2exe, which means there are two problems: first, py2exe ignores the MANIFEST.in when finding modules to include.  This makes a certain perverse sense, but it still bites you in the ass.  After hacking up a script to include the ZCML along side the Python byte-code, though, you [I] realize something &#8212; the byte code is in a ZIP file, and your code doesn&#8217;t traverse into ZIP files (ala &#8220;PEP 302&#8243;:http://www.python.org/peps/pep-0302.html) to retrieve the ZCML resources properly.  Additionally, even though you can set up a dummy tree along side library.zip containing the ZCML, the Python pathing makes things, well, ugly.  Really ugly.  Sigh.</p>
<p>So ccPublisher 2 Developer Preview is slightly delayed on Windows while we make some retrofits to the code. The solution I&#8217;ve decided on is &#8220;Python Eggs&#8221;:http://peak.telecommunity.com/DevCenter/PythonEggs.  Eggs let you package your Python code, make explicit declarations about dependencies and (most importantly for this situation) &#8220;access non-code resources&#8221;:http://peak.telecommunity.com/DevCenter/PythonEggs#accessing-package-resources stored in the package.</p>
<p>So interestly, PJE appears to have the ability to spark concern as well as solve weird edge-case problems.</p>
]]></content:encoded>
			<wfw:commentRss>http://yergler.net/blog/2005/09/08/ccpublisher-python-and-xml/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>ZConfig 2.0 Released</title>
		<link>http://yergler.net/blog/2003/11/03/zconfig-20-released/</link>
		<comments>http://yergler.net/blog/2003/11/03/zconfig-20-released/#comments</comments>
		<pubDate>Mon, 03 Nov 2003 15:30:43 +0000</pubDate>
		<dc:creator>Nathan Yergler</dc:creator>
				<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://yergler.net/blog/archives/2003/11/03/zconfig-20-released</guid>
		<description><![CDATA[I just saw on the &#8220;Python Daily URL&#8221;:http://www.pythonware.com/daily that &#8220;ZConfig 2.0&#8243;:http://www.zope.org/Members/fdrake/zconfig/ is out. I migrated our internal backup software to ZConfig from Python&#8217;s included &#8220;ConfigParser&#8221;:http://www.python.org/doc/lib/module-ConfigParser.html over the summer after cursing one too many times at it&#8217;s inability to do intelligent type checking. While it was a pain in the ass to create the schema and [...]]]></description>
			<content:encoded><![CDATA[<p>I just saw on the &#8220;Python Daily URL&#8221;:http://www.pythonware.com/daily that &#8220;ZConfig 2.0&#8243;:http://www.zope.org/Members/fdrake/zconfig/ is out.  I migrated our internal backup software to ZConfig from Python&#8217;s included &#8220;ConfigParser&#8221;:http://www.python.org/doc/lib/module-ConfigParser.html over the summer after cursing one too many times at it&#8217;s inability to do intelligent type checking.  While it was a pain in the ass to create the schema and grok the datatypes set up, it was well worth it.  Finally, config files you can actually read!</p>
]]></content:encoded>
			<wfw:commentRss>http://yergler.net/blog/2003/11/03/zconfig-20-released/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

