<?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:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Django'n'Flex</title>
	<atom:link href="http://djangonflex.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://djangonflex.wordpress.com</link>
	<description>Trials and Joys of working with Django and Flex</description>
	<lastBuildDate>Wed, 04 Jul 2007 13:28:52 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='djangonflex.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Django'n'Flex</title>
		<link>http://djangonflex.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://djangonflex.wordpress.com/osd.xml" title="Django&#039;n&#039;Flex" />
	<atom:link rel='hub' href='http://djangonflex.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Move Over</title>
		<link>http://djangonflex.wordpress.com/2007/07/04/move-over/</link>
		<comments>http://djangonflex.wordpress.com/2007/07/04/move-over/#comments</comments>
		<pubDate>Wed, 04 Jul 2007 13:28:52 +0000</pubDate>
		<dc:creator>Ian</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://djangonflex.wordpress.com/2007/07/04/move-over/</guid>
		<description><![CDATA[I wasn&#8217;t quite happy wityh the free wordpress package, and since I have my own server with MovableType installed, I thought I&#8217;d move the blog there. So this blog has now moved to www.djangoandflex.org.uk There will be no more posts here.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=djangonflex.wordpress.com&amp;blog=1303137&amp;post=8&amp;subd=djangonflex&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I wasn&#8217;t quite happy wityh the free wordpress package, and since I have my own server with MovableType installed, I thought I&#8217;d move the blog there.</p>
<p><strong>So this blog has now moved to <a href='http://www.djangoandflex.org.uk'>www.djangoandflex.org.uk</a></strong></p>
<p>There will be no more posts here.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/djangonflex.wordpress.com/8/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/djangonflex.wordpress.com/8/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/djangonflex.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/djangonflex.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/djangonflex.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/djangonflex.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/djangonflex.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/djangonflex.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/djangonflex.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/djangonflex.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/djangonflex.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/djangonflex.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/djangonflex.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/djangonflex.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/djangonflex.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/djangonflex.wordpress.com/8/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=djangonflex.wordpress.com&amp;blog=1303137&amp;post=8&amp;subd=djangonflex&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://djangonflex.wordpress.com/2007/07/04/move-over/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/6779b488f95ec26d77ab8380acdb4df4?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">ian</media:title>
		</media:content>
	</item>
		<item>
		<title>Z-Order of Components in a Flex Canvas</title>
		<link>http://djangonflex.wordpress.com/2007/07/03/z-order-of-components-in-a-flex-canvas/</link>
		<comments>http://djangonflex.wordpress.com/2007/07/03/z-order-of-components-in-a-flex-canvas/#comments</comments>
		<pubDate>Tue, 03 Jul 2007 12:34:34 +0000</pubDate>
		<dc:creator>Ian</dc:creator>
				<category><![CDATA[Fixes]]></category>
		<category><![CDATA[Flex]]></category>

		<guid isPermaLink="false">http://djangonflex.wordpress.com/2007/07/03/z-order-of-components-in-a-flex-canvas/</guid>
		<description><![CDATA[This blog has moved to www.djangoandflex.org.uk This isn&#8217;t a blog about Flex bugs &#8211; honestly. But found another yesterday. If you do have a bunch of components in a Flex Canvas, and show/hide/animate them with states and transitions, the components can change z-order on you without warning. I had a pernicious problem today with something [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=djangonflex.wordpress.com&amp;blog=1303137&amp;post=7&amp;subd=djangonflex&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><strong>This blog has moved to <a href='http://www.djangoandflex.org.uk'>www.djangoandflex.org.uk</a></strong></p>
<p>This isn&#8217;t a blog about Flex bugs &#8211; honestly. But found another yesterday.</p>
<p>If you do have a bunch of components in a Flex Canvas, and show/hide/animate them with states and transitions, the components can change z-order on you without warning. I had a pernicious problem today with something like:</p>
<pre>
&lt;mx:Canvas&gt;
 &lt;mx:Panel id='content'/&gt;
 &lt;mx:Panel id='tool_palette'/&gt;
&lt;/mx:Canvas&gt;</pre>
<p>Where <tt>content</tt> started out behind <tt>tool_palette</tt>, but when the latter got hidden (using a RemoveChild node in a state), and reappeared (by transitioning back) it was shown behind the content panel. Clearly a problem.</p>
<p>The solution I found was to separate the objects into two canvases:</p>
<pre>
&lt;mx:Canvas&gt;
 &lt;mx:Canvas height="100%" width="100%"&gt;
  &lt;mx:Panel id='content'/&gt;
 &lt;/mx:Canvas&gt;
 &lt;mx:Canvas height="100%" width="100%"&gt;
  &lt;mx:Panel id='tool_palette'/&gt;
 &lt;/mx:Canvas&gt;
&lt;/mx:Canvas&gt;</pre>
<p>which is a bit of a hack, but works. This is the first time I&#8217;ve missed old-flash&#8217;s z-depth model.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/djangonflex.wordpress.com/7/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/djangonflex.wordpress.com/7/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/djangonflex.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/djangonflex.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/djangonflex.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/djangonflex.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/djangonflex.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/djangonflex.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/djangonflex.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/djangonflex.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/djangonflex.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/djangonflex.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/djangonflex.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/djangonflex.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/djangonflex.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/djangonflex.wordpress.com/7/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=djangonflex.wordpress.com&amp;blog=1303137&amp;post=7&amp;subd=djangonflex&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://djangonflex.wordpress.com/2007/07/03/z-order-of-components-in-a-flex-canvas/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/6779b488f95ec26d77ab8380acdb4df4?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">ian</media:title>
		</media:content>
	</item>
		<item>
		<title>Binding Selected Items in a Flex List</title>
		<link>http://djangonflex.wordpress.com/2007/07/01/binding-selected-items-in-a-flex-list/</link>
		<comments>http://djangonflex.wordpress.com/2007/07/01/binding-selected-items-in-a-flex-list/#comments</comments>
		<pubDate>Sun, 01 Jul 2007 09:39:09 +0000</pubDate>
		<dc:creator>Ian</dc:creator>
				<category><![CDATA[Fixes]]></category>

		<guid isPermaLink="false">http://djangonflex.wordpress.com/2007/07/01/binding-selected-items-in-a-flex-list/</guid>
		<description><![CDATA[This blog has moved to www.djangoandflex.org.uk Just a quickie. Discovered today that if you try to programatically deselect the currently selected item in a ListBase subclass with selectedItem=null the change doesn&#8217;t propagate to anything bound to {my_list.selectedItem}. In fact in my application it seems to permanently break the data binding. Instead, to deselect a list [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=djangonflex.wordpress.com&amp;blog=1303137&amp;post=6&amp;subd=djangonflex&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><strong>This blog has moved to <a href='http://www.djangoandflex.org.uk'>www.djangoandflex.org.uk</a></strong></p>
<p>Just a quickie.</p>
<p>Discovered today that if you try to programatically deselect the currently selected item in a ListBase subclass with <tt>selectedItem=null</tt> the change doesn&#8217;t propagate to anything bound to <tt>{my_list.selectedItem}</tt>. In fact in my application it seems to permanently break the data binding.</p>
<p>Instead, to deselect a list item, do <tt>selectedIndex=-1</tt>, that seems to work.</p>
<p>So I&#8217;ve got something like:</p>
<pre>
 &lt;mx:Button label="Clear" click="entries.selectedIndex=-1"/&gt;
 &lt;mx:List id="entries" dataProvider="{my_data}"/&gt;
 &lt;components:MyEntryDisplay entry="{entries.selectedItem}"/&gt;</pre>
<p>which is fine for me.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/djangonflex.wordpress.com/6/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/djangonflex.wordpress.com/6/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/djangonflex.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/djangonflex.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/djangonflex.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/djangonflex.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/djangonflex.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/djangonflex.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/djangonflex.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/djangonflex.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/djangonflex.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/djangonflex.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/djangonflex.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/djangonflex.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/djangonflex.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/djangonflex.wordpress.com/6/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=djangonflex.wordpress.com&amp;blog=1303137&amp;post=6&amp;subd=djangonflex&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://djangonflex.wordpress.com/2007/07/01/binding-selected-items-in-a-flex-list/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/6779b488f95ec26d77ab8380acdb4df4?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">ian</media:title>
		</media:content>
	</item>
		<item>
		<title>Sending Images From Flex to a Server</title>
		<link>http://djangonflex.wordpress.com/2007/06/30/sending-images-from-flex-to-a-server/</link>
		<comments>http://djangonflex.wordpress.com/2007/06/30/sending-images-from-flex-to-a-server/#comments</comments>
		<pubDate>Sat, 30 Jun 2007 09:19:15 +0000</pubDate>
		<dc:creator>Ian</dc:creator>
				<category><![CDATA[Django]]></category>
		<category><![CDATA[Images]]></category>

		<guid isPermaLink="false">http://djangonflex.wordpress.com/2007/06/30/sending-images-from-flex-to-a-server/</guid>
		<description><![CDATA[This blog has moved to www.djangoandflex.org.uk Today&#8217;s challenge has been to allow a Flex app to create images, and have the new images uploaded back to the server as a bitmap. The application is for a simple buddy-icon editing application: users can upload their photos, drag in bits of clip art, resize and so on, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=djangonflex.wordpress.com&amp;blog=1303137&amp;post=4&amp;subd=djangonflex&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><strong>This blog has moved to <a href='http://www.djangoandflex.org.uk'>www.djangoandflex.org.uk</a></strong></p>
<p>Today&#8217;s challenge has been to allow a Flex app to create images, and have the new images uploaded back to the server as a bitmap. The application is for a simple buddy-icon editing application: users can upload their photos, drag in bits of clip art, resize and so on, then use their generated buddy icon on the site. The same could be useful for doing basic image editing, uploading for print.</p>
<p>There are two issues. First is getting uploaded images into Flex. That&#8217;s a topic for a future post (but basically you have to upload them to the server, then download them again).</p>
<p>The second is uploading a final image generated by Flex.</p>
<p>It turns out this is surprisingly easy. Flash has the ability to render any display component to a bitmap, using the BitmapData class. So in my graphic-design-canvas component I did:</p>
<pre>
private var bitmapData:BitmapData;
private function saveToBitmap():void
{
    bitmapData = new BitmapData(48, 48, true, 0x00ffffff);
    bitmapData.draw(this);</pre>
<p>The next stage was to convert the raw bitmap data into an image format (to reduce bandwidth requirements). In Flex 2.01 I used Adobe&#8217;s PNGEncoder from their <a href="http://code.google.com/p/as3corelib/">corelib</a> package. Once you&#8217;ve set up a classpath, or copied the .swc file into <var>/frameworks/lib</var>, you can do this:</p>
<pre>
    var imageData:ByteArray = PNGEncoder.encode(bitmapData);</pre>
<p>Easy as pie.</p>
<p>Finally to send it to the server I use a POST HTTP request. This requires that the bitmap data is encoded in Base 64:</p>
<pre>
    var encoder : Base64Encoder = new Base64Encoder();
    encoder.encodeBytes(imageData);
    var params:Object = { image_data: encoder.flush() };
    imageSend.send(params);
}</pre>
<p>where <var>imageSend</var> is the name of a HTTPService I created:</p>
<pre>
&lt;mx:HTTPService id="imageSend" showBusyCursor="true"
 useProxy="false" url="http://www.example.com/upload_image/"
 method="POST" result="imageSentConfirmation()"/&gt;</pre>
<p>Which is all very neat and simple: 8 lines of code.</p>
<p>On the Django end you simply need to extract the data from request.POST and decode the base-64 coded string:</p>
<pre>
def upload_image(request):
    data = base64.b64decode(request.POST['image_data'])</pre>
<p>You can feed this data into a file directly:</p>
<pre>
    open("filename.png", "wb").write(data)</pre>
<p>or send it to the Python Imaging Library for size-checks, conversion, or other jiggery pokery:</p>
<pre>
    img = Image.open(StringIO(data))
    img = img.resize((48,48), Image.ANTIALIAS)
    img.save(os.path.join(MEDIA_ROOT, "filename.png"))</pre>
<p>Then return something that your Flex component understands:</p>
<pre>
    return http.HttpResponse("&lt;ok/&gt;", mimetype="text/xml")</pre>
<p>Of course, you&#8217;ll probably want to do some more error handling on the server: trapping garbage content, file issues and the like. But the basic functionality is yours for just two lines of Django code!</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/djangonflex.wordpress.com/4/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/djangonflex.wordpress.com/4/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/djangonflex.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/djangonflex.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/djangonflex.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/djangonflex.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/djangonflex.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/djangonflex.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/djangonflex.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/djangonflex.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/djangonflex.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/djangonflex.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/djangonflex.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/djangonflex.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/djangonflex.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/djangonflex.wordpress.com/4/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=djangonflex.wordpress.com&amp;blog=1303137&amp;post=4&amp;subd=djangonflex&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://djangonflex.wordpress.com/2007/06/30/sending-images-from-flex-to-a-server/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/6779b488f95ec26d77ab8380acdb4df4?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">ian</media:title>
		</media:content>
	</item>
		<item>
		<title>Xml Generation Module</title>
		<link>http://djangonflex.wordpress.com/2007/06/29/xml-generation-module/</link>
		<comments>http://djangonflex.wordpress.com/2007/06/29/xml-generation-module/#comments</comments>
		<pubDate>Fri, 29 Jun 2007 14:54:24 +0000</pubDate>
		<dc:creator>Ian</dc:creator>
				<category><![CDATA[Django]]></category>
		<category><![CDATA[Server Data]]></category>
		<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://djangonflex.wordpress.com/2007/06/29/xml-generation-module/</guid>
		<description><![CDATA[In all my apps I communicate client to server in XML. Flex has very nice XML processing capabilities through e4x. I typically generate only simple XML to send back to the server, where python's processing is fairly easy too. The last link in the chain is getting Django to generate XML easily. Here is a very simple xml generating module you might find useful.
<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=djangonflex.wordpress.com&amp;blog=1303137&amp;post=3&amp;subd=djangonflex&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><strong>This blog has moved to <a href='http://www.djangoandflex.org.uk'>www.djangoandflex.org.uk</a></strong></p>
<p>In all my apps I communicate client to server in XML. Flex has very nice XML processing capabilities through e4x. I typically generate only simple XML to send back to the server, where python&#8217;s processing is fairly easy too.</p>
<p>The last link in the chain is getting Django to generate XML easily. I wrote a very simple xml generating module that you might find useful.</p>
<p>It is designed to be as simple as possible. So you might have</p>
<pre>&gt;&gt;&gt; b = xml.book(
...     xml.title('The Title'), xml.author('Ian Millington')
...     )</pre>
<p>and have it rendered to xml with:</p>
<pre>&gt;&gt;&gt; b.xml
'&lt;book&gt;&lt;title&gt;The Title&lt;/title&gt;&lt;author&gt;Ian
Millington&lt;/author&gt;&lt;/book&gt;'</pre>
<p>Of course, things can get much more complex, it handles tag properties, namespaces, DTDs and so on. For example:</p>
<pre>&gt;&gt;&gt; svg = XMLNamespace('svg', 'http://www.w3.org/2000/svg')
&gt;&gt;&gt; makeXhtml(html.html(html.body(svg.svg(), class='main-page')))</pre>
<p>produces</p>
<pre>&lt;?xml version="1.0"?&gt;
&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
&lt;html xmlns:svg="http://www.w3.org/2000/svg"&gt;
&lt;body class="main-page"&gt;
&lt;svg:svg/&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
<p>You can find the python module on google code <a href="http://code.google.com/p/xml4py/">here</a>, with the actual python code <a href="http://xml4py.googlecode.com/svn/trunk/xmlgen.py">here</a>. The license is LGPL (i.e. no warranties, free for commercial use, non-copyleft).</p>
<p>The code is based on a HTML code generator <a href="http://www.therndguy.com/project/automatic-customised-content/">I wrote</a> as part of a research project last year. That in turn was inspired by the HTML creation system in <a href="http://mochikit.com/">MochiKit</a>, which is in turn based on a Python HTML library, I believe, but I don&#8217;t know which one. Please fill me in on the missing inspiration if you know. In any case I think that the prior art used a fixed set of tag functions, rather than allowing any tags to be used. Correct me if I&#8217;m wrong!</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/djangonflex.wordpress.com/3/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/djangonflex.wordpress.com/3/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/djangonflex.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/djangonflex.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/djangonflex.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/djangonflex.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/djangonflex.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/djangonflex.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/djangonflex.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/djangonflex.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/djangonflex.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/djangonflex.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/djangonflex.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/djangonflex.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/djangonflex.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/djangonflex.wordpress.com/3/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=djangonflex.wordpress.com&amp;blog=1303137&amp;post=3&amp;subd=djangonflex&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://djangonflex.wordpress.com/2007/06/29/xml-generation-module/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/6779b488f95ec26d77ab8380acdb4df4?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">ian</media:title>
		</media:content>
	</item>
		<item>
		<title>Welcome</title>
		<link>http://djangonflex.wordpress.com/2007/06/29/hello-world/</link>
		<comments>http://djangonflex.wordpress.com/2007/06/29/hello-world/#comments</comments>
		<pubDate>Fri, 29 Jun 2007 12:28:12 +0000</pubDate>
		<dc:creator>Ian</dc:creator>
				<category><![CDATA[Meta-Stuff]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[This blog has moved to www.djangoandflex.org.uk Welcome to Django&#8217;n'Flex. This site is about working with these two great new technologies, because that&#8217;s what I&#8217;m doing a lot at the moment. Here&#8217;s some background on me. I thought I&#8217;d start this blog to note down things I&#8217;ve found out, numskull moments and the rare bit of [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=djangonflex.wordpress.com&amp;blog=1303137&amp;post=1&amp;subd=djangonflex&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><strong>This blog has moved to <a href='http://www.djangoandflex.org.uk'>www.djangoandflex.org.uk</a></strong></p>
<p>Welcome to Django&#8217;n'Flex. This site is about working with these two great new technologies, because that&#8217;s what I&#8217;m doing a lot at the moment.</p>
<p><a href="http://djangonflex.wordpress.com/about/">Here&#8217;s some background</a> on me.</p>
<p>I thought I&#8217;d start this blog to note down things I&#8217;ve found out, numskull moments and the rare bit of insight.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/djangonflex.wordpress.com/1/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/djangonflex.wordpress.com/1/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/djangonflex.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/djangonflex.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/djangonflex.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/djangonflex.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/djangonflex.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/djangonflex.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/djangonflex.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/djangonflex.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/djangonflex.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/djangonflex.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/djangonflex.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/djangonflex.wordpress.com/1/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/djangonflex.wordpress.com/1/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/djangonflex.wordpress.com/1/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=djangonflex.wordpress.com&amp;blog=1303137&amp;post=1&amp;subd=djangonflex&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://djangonflex.wordpress.com/2007/06/29/hello-world/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/6779b488f95ec26d77ab8380acdb4df4?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">ian</media:title>
		</media:content>
	</item>
	</channel>
</rss>
