<?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>Swarling Black Mable &#187; google</title>
	<atom:link href="http://blainegarrett.com/tag/google/feed/" rel="self" type="application/rss+xml" />
	<link>http://blainegarrett.com</link>
	<description>Blaine Garrett's Home on the Web - Art, Programming, Ideas, and more</description>
	<lastBuildDate>Tue, 02 Aug 2011 18:50:05 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1</generator>
		<item>
		<title>Appengine: getCurrentUser() is None but app.yaml login:admin Allows Access?</title>
		<link>http://blainegarrett.com/2010/05/14/appengine-getcurrentuser-is-none-but-app-yaml-loginadmin-allows-access/</link>
		<comments>http://blainegarrett.com/2010/05/14/appengine-getcurrentuser-is-none-but-app-yaml-loginadmin-allows-access/#comments</comments>
		<pubDate>Fri, 14 May 2010 21:20:28 +0000</pubDate>
		<dc:creator>blainegarrett</dc:creator>
				<category><![CDATA[Google AppEngine]]></category>
		<category><![CDATA[app.yaml]]></category>
		<category><![CDATA[appengine]]></category>
		<category><![CDATA[getCurrentUser]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[login]]></category>
		<category><![CDATA[service]]></category>
		<category><![CDATA[user]]></category>

		<guid isPermaLink="false">http://blainegarrett.com/?p=884</guid>
		<description><![CDATA[Today, while working on Google AppEngine code, I discovered a bug in AppEngine, but it just turned out to be a typo. I spent a good few hours googling before tearing things apart and solving the tricky issue. As such, I am sharing my finds to help others&#8217; save some time and stress. Short version [...]]]></description>
			<content:encoded><![CDATA[<p><a rel="attachment wp-att-840" href="http://blainegarrett.com/2010/01/25/appengine-djangogql-ensuring-uniqueness-of-model-type-on-edit/saupload_google_appengine/"><img class="alignleft size-full wp-image-840" src="http://blainegarrett.com/files/2010/01/saupload_google_appengine.png" alt="saupload_google_appengine" width="250" height="250" /></a>Today, while working on Google AppEngine code,  I discovered a bug in AppEngine, but it just turned out to be a typo. I spent a good few hours googling before tearing things apart and solving the tricky issue. As such, I am sharing my finds to help others&#8217; save some time and stress. <strong>Short version is to check your regular expressions in the app.yaml file when adding security to an entire folder.</strong></p>
<p><strong>Here is the skinny: </strong><br />
I was running into an unexpected issue with the AppEngine users service on a folder locked down by app.yaml. I had a folder <strong>/cms/</strong> that I wanted the contents of to only be viewed by admin users to my Google AppEngine project. All pages inside of the directory displayed the email address of the user as well as a log out link. I was using <strong>users.GetCurrentUser() </strong> and <strong>users.create_logout_url</strong> to display this. The folder itself was being locked down at the app.yaml level. Aside from this, there was no other security (@require_admin decorators, etc). After testing, I discovered I was able to return to pages within /cms/ while being logged out via the <strong>users.create_logout_url</strong> link. <strong>users.GetCurrentUser() </strong> was returning None as expected, but I figured I would be redirected to a Google login page. </p>
<p>I figured this might be a bug with the current sdk, but I wasn&#8217;t willing to assume that until I had support. After submitting to the python mailing list with no reply, some googling, I started debugging the app.yaml. In the end I discovered it to be the url matching condition to the app.yaml file &#8211; essentially a logical &#8220;typo&#8221;. For what it is worth, I didn&#8217;t check here first because I am making changes to an existing set of code that already had the app.yaml condition in place. However, if you are in the same boat ever, hopefully this info will help.</p>
<p>So, if you think you have a folder locked down with app.yaml and users are still able to visit the page while logged out, check the url conditions. Examples below:</p>
<p>My app.yaml has</p>
<pre class="brush: python">
#- url: /cms # BAD VERSION - only protects a file named cms in the root, not the cms folder&lt;/del&gt;
- url: /cms.* # GOOD VERSION - protects any url matching the regexp &quot;starts with &#039;/cms&#039; followed by any number of characters (including &#039;/&#039;) &quot;
  script: main.py
  login: admin
  secure: always
</pre>
<p>Hopefully, that helps someone out. I know I wasted lunch break figuring it out. </p>
<p>On the page, I display the value of users.GetCurrentUser() and have a logout link generated by users.create_logout_url(&#8216;/home/&#8217;).<br />
When I click logout, I am redirected to /home/ as expected.</p>
<p>The odd behavior is that I can then go to /cms/ again without having to reauthenticate. The value of users.GetCurrentUser() is None (as expected).<br />
However, I would expect the app.yaml to cause me to be redirected to the Google login screen when trying to revisit logged out.</p>
<p>I have not tested on production yet. Is this correct behavior and/or a known issue on dev sdk?</p>
]]></content:encoded>
			<wfw:commentRss>http://blainegarrett.com/2010/05/14/appengine-getcurrentuser-is-none-but-app-yaml-loginadmin-allows-access/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Appengine Django/GQL &#8211; Ensuring Uniqueness of Model Type on Edit &#8211; Not Equals Filters</title>
		<link>http://blainegarrett.com/2010/01/25/appengine-djangogql-ensuring-uniqueness-of-model-type-on-edit/</link>
		<comments>http://blainegarrett.com/2010/01/25/appengine-djangogql-ensuring-uniqueness-of-model-type-on-edit/#comments</comments>
		<pubDate>Mon, 25 Jan 2010 22:40:33 +0000</pubDate>
		<dc:creator>blainegarrett</dc:creator>
				<category><![CDATA[Google AppEngine]]></category>
		<category><![CDATA[appengine]]></category>
		<category><![CDATA[Django]]></category>
		<category><![CDATA[filter]]></category>
		<category><![CDATA[forms]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[unique]]></category>

		<guid isPermaLink="false">http://blainegarrett.com/?p=837</guid>
		<description><![CDATA[Edit 2009-02-02 - Added note about inequality query complexity. Spoiler &#8211; inequalities are 2 queries under the hood. In my further adventures in Google AppEngine land, I wanted to ensure uniqueness of an email field while still allowing the user to change their email address. Since, Google App Engine&#8217;s BigTable doesn&#8217;t allow you to custom [...]]]></description>
			<content:encoded><![CDATA[<p><a rel="attachment wp-att-840" href="http://blainegarrett.com/2010/01/25/appengine-djangogql-ensuring-uniqueness-of-model-type-on-edit/saupload_google_appengine/"><img class="alignleft size-full wp-image-840" src="http://blainegarrett.com/files/2010/01/saupload_google_appengine.png" alt="saupload_google_appengine" width="250" height="250" /></a></p>
<p><strong>Edit 2009-02-02 -</strong> Added note about inequality query complexity. Spoiler &#8211; inequalities are 2 queries under the hood.</p>
<p>In my further adventures in Google AppEngine land, I wanted to ensure uniqueness of an email field while still allowing the user to change their email address. Since, Google App Engine&#8217;s BigTable doesn&#8217;t allow you to custom define unique indexes, this poses a problem. Instead of relying on database defined indexes, you have to set up your own rules, which is a wee bit tricky for GAE beginners such as me.<br />
<a href="http://squeeville.com/2009/01/30/add-a-unique-constraint-to-google-app-engine/">This can be done in general by overloading the put() method on an entity</a>, but I wanted to be able to handle the errors nicely for the form UI.</p>
<p>The old Django Method:</p>
<pre class="brush: python">
#account = account entity you are editing
email = form.cleaned_data[&#039;email&#039;].lower()
users_with_this_email = User.objects.filter(email=email).exclude(pk=account.pk).count()
if (users_with_this_email &gt; 0):
# do something...
</pre>
<p>The new Google AppEngine Big Table GQL method:</p>
<pre class="brush: python">
#account = account entity you are editing
...
email = form.cleaned_data[&#039;email&#039;].lower()
users_with_this_email = Account.all().filter(&#039;email = &#039; , email).filter(&#039;__key__ != &#039; , account.key()).count(1)
if (users_with_this_email &gt; 0):
# do something...
</pre>
<p>The key here is making sure some OTHER entity does not also have the value for their email field.<br />
In regular Django, an entity will evaluate to its primary key when used in a query and can be filtered on &#8216;pk&#8217; .<br />
GQL, however, the primary key needs to be explicitly fetched via entity.key() and filtered on __key__</p>
<p>A couple other notes:</p>
<ul>
<li>GQL does have an email property. I have not run tests yet to tell if this is case sensitive.</li>
<li><a href="http://gae-java-persistence.blogspot.com/2009/11/case-insensitive-queries.html">GQL does not allow case-insensitive searches like regular Django does</a>. Thus, I am making sure all email addresses are lowercased when inserting and querying against the db. Even if this is not needed for EmailProperties, you will need it for ensuring the uniqueness of other types.</li>
<li>!= filters are actually ran as two queries &#8211; one where the != is replace with a less than inequality filter, and one where it is replaced with a greater than inequality  filter. No word at the moment if this applies to __key__ searches.</li>
<li>A query with a != cannot have inequality filters because of the above rule nor other != filters.</li>
</ul>
<p>Related Links</p>
<ul>
<li><a href="http://squeeville.com/2009/01/30/add-a-unique-constraint-to-google-app-engine/">Add A Unique Constraint to Google App Engine</a> via Squeeville</li>
<li><a href="http://gae-java-persistence.blogspot.com/2009/11/case-insensitive-queries.html">Case Insensitive Queries</a> via GAE Java Persistence</li>
<li><a href="http://code.google.com/appengine/docs/python/datastore/typesandpropertyclasses.html">Appengine Types and Properties</a> via Google Code</li>
<li><a href="http://code.google.com/appengine/docs/python/datastore/queriesandindexes.html">Queries and Index </a>via Google Code &#8211; discussion on inequalities and != filters</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blainegarrett.com/2010/01/25/appengine-djangogql-ensuring-uniqueness-of-model-type-on-edit/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Will Wolverine be in Imax? Trolls Ruin Google&#8230;</title>
		<link>http://blainegarrett.com/2009/04/27/will-wolverine-be-in-imax-trolls-ruin-google/</link>
		<comments>http://blainegarrett.com/2009/04/27/will-wolverine-be-in-imax-trolls-ruin-google/#comments</comments>
		<pubDate>Mon, 27 Apr 2009 18:42:01 +0000</pubDate>
		<dc:creator>blainegarrett</dc:creator>
				<category><![CDATA[Reflection]]></category>
		<category><![CDATA[Wasting Time]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[rants]]></category>
		<category><![CDATA[trolls]]></category>
		<category><![CDATA[wolverine]]></category>

		<guid isPermaLink="false">http://blainegarrett.com/?p=519</guid>
		<description><![CDATA[Just a quick rant&#8230; My old buddy Jin and I have been planning on catching the new Wolverine flick together for a long time. I know it was leaked to unflattering reviews, but I really don&#8217;t care. He is coming from St. Cloud and I am coming from Minneapolis. So we were thinking it might [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: left"><a href="http://blainegarrett.com/files/2009/04/trolls_motivational_poster_by_captain_gamer.jpg"><img class="alignleft size-full wp-image-521" src="http://blainegarrett.com/files/2009/04/trolls_motivational_poster_by_captain_gamer.jpg" alt="trolls_motivational_poster_by_captain_gamer" width="300" height="240" /></a>Just a quick rant&#8230;</p>
<p style="text-align: left">My old buddy Jin and I have been planning on catching the new Wolverine flick together for a long time. I know it was leaked to unflattering reviews, but I really don&#8217;t care.</p>
<p style="text-align: left">He is coming from St. Cloud and I am coming from Minneapolis. So we were thinking it might be cool to try to hit the IMAX in St. Michael. But thus far, the ticket sites were not showing anything for IMAX.</p>
<p style="text-align: left">So i decided to google it. The first result was <a href="http://www.comicbookmovie.com/forum/?ft=39230">Comic Book Movie Forums / X-Men Movies / Will Wolverine be in Imax</a>. Someone, like me, posed the question, &#8220;<span>Will Wolverine be in Imax?&#8221; to which all the replies are some form of &#8220;who cares. That movie sucks&#8221; or &#8220;your mom is a slut&#8221;. Neat. </span></p>
<p style="text-align: left"><span>Now, I am fine with the Internet being full of crap like this, but I wish google had a way to filter it out. Yes, this matched my search description, but there was no real valuable information there. I&#8217;m sure through stumble upon or some hip crazy cool firefox extension, you can rank results. But, god damn google, isn&#8217;t the Skynet type AI you are running on smart enough to give me legitimate answers versus the ramblings of dipshit internet trolls?</span></p>
<p style="text-align: left"><span>End rant.<br />
</span></p>
]]></content:encoded>
			<wfw:commentRss>http://blainegarrett.com/2009/04/27/will-wolverine-be-in-imax-trolls-ruin-google/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

