<?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>Blog - ShiftEleven &#187; appengine</title>
	<atom:link href="http://shifteleven.com/articles/tag/appengine/feed" rel="self" type="application/rss+xml" />
	<link>http://shifteleven.com</link>
	<description></description>
	<lastBuildDate>Mon, 09 Jan 2012 04:04:19 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>A Tip For People using Google Code and the Issue Tracker</title>
		<link>http://shifteleven.com/articles/2008/04/12/a-tip-for-people-using-google-code-and-the-issue-tracker?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=a-tip-for-people-using-google-code-and-the-issue-tracker</link>
		<comments>http://shifteleven.com/articles/2008/04/12/a-tip-for-people-using-google-code-and-the-issue-tracker#comments</comments>
		<pubDate>Sun, 13 Apr 2008 01:12:57 +0000</pubDate>
		<dc:creator>K. Adam Christensen</dc:creator>
				<category><![CDATA[Software Development]]></category>
		<category><![CDATA[appengine]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[goole]]></category>
		<category><![CDATA[issuetracker]]></category>

		<guid isPermaLink="false">http://shifteleven.com/?p=49</guid>
		<description><![CDATA[If you are using Google Code, and let&#8217;s say that you want an issue addressed, like having ruby supported in GAE Please, Please, PLEASE, use the star voting and avoid making comments that are simply &#8220;+1&#8243;. The more stars a &#8230; <a href="http://shifteleven.com/articles/2008/04/12/a-tip-for-people-using-google-code-and-the-issue-tracker">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>If you are using Google Code, and let&#8217;s say that you want an issue addressed, like <a href="http://code.google.com/p/googleappengine/issues/detail?id=29.">having ruby supported in <acronym title="Google App Engine">GAE</acronym></a> Please, Please, PLEASE, use the star voting and avoid making comments that are simply &#8220;+1&#8243;.  The more stars a defect has, the more attention it has, not the number of comments and especially the number of &#8220;+1&#8243;s.</p>
<p>Actually, you <strong>hurt</strong> the initiative to get an issue addressed when you make those comments.  You see, when you star an issue, you receive emails when that issue gets updated or commented upon.  So if an issue has 100 or so &#8220;+1&#8243; comments, then whoever put a star on that defect is going to get 100 or so emails.  After getting 20 inane emails, one might decide to remove the star from the issue, thus lowering it&#8217;s rating and hurting the campaign.</p>
<p>So please, if you want to help, just star the issue.</p>
]]></content:encoded>
			<wfw:commentRss>http://shifteleven.com/articles/2008/04/12/a-tip-for-people-using-google-code-and-the-issue-tracker/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Problem with writing RESTful Google App Engine Code</title>
		<link>http://shifteleven.com/articles/2008/04/12/problem-with-writing-restful-google-app-engine-code?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=problem-with-writing-restful-google-app-engine-code</link>
		<comments>http://shifteleven.com/articles/2008/04/12/problem-with-writing-restful-google-app-engine-code#comments</comments>
		<pubDate>Sat, 12 Apr 2008 23:57:07 +0000</pubDate>
		<dc:creator>K. Adam Christensen</dc:creator>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[appengine]]></category>
		<category><![CDATA[defect]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[restful]]></category>
		<category><![CDATA[webob]]></category>

		<guid isPermaLink="false">http://shifteleven.com/?p=48</guid>
		<description><![CDATA[So after I used middleware to make browsers work with RESTful URLs in GAE I started to write more than simple little methods and I&#8217;m trying to write a test application. Upon doing so, I ran into a defect with &#8230; <a href="http://shifteleven.com/articles/2008/04/12/problem-with-writing-restful-google-app-engine-code">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>So after I used middleware to <a href="http://shifteleven.com/articles/2008/04/08/letting-browsers-use-all-of-the-methods-in-google-app-engine,">make browsers work with RESTful URLs in <acronym title="Google App Engine">GAE</acronym></a> I started to write more than simple little methods and I&#8217;m trying to write a test application.  Upon doing so, I ran into a <a href="http://code.google.com/p/googleappengine/issues/detail?id=170.">defect with how request parameters are returned for a PUT request</a> To be fair, this is more of a problem with <a href="http://pythonpaste.org/webob/">webob</a> than with GAE, but I hope that this gets fixed because my attempts at <a href="http://mail.python.org/pipermail/python-dev/2008-January/076194.html">monkey patching</a> the problem have not worked out too well.</p>
]]></content:encoded>
			<wfw:commentRss>http://shifteleven.com/articles/2008/04/12/problem-with-writing-restful-google-app-engine-code/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Letting Browsers use all of the RESTful Methods in Google App Engine</title>
		<link>http://shifteleven.com/articles/2008/04/08/letting-browsers-use-all-of-the-methods-in-google-app-engine?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=letting-browsers-use-all-of-the-methods-in-google-app-engine</link>
		<comments>http://shifteleven.com/articles/2008/04/08/letting-browsers-use-all-of-the-methods-in-google-app-engine#comments</comments>
		<pubDate>Wed, 09 Apr 2008 02:45:05 +0000</pubDate>
		<dc:creator>K. Adam Christensen</dc:creator>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[appengine]]></category>
		<category><![CDATA[browsers]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[middleware]]></category>
		<category><![CDATA[rack]]></category>
		<category><![CDATA[restful]]></category>
		<category><![CDATA[wsgi]]></category>

		<guid isPermaLink="false">http://shifteleven.com/?p=46</guid>
		<description><![CDATA[So there was much talk and whathave you about Google&#8217;s new App Engine and after viewing the tutorials and reading the documentation, I thought it was pretty rad too. Because I was using rack for some previous stuff, WSGI felt &#8230; <a href="http://shifteleven.com/articles/2008/04/08/letting-browsers-use-all-of-the-methods-in-google-app-engine">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>So there was much talk and whathave you about Google&#8217;s new <a href="http://code.google.com/appengine/,">App Engine</a> and after viewing the tutorials and reading the documentation, I thought it was pretty rad too.  Because I was using <a href="http://rack.rubyforge.org/">rack</a> for some previous stuff, <a href="http://www.wsgi.org/">WSGI</a> felt right at home (probably because rack was modeled after WSGI).  There was one thing that bothered me however.  When writing a class using their <a href="http://code.google.com/appengine/docs/webapp/">webapp framework</a> there isn&#8217;t any magic param name, like <code>_method</code>, that I could use to mock requests methods like <code>DELETE</code> and <code>PUT</code> since the browser doesn&#8217;t support those HTTP methods.</p>
<p>Well my friends, fear not.  If you enjoy the sweet freedom of RESTful urls, I&#8217;m here to help.  Since this is all built on top of WSGI, we can create a some new Middleware to sit before the application to resolve this little issue.</p>
<p><span id="more-46"></span></p>
<h3>MockHTTPMethodMiddleware</h3>
<pre class="python" title="code">from google.appengine.ext import webapp

class MockHTTPMethodMiddleware(object):
  def __init__(self, app):
    self.app = app

  def __call__(self, environ, start_response):
    method = webapp.Request(environ).get('_method')
    if method:
      environ['REQUEST_METHOD'] = method.upper()
    return self.app(environ, start_response)</pre>
<p>The code is pretty simple.  So when this middleware is called, it processes the <code>environ</code> into a <code>Request</code> object.  From there, I just inspect the params for a key called <code>_method</code>.  If that param exists, then it overwrites the <code>REQUEST_METHOD</code> and bam&#8230;we have mocked the HTTP method of our choosing.</p>
<h3>Putting that code to good use</h3>
<p>Let&#8217;s pretend that this is our class is something inane like this:</p>
<pre class="python" title="code">from google.appengine.ext import webapp

class MethodTest(webapp.RequestHandler):
  def get(self):
    self.response.headers["Content-Type"] = 'text/text'
    self.response.out.write("Get")

  def put(self):
    self.response.headers["Content-Type"] = 'text/text'
    self.response.out.write("Put")</pre>
<p>So now when you are writing your <code>main</code> method that creates the WSGI application, you would write it something like:</p>
<pre class="python" title="code">import wsgiref.handlers

def main():
  app = webapp.WSGIApplication(
      [('/', MethodTest)],
      debug=True)
  wsgiref.handlers.CGIHandler().run(MockHTTPMethodMiddleware(app))

if __name__ == "__main__":
  main()</pre>
<p>Notice that in the run method arguments, <code>MockHTTPMethodMiddleware</code> takes <code>app</code> as a parameter, thus <code>MockHTTPMethodMiddleware</code> will run before it runs <code>app</code>.</p>
<h3>Conclusion</h3>
<p>While there wasn&#8217;t support out of the box for mocking HTTP methods for browsers, with a little help from a WSGI Middleware class, it&#8217;s not too hard to add that functionality in, nor is it hard to add anything else you would want to use.</p>
]]></content:encoded>
			<wfw:commentRss>http://shifteleven.com/articles/2008/04/08/letting-browsers-use-all-of-the-methods-in-google-app-engine/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

