<?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; google appengine</title>
	<atom:link href="http://jython.xhaus.com/category/google-appengine/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>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>
	</channel>
</rss>
