<?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>Jython Journeys &#187; jython</title>
	<atom:link href="http://jython.xhaus.com/category/jython/feed/" rel="self" type="application/rss+xml" />
	<link>http://jython.xhaus.com</link>
	<description>Notes about my work with jython and python</description>
	<lastBuildDate>Tue, 01 Dec 2009 19:37:22 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Transforming with XSLT on Google AppEngine and jython.</title>
		<link>http://jython.xhaus.com/transforming-with-xslt-on-google-appengine-and-jython/</link>
		<comments>http://jython.xhaus.com/transforming-with-xslt-on-google-appengine-and-jython/#comments</comments>
		<pubDate>Tue, 01 Dec 2009 18:42:26 +0000</pubDate>
		<dc:creator>alan.kennedy</dc:creator>
				<category><![CDATA[google appengine]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[jython]]></category>
		<category><![CDATA[cloud computing]]></category>
		<category><![CDATA[java scripting]]></category>
		<category><![CDATA[web technology]]></category>
		<category><![CDATA[xml]]></category>
		<category><![CDATA[xslt]]></category>

		<guid isPermaLink="false">http://jython.xhaus.com/?p=171</guid>
		<description><![CDATA[I&#8217;m writing this post in response to a challenge. I wrote a post entitled Jython on Google AppEngine: Why bother?, which was a reply to a statement made by a Google engineer about not seeing the point of running jython on AppEngine. And a similar statement was repeated in a comment on that blog post [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m writing this post in response to a challenge. I wrote a post entitled <a href="http://jython.xhaus.com/jython-on-google-appengine-why-bother/">Jython on Google AppEngine: Why bother?</a>, which was a reply to a statement made by a Google engineer about not seeing the point of running jython on AppEngine. And a similar statement was repeated in a <a href="http://jython.xhaus.com/jython-on-google-appengine-why-bother/#comments">comment on that blog post</a> (i.e. &#8220;<i>the gist of what I intended to say was that while it was possible to run Jython on App Engine, I couldn’t think why you’d want to</i>.&#8221;)</p>
<p>So rather than get into a back-and-forth of yes-it-is-no-it-isnt-yes-it-is, I thought I&#8217;d reply with some simple code that demonstrates <b>something that cannot (currently) be done in cpython on AppEngine</b>, but is <b>easy with jython on AppEngine</b>: XSLT transforms. </p>
<p><span id="more-171"></span></p>
<p>So, without further ado, here is the jython source code for running an XSLT transform on Google AppEngine. It is implemented as a jython WSGI application, using xhaus.com&#8217;s <a href="http://modjy.xhaus.com">modjy WSGI gateway for java servlets</a> that was <a href="http://jython.xhaus.com/modjy-now-fully-integrated-into-jython/">contributed to the jython project a few months back</a>.</p>
<p>In order to get this code running, I suggest you download the <a href="http://downloads.xhaus.com/modjy_webapp_google_appengine/">modjy on google appengine demo</a> from our <a href="http://downloads.xhaus.com">downloads site</a>. In that download, there is a jython file called &#8220;demo_app.py&#8221;. Simply replace the entire contents of that file with the code below, and you&#8217;re good to go. If you need help with getting the modjy demo application working on Google AppEngine, see the documentation on the modjy wiki: <a href="http://opensource.xhaus.com/projects/modjy/wiki/ModjyGoogleAppEngine">Running jython WSGI applications on Google AppEngine, with modjy</a>.</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;">__doc__ = <span style="color: #483d8b;">&quot;&quot;&quot;
A demonstration of how to run XSLT transforms on Google AppEngine with jython (not cpython).
Please feel free to use this code in whatever way you wish.
&quot;&quot;&quot;</span>
<span style="color: #ff7700;font-weight:bold;">from</span> java.<span style="color: black;">io</span> <span style="color: #ff7700;font-weight:bold;">import</span> StringReader, StringWriter
<span style="color: #ff7700;font-weight:bold;">from</span> javax.<span style="color: #dc143c;">xml</span>.<span style="color: black;">transform</span> <span style="color: #ff7700;font-weight:bold;">import</span> Transformer, TransformerFactory
<span style="color: #ff7700;font-weight:bold;">from</span> javax.<span style="color: #dc143c;">xml</span>.<span style="color: black;">transform</span>.<span style="color: black;">stream</span> <span style="color: #ff7700;font-weight:bold;">import</span> StreamResult, StreamSource
&nbsp;
xml_data = <span style="color: #483d8b;">&quot;&quot;&quot;
&lt;books&gt;
  &lt;book&gt;
    &lt;title&gt;2001 - A Space Odyssey&lt;/title&gt;
    &lt;author&gt;Arthur C Clarke&lt;/author&gt;
  &lt;/book&gt;
  &lt;book&gt;
    &lt;title&gt;I, Robot&lt;/title&gt;
    &lt;author&gt;Isaac Asimov&lt;/author&gt;
  &lt;/book&gt;
  &lt;book&gt;
    &lt;title&gt;Kil'n people&lt;/title&gt;
    &lt;author&gt;David Brin&lt;/author&gt;
  &lt;/book&gt;
&lt;/books&gt;
&quot;&quot;&quot;</span>
&nbsp;
xslt_source = <span style="color: #483d8b;">&quot;&quot;&quot;
&lt;xsl:stylesheet
  xmlns:xsl=&quot;http://www.w3.org/1999/XSL/Transform&quot;
&gt;
&nbsp;
&lt;xsl:template match=&quot;books&quot;&gt;
&lt;html&gt;
  &lt;head&gt;&lt;title&gt;A list of books, transformed into html from xml using xslt and jython.&lt;/title&gt;&lt;/head&gt;
  &lt;body&gt;
    &lt;table border=&quot;1&quot; width=&quot;50%&quot; align=&quot;center&quot;&gt;
      &lt;caption&gt;A list of books, transformed into html from xml using xslt and jython.&lt;/caption&gt;
      &lt;tr&gt;&lt;th&gt;Title&lt;/th&gt;&lt;th&gt;Author&lt;/th&gt;&lt;/tr&gt;
    &lt;xsl:for-each select=&quot;book&quot;&gt;
      &lt;tr&gt;&lt;td&gt;&lt;xsl:value-of select=&quot;title/text()&quot;/&gt;&lt;/td&gt;&lt;td&gt;&lt;xsl:value-of select=&quot;author/text()&quot;/&gt;&lt;/td&gt;&lt;/tr&gt;
    &lt;/xsl:for-each&gt;
    &lt;/table&gt;
  &lt;/body&gt;
&lt;/html&gt;
&lt;/xsl:template&gt;
&nbsp;
&lt;/xsl:stylesheet&gt;
&quot;&quot;&quot;</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> generate_html<span style="color: black;">&#40;</span>xml_data, xslt_source<span style="color: black;">&#41;</span>:
  transformer = TransformerFactory.<span style="color: black;">newInstance</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>.<span style="color: black;">newTransformer</span><span style="color: black;">&#40;</span>StreamSource<span style="color: black;">&#40;</span>StringReader<span style="color: black;">&#40;</span>xslt_source<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
  output_buffer = StringWriter<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
  transformer.<span style="color: black;">transform</span><span style="color: black;">&#40;</span>StreamSource<span style="color: black;">&#40;</span>StringReader<span style="color: black;">&#40;</span>xml_data<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>, StreamResult<span style="color: black;">&#40;</span>output_buffer<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
  <span style="color: #ff7700;font-weight:bold;">return</span> output_buffer.<span style="color: black;">buffer</span>.<span style="color: black;">toString</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> handler<span style="color: black;">&#40;</span>environ, start_response<span style="color: black;">&#41;</span>:
  result = generate_html<span style="color: black;">&#40;</span>xml_data, xslt_source<span style="color: black;">&#41;</span>
  start_response<span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;200 Hoopy&quot;</span>, <span style="color: black;">&#91;</span> <span style="color: black;">&#40;</span><span style="color: #483d8b;">'content-type'</span>, <span style="color: #483d8b;">'text/html'</span><span style="color: black;">&#41;</span> <span style="color: black;">&#93;</span><span style="color: black;">&#41;</span>
  <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: black;">&#91;</span>result<span style="color: black;">&#93;</span></pre></div></div>

<p>Happy Transforming!</p>
]]></content:encoded>
			<wfw:commentRss>http://jython.xhaus.com/transforming-with-xslt-on-google-appengine-and-jython/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Jython on Google AppEngine: Why bother?</title>
		<link>http://jython.xhaus.com/jython-on-google-appengine-why-bother/</link>
		<comments>http://jython.xhaus.com/jython-on-google-appengine-why-bother/#comments</comments>
		<pubDate>Mon, 30 Nov 2009 14:40:09 +0000</pubDate>
		<dc:creator>alan.kennedy</dc:creator>
				<category><![CDATA[google appengine]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[jython]]></category>
		<category><![CDATA[cloud computing]]></category>
		<category><![CDATA[java scripting]]></category>
		<category><![CDATA[web technology]]></category>

		<guid isPermaLink="false">http://jython.xhaus.com/?p=160</guid>
		<description><![CDATA[Why on earth would you want to run jython applications on Google Appengine?

First off, I must apologise for the flippant nature of the attention grabbing title. I&#8217;m a jython committer, and a jython user, so I believe that there are very good reasons for running jython on Google AppEngine. (You can read how to do [...]]]></description>
			<content:encoded><![CDATA[<p>Why on earth would you want to run <a href="http://www.jython.org">jython</a> applications on <a href="http://appengine.google.com">Google Appengine</a>?</p>
<p><span id="more-160"></span></p>
<p>First off, I must apologise for the flippant nature of the attention grabbing title. I&#8217;m a jython committer, and a jython user, so I believe that there are very good reasons for running jython on Google AppEngine. (You can read how to do so on the modjy wiki: <a href="http://opensource.xhaus.com/projects/modjy/wiki/ModjyGoogleAppEngine">how to run jython applications on Google AppEngine</a>).</p>
<p>The title is essentially a paraphrase of a statement made by a Google AppEngine Evangelist, at a talk about AppEngine that I attended here in Dublin. The speaker was of the opinion that there was no valid reason for running jython on AppEngine, a statement which I couldn&#8217;t let pass.</p>
<p>I think that the core of his reasoning for making that statement was a simple misunderstanding, but a misunderstanding that is common among users who are familiar with python, or users of cpython, but who are not familiar with jython&#8217;s use as a <a href="http://www.javaworld.com/javaworld/jw-11-2007/jw-11-jsr223.html">JVM scripting language</a>. The misunderstanding is that the only reason for running jython is so that one can run python applications on the JVM, using python&#8217;s wealth of &quot;batteries included&quot; APIs. If that is the case, then why bother running jython, when one can simply use the <a href="http://code.google.com/appengine/docs/python/gettingstarted/">cpython support on AppEngine</a> directly?</p>
<p>To explain, when writing a cpython application that processes email, for example, one can make use of the python&#8217;s <a href="http://docs.python.org/library/email.html">email module</a>, which provides a wealth of features for dealing with the many complexities of parsing, processing and generating email messages, MIME, etc. Users of jython can also use the python email modules, since those modules are written in pure python. But since jython runs on the Java Virtual Machine(JVM) and permits seamless integration of java and python code, jython users writing email processing also have the option of using the excellent <a href="http://java.sun.com/products/javamail/">JavaMail APIs</a>, which are just as robust as the pure python modules, and arguably more efficient. So jython users have the best of both worlds: they can use either python APIs or java APIs, with equal ease.</p>
<p>Processing email is perhaps too straightforward an example, in that both python and java have excellent email processing support. But due to the more widespread use of java in the development community in general, java generally has far more support for any given technology need, since there are often multiple options available. A good example of this is cryptography: there is a wealth of <a href="http://www.homeport.org/~adam/crypto/">java cryptography libraries</a> available, including the excellent <a href="bouncycastle.org">Bouncy Castle</a>, <a href="http://www.cryptix.org/">Cryptix</a>, <a href="http://www.flexiprovider.de/">Flexiprovider</a>, etc. The choice of crypto libraries in python is generally narrower, supports less functionality, and is sometimes abandon-ware.</p>
<p>So if one&#8217;s understanding of jython is simply that it is a way to run pure python modules on the JVM, then the above mentioned mis-understanding is forgivable. But it is simply not the case that the primary usage of jython is to run pure python modules: Jython excels as a dynamic/scripting language for the JVM, and permits the use of java APIs, without having to write java code.</p>
<p>In discussion with the Google engineer after the talk, he conceded that there was one possible use case for running jython on AppEngine, namely that of prototyping java applications. In this scenario, applications would</p>
<ol>
<li>Be developed in jython, taking advantage of the enormous productivity increases gained by developing in python</li>
<li>Be translated to java once the functionality of the application is complete</li>
</ol>
<p>My reply to this is: <b>&#8220;Why bother with step 2&#8243;</b>?</p>
<p>If you&#8217;ve got a running application that is fully functional and written in jython, then you don&#8217;t need to translate it to java. You should only consider translating it, or parts of it, into java <b>if you really have to</b>. For example, after profiling your jython application, you may find one or two core pieces that are performance bottlenecks: these are prime candidates for translation to java, to improve performance. But there&#8217;s no reason to translate the rest of the application: maintainability and productivity is best served by simply leaving the jython code exactly as is.</p>
<p>I suppose a part of the reason why this mis-perception of jython has come about is because python is such an excellent language that it is in the unique position of having two completely independent implementations of the language that run on Google AppEngine. But just because both cpython and jython run on AppEngine doesn&#8217;t mean that their usages should be identical. Jython&#8217;s place in the AppEngine ecosystem is primarily as a JVM dynamic language.</p>
<p>So, in summary, jython is more than just a mechanism for running pure python code on the JVM: it is an excellent JVM development platform in it&#8217;s own right.</p>
<p>I hope I&#8217;ve given you some good reasons to consider developing your next Google AppEngine project on jython.</p>
]]></content:encoded>
			<wfw:commentRss>http://jython.xhaus.com/jython-on-google-appengine-why-bother/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Jython 2.5; it&#8217;s a beautiful day!</title>
		<link>http://jython.xhaus.com/jython-25-its-a-beautiful-day/</link>
		<comments>http://jython.xhaus.com/jython-25-its-a-beautiful-day/#comments</comments>
		<pubDate>Tue, 16 Jun 2009 18:39:23 +0000</pubDate>
		<dc:creator>alan.kennedy</dc:creator>
				<category><![CDATA[jython]]></category>
		<category><![CDATA[java scripting]]></category>

		<guid isPermaLink="false">http://jython.xhaus.com/?p=3</guid>
		<description><![CDATA[A fantastic thing happened today: Jython 2.5 was released! I&#8217;ve anticipated this day a long time, as have many others; it&#8217;s great that it&#8217;s finally happened.

I&#8217;ve been using jython since 1999, when it was known as jpython. That was back in the Finn Bock Errata days; Finn had been kind of maintaining jpython after Jim [...]]]></description>
			<content:encoded><![CDATA[<p>A fantastic thing happened today: Jython 2.5 was released! I&#8217;ve anticipated this day a long time, as have many others; it&#8217;s great that it&#8217;s finally happened.</p>
<p><span id="more-3"></span><br />
I&#8217;ve been using jython since 1999, when it was known as jpython. That was back in the Finn Bock Errata days; Finn had been kind of maintaining jpython after Jim Hugunin left CNRI, and produced a series of upgrade patches and fixes he called Errata. For legal reasons relating to CNRI&#8217;s IP, the project name had to be changed to jython; after that Finn, Samuele Pedroni and Barry Warsaw powered forward, bringing jython through cpython 2.0 and 2.1 compatibility. The result was a fantastically robust product, which had completely seamless Java integration, and which went on to become the JVM scripting language for a wide range of applications.</p>
<p>However, after 2.1 had settled down, Finn moved on. Cpython moved onto version 2.2, which brought big changes to the language: metaclasses, descriptors, properties, iterators, generators and nested scopes, to mention a few. All of the new features required large changes in the sometimes complex interactions between cpython and java class designs.</p>
<p>Samuele continued as jython&#8217;s maintainer, and a jython 2.2 alpha was produced that provided many of the required new features, and much of which still remains in jython 2.5. But Samuele moved on to the greener pastures of the amazing PyPy project, which is developing a self-hosting python-in-python interpreter. Although that is where his main energies lie, Samuele continues to be a jython contributor and provide valued guidance to the other developers.</p>
<p>The project languished for a couple of years, and the version number did not advance; 2.2 alpha was the state of jython for a long time, principally because of the enormous work involved in implementing a full 2.2 version. Brian Zimmer was project lead for a while, but much of the time there was no clear leadership. Jython 2.1 continued and continues to be used in a lot of places; it&#8217;s stability was and is fantastic, and it always did the job. But there was some angst about it&#8217;s future, especially with the advance of other JVM scripting languages such as JRuby, and with changes in Java itself, such as Annotations, Generics, etc.</p>
<p>Then the project sprang back to life, with a complete 2.2 being published; Charlie Groves was the key person in that achievement. Charlie did, and still does, an <a href="http://fisheye3.atlassian.com/browse/~author=cgroves/jython">enormous amount of work on jython</a>, and I believe that his dedication to releasing a complete and robust 2.2 version was key to revitalising jython, both the language and the community.</p>
<p>And then came Frank Wierzbicki, the current BDFL, and the person who has done most to bring jython to the modern state it exists in today.</p>
<p>Initially, there was hesitation about which version of the python language to target; cpython had reached version 2.5, and ironpython was at version 2.4. Upgrading jython to 2.3, then 2.4 and then 2.5 seemed like an awful lot of work. Frank adopted a bold strategy: aim to get jython as up-to-date as possible,  and bring jython directly to 2.5. And today we&#8217;ve seen that that strategy worked!</p>
<p>Congratulations Frank! Superb job!</p>
<p>And well done to a great group of people who&#8217;ve contributed fantastic work; Jim Baker, Charlie Groves, Otmar Humbel, Tobias Ivarsson, Philip Jenvey, Nicholas Riley, Leo Soto, among <a href="https://www.ohloh.net/p/jython/contributors/">others</a>.</p>
<p>Well done to all the jython development team; ye&#8217;ve achieved something wonderful!</p>
]]></content:encoded>
			<wfw:commentRss>http://jython.xhaus.com/jython-25-its-a-beautiful-day/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How to run jython WSGI applications on Google AppEngine with modjy.</title>
		<link>http://jython.xhaus.com/how-to-run-jython-wsgi-applications-on-google-appengine-with-modjy/</link>
		<comments>http://jython.xhaus.com/how-to-run-jython-wsgi-applications-on-google-appengine-with-modjy/#comments</comments>
		<pubDate>Sun, 12 Apr 2009 21:36:01 +0000</pubDate>
		<dc:creator>alan.kennedy</dc:creator>
				<category><![CDATA[google appengine]]></category>
		<category><![CDATA[jython]]></category>
		<category><![CDATA[cloud computing]]></category>
		<category><![CDATA[web technology]]></category>

		<guid isPermaLink="false">http://jython.xhaus.com/?p=97</guid>
		<description><![CDATA[As you can see from our last blog post, we were delighted to get jython WSGI applications running on Google AppEngine for java using modjy. We promised in that we&#8217;d write a tutorial on how to do do that.

Well we&#8217;ve done that: you can read the results on the modjy wiki: How to run jython [...]]]></description>
			<content:encoded><![CDATA[<p>As you can see from our last blog post, we were delighted to get jython WSGI applications running on Google AppEngine for java using modjy. We promised in that we&#8217;d write a tutorial on how to do do that.</p>
<p><span id="more-97"></span></p>
<p>Well we&#8217;ve done that: you can read the results on the modjy wiki: <a href="http://opensource.xhaus.com/projects/modjy/wiki/ModjyGoogleAppEngine">How to run jython WSGI applications on Google AppEngine with modjy</a>.</p>
<p>If you successfully upload the mody demo application, you should see results like this: <a href="http://jywsgi.appspot.com">modjy demo application running on AppEngine</a></p>
<p>We&#8217;d be happy to know of any successful reports of jython WSGI applications running on AppEngine: please feel free to leave a comment about it.</p>
]]></content:encoded>
			<wfw:commentRss>http://jython.xhaus.com/how-to-run-jython-wsgi-applications-on-google-appengine-with-modjy/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Modjy running on Google AppEngine.</title>
		<link>http://jython.xhaus.com/modjy-running-on-google-appengine/</link>
		<comments>http://jython.xhaus.com/modjy-running-on-google-appengine/#comments</comments>
		<pubDate>Sun, 12 Apr 2009 08:25:26 +0000</pubDate>
		<dc:creator>alan.kennedy</dc:creator>
				<category><![CDATA[google appengine]]></category>
		<category><![CDATA[jython]]></category>
		<category><![CDATA[cloud computing]]></category>
		<category><![CDATA[web technology]]></category>

		<guid isPermaLink="false">http://jython.xhaus.com/?p=92</guid>
		<description><![CDATA[So, after the announcement by Google that their AppEngine could run other JVM languages, including jython, I had to have a go at getting modjy, our jython WSGI to java servlet bridge, running on it.

It wasn&#8217;t a complex job, but did require a number of tweaks to the standard jython deployment. I will write up [...]]]></description>
			<content:encoded><![CDATA[<p>So, after <a href="http://googleappengine.blogspot.com/2009/04/seriously-this-time-new-language-on-app.html">the announcement by Google that their AppEngine could run other JVM languages</a>, including <a href="http://www.jython.org">jython</a>, I had to have a go at getting <a href="http://jython.xhaus.com/?p=41">modjy</a>, our jython WSGI to java servlet bridge, running on it.</p>
<p><span id="more-92"></span></p>
<p>It wasn&#8217;t a complex job, but did require a number of tweaks to the standard jython deployment. I will write up these instructions and make them available very soon.</p>
<p>You can see the results here: <a href="http://jywsgi.appspot.com">modjy demo application running on Google AppEngine</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://jython.xhaus.com/modjy-running-on-google-appengine/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Jython runs on Google AppEngine!</title>
		<link>http://jython.xhaus.com/jython-runs-on-google-appengine/</link>
		<comments>http://jython.xhaus.com/jython-runs-on-google-appengine/#comments</comments>
		<pubDate>Wed, 08 Apr 2009 13:05:40 +0000</pubDate>
		<dc:creator>alan.kennedy</dc:creator>
				<category><![CDATA[google appengine]]></category>
		<category><![CDATA[jython]]></category>
		<category><![CDATA[cloud computing]]></category>
		<category><![CDATA[web technology]]></category>

		<guid isPermaLink="false">http://jython.xhaus.com/?p=88</guid>
		<description><![CDATA[It is now possible to run Jython on Google AppEngine!

If you&#8217;re not yet aware of it, Google AppEngine is one of the foremost Cloud Computing offerings currently available. It is also arguably one of the purest options available, since it truly removes the need for the application administrator to consider physical resources (apart from paying [...]]]></description>
			<content:encoded><![CDATA[<p>It is now possible to run Jython on Google AppEngine!</p>
<p><span id="more-88"></span></p>
<p>If you&#8217;re not yet aware of it, <a href="http://code.google.com/appengine/">Google AppEngine</a> is one of the foremost <a href="http://en.wikipedia.org/wiki/Cloud_computing">Cloud Computing</a> offerings currently available. It is also arguably one of the <b>purest</b> options available, since it truly removes the need for the application administrator to consider physical resources (apart from paying for them that is!). The Google AppEngine cloud will automatically scale up the resources as and when required.</p>
<p>This is in contrast to the <a href="http://aws.amazon.com/ec2/">Amazon EC2</a> offering, where the application architect has to <a href="http://developer.amazonwebservices.com/connect/entry!default.jspa?categoryID=100&#038;externalID=1639">specially design the application to distribute over the Amazon cloud</a>, including allocating and de-allocating machine instances dynamically.</p>
<p>Yesterday, <a href="http://googleappengine.blogspot.com/2009/04/seriously-this-time-new-language-on-app.html">Google annnounced that they are providing Java on their AppEngine</a>!</p>
<p>And because they&#8217;re supporting java, they also get automatic support for other languages that run on the JVM, with <a href="http://groups.google.com/group/google-appengine-java/web/will-it-play-in-app-engine">jython 2.2 and jython 2.5 being explicitly supported on AppEngine</a>!</p>
<p>This is fantastic news!</p>
<p>The jython team are currently ramping up for a jython 2.5 Release Candidate, which should appear very soon. It&#8217;s very likely that we&#8217;ll get the <a href="http://google-appengine-java.googlegroups.com/web/jython-r5996-appengine.patch">Google patches</a> included in jython 2.5 before then.</p>
<p>Discussions are ongoing how about <a href="http://www.nabble.com/Jython-on-Google-AppEngine%21-td22949606.html">applying the patch</a>, and the issue of <a href="http://www.nabble.com/Contributor-Agreements-for-Patches---was-Jython-on-Google-AppEngine%21-td22953650.html">contributor agreements</a>.</p>
<p>Watch this space!</p>
]]></content:encoded>
			<wfw:commentRss>http://jython.xhaus.com/jython-runs-on-google-appengine/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Announce: jyson, a pure java JSON codec for jython.</title>
		<link>http://jython.xhaus.com/announce-jyson-a-pure-java-json-codec-for-jython/</link>
		<comments>http://jython.xhaus.com/announce-jyson-a-pure-java-json-codec-for-jython/#comments</comments>
		<pubDate>Tue, 17 Mar 2009 22:19:15 +0000</pubDate>
		<dc:creator>alan.kennedy</dc:creator>
				<category><![CDATA[jython]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[json]]></category>
		<category><![CDATA[web technology]]></category>

		<guid isPermaLink="false">http://jython.xhaus.com/?p=83</guid>
		<description><![CDATA[I&#8217;m delighted to announce the publication of jyson, a fast codec for JavaScript Object Notation (JSON), a lightweight and easy-to-use data interchange format.

As you may know, JSON is used extensively in modern web development, particularly to communicate data between servers and clients in Rich Internet Applications, or Web 2.0 applications. JSON is commonly the preferred [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m delighted to announce the publication of <a href="http://jyson.xhaus.com">jyson</a>, a fast codec for <a href="http://json.org">JavaScript Object Notation (JSON)</a>, a lightweight and easy-to-use data interchange format.</p>
<p><span id="more-83"></span></p>
<p>As you may know, JSON is used extensively in modern web development, particularly to communicate data between servers and clients in <a href="http://en.wikipedia.org/wiki/Rich_Internet_application">Rich Internet Applications</a>, or <a href="http://en.wikipedia.org/wiki/Web_2.0">Web 2.0</a> applications. JSON is commonly the preferred choice for data interchange between clients and servers which use a <a href="http://en.wikipedia.org/wiki/Representational_State_Transfer">Respresentational State Transfer</a> (REST) based architecture.</p>
<p>JSON is often the preferred choice because it is a <a href="http://www.json.org/fatfree.html">fat free alternative to XML</a>. Although we use XML all the time, we fully recognise that it be both complex to work with and inefficient to generate and parse. JSON, on the other hand, is both simple and fast.</p>
<p>Jyson is written in pure java, and should be highly performant. So, if you&#8217;re using jython and JSON, we recommend you check out <a href="http://jyson.xhaus.com">jyson</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://jython.xhaus.com/announce-jyson-a-pure-java-json-codec-for-jython/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>New xhaus.com open source software portal.</title>
		<link>http://jython.xhaus.com/new-xhauscom-open-source-software-portal/</link>
		<comments>http://jython.xhaus.com/new-xhauscom-open-source-software-portal/#comments</comments>
		<pubDate>Sun, 15 Mar 2009 18:05:50 +0000</pubDate>
		<dc:creator>alan.kennedy</dc:creator>
				<category><![CDATA[jruby]]></category>
		<category><![CDATA[jython]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[redmine]]></category>

		<guid isPermaLink="false">http://jython.xhaus.com/?p=81</guid>
		<description><![CDATA[I&#8217;m delighted to announce the opening of the xhaus.com open source software portal.
On the portal you will find source code, documentation, issue trackers, etc, for open source software that we have published.

To run our open source portal, we use the excellent Redmine, an open source project management system written with Ruby on Rails. One thing [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m delighted to announce the opening of the <a href="http://opensource.xhaus.com">xhaus.com open source software portal</a>.</p>
<p>On the portal you will find source code, documentation, issue trackers, etc, for open source software that we have published.</p>
<p><span id="more-81"></span></p>
<p>To run our open source portal, we use the excellent <a href="http://www.redmine.org">Redmine</a>, an open source project management system written with <A href="http://www.rubyonrails.org">Ruby on Rails</a>. One thing we particularly like is that the <a href="http://www.redmine.org/wiki/redmine/TheyAreUsingRedmine">Ruby community uses Redmine extensively</a>, meaning that they subscribe to the philosophy of <a href="http://en.wikipedia.org/wiki/Eat_one%27s_own_dog_food">eating their own dog food</a>, an admirable trait in the open source world.</p>
<p>We host our instance of Redmine on <a href="http://jruby.codehaus.org">jruby</a>, running on <a href="http://tomcat.apache.org">Apache Tomcat 6.0</a>.</p>
<p>We chose Redmine because it is a highly functional and well architected piece of software. Browsing the <a href="http://www.redmine.org/projects/redmine/repository">source code for redmine</a> shows that it is well designed and highly extensible, with a <a href="http://www.redmine.org/wiki/redmine/Plugins">range of plugins for different tasks</a>. Moreover, it has a rich feature set, including</p>
<ul>
<li>Multiple projects</li>
<li>Hierarchical projects</li>
<li>Forums</li>
<li>Issue trackers</li>
<li>Wiki</li>
<li>File and Document areas</li>
<li>News</li>
<li><a href="http://www.redmine.org/wiki/redmine/Features">lots of other great features</a></li>
</ul>
<p>Many thanks to the Redmine developers for their great software!</p>
<p>Being avid <a href="http://en.wikipedia.org/wiki/Python_(programming_language)">pythonistas</a>, we normally like to use python or jython software when possible. In the case of project management, the obvious choice would be <a href="http://trac.edgewall.org">Trac</a>, which was the first software of it&#8217;s type in the market, and in many ways defined the space that Redmine occupies.</p>
<p>But Trac has many problems, the most restrictive being that it can only support single projects (unless one is willing to do <a href="http://trac.edgewall.org/wiki/TracMultipleProjects">a fair amount of hacking</a>). Furthermore, the Trac code base is getting a little crufty, a problem which is exacerbated by the fact that authors focus on <a href="http://trac.edgewall.org/wiki/TracDev/PortingFromClearSilverToGenshi">changing the technologies on which Trac is built</a>, rather than on adding new functionality that is useful to the end user.</p>
<p>So we invite you to visit the <a href="http://opensource.xhaus.com">xhaus.com open source software portal</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://jython.xhaus.com/new-xhauscom-open-source-software-portal/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Modjy now fully integrated into jython.</title>
		<link>http://jython.xhaus.com/modjy-now-fully-integrated-into-jython/</link>
		<comments>http://jython.xhaus.com/modjy-now-fully-integrated-into-jython/#comments</comments>
		<pubDate>Sat, 07 Mar 2009 15:40:06 +0000</pubDate>
		<dc:creator>alan.kennedy</dc:creator>
				<category><![CDATA[jython]]></category>
		<category><![CDATA[cloud computing]]></category>
		<category><![CDATA[web technology]]></category>

		<guid isPermaLink="false">http://jython.xhaus.com/?p=77</guid>
		<description><![CDATA[I&#8217;m delighted to announce that modjy, the java servlet to python WSGI gateway that I originally wrote to track the WSGI spec, has now finally been fully integrated into the jython source base.

Modjy has been distributed with jython for several months now, in the form of a third party library, as a zip file; I [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m delighted to announce that <a href="http://modjy.xhaus.com">modjy</a>, the <a href="http://java.sun.com/products/servlet/">java servlet</a> to <a href="http://www.python.org/dev/peps/pep-0333/">python WSGI</a> gateway that I originally wrote to track the WSGI spec, has now finally been fully integrated into the jython source base.</p>
<p><span id="more-77"></span></p>
<p>Modjy has been distributed with jython for several months now, in the form of a third party library, as a zip file; I used to maintain the modjy source code in a private subversion repo. But now all of the java and jython source code for modjy has been checked into the jython source base. I did the integration work on a <a href="http://fisheye3.atlassian.com/browse/jython/branches/modjy">dedicated modjy branch</a>. The jython <a href="http://en.wikipedia.org/wiki/Benevolent_Dictator_For_Life">BDFL</a>, <a href="http://fwierzbicki.blogspot.com/">Frank Wierzbicki</a>, then kindly exercised his considerable subversion fu to <a href="http://fisheye3.atlassian.com/changelog/jython/?cs=6075">integrate that branch with the jython trunk</a>, from whence the first jython 2.5 release candidate will be cut.</p>
<p>Jython 2.5 is a fantastic achievement, a tribute to Frank and all of the jython developers!</p>
]]></content:encoded>
			<wfw:commentRss>http://jython.xhaus.com/modjy-now-fully-integrated-into-jython/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Socket shutdown versus socket close on cpython, jython and java.</title>
		<link>http://jython.xhaus.com/socket-shutdown-versus-socket-close-on-cpython-jython-and-java/</link>
		<comments>http://jython.xhaus.com/socket-shutdown-versus-socket-close-on-cpython-jython-and-java/#comments</comments>
		<pubDate>Thu, 29 Jan 2009 18:16:48 +0000</pubDate>
		<dc:creator>alan.kennedy</dc:creator>
				<category><![CDATA[jython]]></category>
		<category><![CDATA[asynchronous]]></category>
		<category><![CDATA[networking]]></category>
		<category><![CDATA[sockets]]></category>

		<guid isPermaLink="false">http://jython.xhaus.com/?p=65</guid>
		<description><![CDATA[So, here we are again with translating cpython socket semantics to java socket semantics, in order to correctly implement the cpython socket API on jython.
The latest issue is socket shutdown.

Cpython sockets have two separate methods related to terminating a socket connection; the close method and the shutdown method.
Before we get into the difference between the [...]]]></description>
			<content:encoded><![CDATA[<p>So, here we are again with translating cpython socket semantics to java socket semantics, in order to correctly implement the cpython socket API on jython.</p>
<p>The latest issue is <strong>socket shutdown</strong>.<br />
<span id="more-65"></span><br />
<a href="http://docs.python.org/library/socket.html#id1">Cpython sockets</a> have two separate methods related to terminating a socket connection; the <strong>close</strong> method and the <strong>shutdown</strong> method.</p>
<p>Before we get into the difference between the two, we should note that when a TCP socket connection is to be terminated, a network packet containing a FIN is sent to the peer, informing them to tear down the connection (although <a href="http://en.wikipedia.org/wiki/Transmission_Control_Protocol#Connection_termination">sometimes an RST packet can be sent instead</a>). It is a sometimes used practice to <a href="http://www.developerweb.net/forum/showthread.php?t=2940">shutdown only one side of a connection</a>. For example, when a client knows that its request has been fully transmitted, it shuts down its transmit stream to the server, but leaves the receive stream open for the response. This makes the clients intention for future communications more explicit, and may lighten the load on the server. However, this is controversial topic, because that can also lead <a href="/?p=5">asynchronous servers</a> to mistakenly think that a socket is readable when it is not. You can find a detailed and thorough discussion of this topic in ActiveState <a href="http://code.activestate.com/recipes/408997/">Recipe 408997: When to not just use socket.close()</a>; make sure to read all of the comments.</p>
<p>The <strong>close</strong> method of sockets closes the file descriptor to which the socket is connected. When the last file descriptor connected to the socket is closed, then the operating system also closes the underlying socket, which results in the transmission of the FIN packet. That wording is important: <em>&#8220;when the last file descriptor .. is closed&#8221;</em> has specific meaning in many unix network servers architectures. The archetypal design for a network server on unix is to accept incoming socket connections in one process, and then spawn a subprocess to service the connection. Since the child process inherits the file descriptor table of its parent, it also inherits a file descriptor for the socket. Which means that there can be multiple file descriptors open on a socket. Which means that closing a socket is not guaranteed to close the connection; that will not happen until <strong>all</strong> file descriptors for the socket are closed.</p>
<p>The <strong>shutdown</strong> method, on the other hand <strong>only</strong> sends the FIN packet, regardless of how many file descriptors are open to the socket; moreover, it doesn&#8217;t affect any of those file descriptors.</p>
<p>There are some problems for implementing <strong>shutdown</strong> on java and thus on jython. Java servers are almost always multi-threaded, and process incoming requests in spawned threads, <strong>not</strong> processes. For this reason, and because of the fact that java does not expose C file descriptors, there are no socket methods that differentiate between the socket and file descriptor; the two are one and the same in java. This applies to all types of socket.</p>
<p>Implementing shutdown will be discussed below under the different socket types</p>
<ol>
<li><strong>TCP client sockets</strong> are fine: <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/net/Socket.html">java.net.Socket</a> objects have the <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/net/Socket.html#shutdownInput()">shutdownInput</a> and <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/net/Socket.html#shutdownOutput()">shutdownOutput</a> methods, which shut down the receive stream and the transmit stream respectively.</li>
<li><strong>TCP server sockets</strong> are different: they don&#8217;t have transmit and receive streams: they exist only to <strong>accept</strong> incoming socket connections. So when a TCP server socket is shutdown, the result of the call should be to close the listen queue for the socket, and discard all queued incoming connections. In java, server sockets do not have a shutdown method (as you can see from their javadocs: <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/net/ServerSocket.html">java.net.ServerSocket</a> and <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/nio/chennels/ServerSocketChannel.html">java.nio.channels.ServerSocketChannels</a>: remember, both classes are required to fully implement all cpython socket semantics in jython). So, how to implement the <strong>shutdown</strong> for TCP server sockets? In java, the same effect is achieved is issuing the <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/net/ServerSocket.html#close()">close</a> method. So the choice is whether or not to make <strong>shutdown</strong> call <strong>close</strong>? Since production code that uses the <strong>shutdown</strong> method will also call the <strong>close</strong> method immediately, or soon afterwards, that would make that series of calls fail. Therefore, the right choice (IMHO) is to have the <strong>shutdown</strong> method as a no-op, i.e. <strong>do nothing</strong>, and document the fact that the user must call <strong>close</strong> on the socket in the <a href="http://wiki.python.org/jython/NewSocketModule">jython socket module documentation. </a></li>
<li><strong>UDP sockets</strong>, similarly don&#8217;t have input and output streams; calling shutdown on the socket should stop the acceptance of incoming packets. But in java, neither <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/net/DatagramSocket.html">java.net.DatagramSocket</a>s nor <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/nio/channels/DatagramSocket.html">java.nio.channels.DatagramSocketChannel</a>s have <strong>shutdown</strong> methods; instead the same effect is achieved in by calling the <strong>close</strong> method. So, the right choice for the <strong>shutdown</strong> of UDP sockets is to make it a no-op, and document that fact.</li>
</ol>
<p>I have checked in an implementation of the above into the jython SVN; in the release 2.2 maintenance branch at <a href="http://fisheye3.atlassian.com/changelog/jython?cs=6000">revision 6000</a> and into trunk at <a href="http://fisheye3.atlassian.com/changelog/jython?cs=6001">revision 6001</a>. I have put together this page to record my reasoning for implementing things this way, and the research that I&#8217;ve done in trying to arrive at the right implementation. Or at least, an implementation that is <strong>as right as possible</strong> for the jython programmer.</p>
<p>On a related note, I see that the good people over in <a href="http://twistedmatrix.com/">Twisted Matrix</a> are making <a href="http://twistedmatrix.com/trac/ticket/3413">great progress with getting twisted running on jython</a>. It will be fantastic to see one of the premier python <a href="/?p=5">asynchronous frameworks</a> working on jython!</p>
<p>Lastly, thanks to <a href="http://twistedmatrix.com/glyph/">Glyph Lefkowitz</a> of <a href="http://twistedmatrix.com">twisted</a> for reporting this situation in the jython bug tracker: <a href="http://bugs.jython.org/issue1121">listening socket shutdown expects the wrong kind of socket</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://jython.xhaus.com/socket-shutdown-versus-socket-close-on-cpython-jython-and-java/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
