Monday, November 15, 2010

App Engine Helper for Django - Part I

Even with the easy instructions on installing GAE Django Helper I ran into several problems. Most of these were Import Error.

from google.appengine.ext import db
ImportError: No module named google.appengine.ext

django.core.exceptions.ImproperlyConfigured: 'appengine' isn't an available database backend. 
Try using django.db.backends.XXX, where XXX is one of:
    'dummy', 'mysql', 'oracle', 'postgresql', 'postgresql_psycopg2', 'sqlite3'
Error was: No module named appengine.base


Turns out was not pointing correctly to appengine_django. I had copied the app directory to my project's directory but the path didn't include the project name. The app was still running fine when using launcher. 

Here's how the correct entry should look

#    'django.contrib.auth',
#    'django.contrib.contenttypes',
#    'django.contrib.sessions',
#    'django.contrib.sites',

Another point, although instructions here say that you don't need in your project didn't work for me without it.

I will do another post giving step by step for using django helper for GAE.

Here's a successful run of runserver with django and GAE helper.

ruch:djproject ruchi$ ./ runserver
WARNING:root:Could not read datastore data from /var/folders/d9/d92Wee6VGY4YhfNUP1rgnU+++TM/-Tmp-/django_mixq.datastore
WARNING:root:Could not initialize images API; you are likely missing the Python "PIL" module. ImportError: No module named _imaging
INFO:root:zipimporter('/Users/ruchi/djproject/', 'django/contrib/')
INFO:root:Checking for updates to the SDK.
INFO:root:The SDK is up to date.
WARNING:root:Could not read datastore data from /var/folders/d9/d92Wee6VGY4YhfNUP1rgnU+++TM/-Tmp-/django_mixq.datastore
WARNING:root:Could not initialize images API; you are likely missing the Python "PIL" module. ImportError: No module named _imaging
INFO:root:Running application mydjapp on port 8000: http://localhost:8000

Friday, November 12, 2010

Exporting Contacts from Facebook - How many care?

There have been discussions around how Facebook is evil about not letting "everyone" get their contact data out unless they happen to have a free yahoo or hotmail account. The discussions 

Techcrunch has an article today about how to create a new yahoo account to get most of your contact data out.

Do people care about their contact data? How many of them do?

The contact data I'm importing to Facebook is already with me on gmail, why do I care if Facebook is gonna lock it down? Even if we consider that I might need contact data of my new Facebook friends, how many people are still use email anyways? Isn't most communication thru Facebook status and messages or IM's.

People who care about the data are in minority. Techcrunch reaches 0.7% global users while Facebook has 37.3% global reach. Even if 10 fold techcrunch readers cared about their data, they are still not enough.

I know it can be debated that people have no option but to join where their friends are. Would you make deposits in a bank where you cannot withdraw the interest that your money generates? The point being people don't value their contacts like Facebook does.

Thursday, November 11, 2010

GAE Error when displaying datastore entity key

TypeError: write() argument 1 must be string or read-only character buffer, not Key

I was trying to display key for an entity. Python/ Java API returns keys as an instance of the entity class. Convert it to string to pass it or to display.

Running Django on Google App Engine

It took about five hours but I did it!!!

Google has this simple tutorial on how to start first Django project on GAE. It's helpful but not enough to debug all the errors novices run into. Here's the step by step instructions for someone familiar with basic Django.

1. Create the GAE app. 

Let's call it gaeapp.

I use GUI to provide app name and it creates a directory with following files.

2. Create the django project INSIDE the GAE app directory.
If you have created a Django project before, you would know to do so using startproject djprj

Now we have a directory called djprj with following files.

If you want, you can copy all the django files to GAE dir. Make sure to remove all refrences to Django project name. e.g. djprj.settings would become settings.

4. Edit app.yaml
I followed the instructions on the google's tutorial and kept getting error message - "unknown URL handler type". Turns out the code was not indented properly. 

"ERROR    2010-11-11 06:42:51,957] Fatal error when loading application configuration:

while scanning a simple key
  in "~/gaeapp/app.yaml", line 8, column 1
could not found expected ':'"

Received above error since static_dir: and static were not separated by space. 

So this is how my appl.yaml looks
application: gaeapp
version: 1
runtime: python
api_version: 1

- url: /static
  static_dir: static
- url: .*

5. Edit
Here's how my looks. Note that if both django and GAE files are in the same folder, you should point DJANGO_SETTINGS_MODULE to the current directory and omit the Django project name unlike the google tutorial.

I kept getting message about DJANGO_SETTINGS_MODULE is not defined and then it disappeared. 

import os, logging
from google.appengine.ext import webapp
from google.appengine.ext.webapp import util

from django.conf import settings

import django.core.handlers.wsgi
import django.core.signals
import django.db
import django.dispatch.dispatcher

#class MainHandler(webapp.RequestHandler):
#    def get(self):
#        self.response.out.write('Hello World!')

def main():
    #application = webapp.WSGIApplication([('/', MainHandler)], debug=True)

if __name__ == '__main__':

6. Edit
  1. Comment out all of the middleware parameter else you might get this error "AttributeError: 'module' object has no attribute 'messages'".
  2. Ensure ROOT_URLCONF = 'urls' if  Django files are in GAE dir. Else it will be djprj.urls since our project is called djprj.

7. Done! 
Run the GAE app and the corn blue awaits you.

8. Doing the work - adding code
Standard Django practice is to have code in So let's 
create a in Django dir. This will contain some code for first Django GAE app. This is what I've got -

from django.http import HttpResponse

def sayhello(request):
    return HttpResponse("This is my first GAE app using Django")

9. Edit
The standard process of including  code in django url.

from django.conf.urls.defaults import *
from djprj.views import *

from django.conf.urls.defaults import *
from djprj.views import *

urlpatterns = patterns('',

10. Refresh your page or restart your GAE app.

Tuesday, November 09, 2010

An African Elephant Sketch

Here's the original - 

Mine didn't turn out that well. Looks kind of aged. 

Monday, November 08, 2010


Contrasted pink with gray just to see how it looks. Not to bad eh :)

Friday, November 05, 2010

Crayon Sketch

Time to draw : 15 mins

Mac OSX Disk Sweeper

With over year and half of data, my mac harddrive is choking. With backups for previous machines and trip photographs and applications etc. Although I've backup on external harddrive, my fingers still refuse to delete anything worthwhile from my mac. So until I bought another harddrive to backup my backup, I had to do some clean up. A quick googling helped me find this awesome software called Disk Sweeper that gives the directories in the descending order of size.

Jeff Dunham Show

Watched the show at the Ohio State Fair last night. I took a "sky ride" ride and had an aerial view of most of the fairground. They have so many rides! The Celeste Center theatre was right in the middle of the fairgrounds. The theatre is huge and clean but the seats suck! With the uncomfortable, narrow and close seats, it manages to seat 10k.

Show itself was good! Jeff showed a new doll - Diane, who plays his wife in the movie - Dinner for Schmucks. Guitar guy played us three songs before Jeff came onstage. It was fun! The theatre had arranged an interpreter for the hearing impaired.

Amazon Kindle has games

If you have an Amazon Kindle and you didn't already know it, go get your Kindle and try it out like now. When on home screen, press SHIFT (the up arrow key ↑)  + ALT + M and voila - there's the hidden Minesweeper. Use joystick to explore and "m" to mark/unmark mines. And if you hit "g" you could play GoMoku. I had never heard of GoMoku and simply explained it's Tic-Tac-Toe but you need 5 consecutive rows to win.


Minesweeper on Kindle


More on the under the hood working of Kindle here


Checkout the 3D room like appearance of desktop. It looks pretty neat isn't it. You could pile stuff just like in a book store.

The software was developed by bumptop who have been acquired by Google and the software is off the shelves now.

Amazon buying your old books

Amazon is offering a trade in of amazon gift card worth $5 or more for your used books in good condition. These books will be purchased by a Third Party Merchant. How convenient is it that that shipping is free. So no more selling your books for the same amount and wait in queue at halfprice bookstore or reposting those craigslist advts.

Cute Puss sans boots

If you have seen any of the Shrek movies, well not any, but ones after 1st Shrek you know who Puss is. Puss is the ninja cat - nimble, fast, sharp and in the boots at that. This is how Puss looked before.

With Shrek Forever After, Puss gets a make over...a big fat one. One of the most hilarious scenes from the movie, when puss and donkey are drenched are trying to groom themselves.
While looking for pics, I learnt that there really is a fairy tale character by the same name and also has a sophisticated French name to boot :-) Le Maistre Chat  (the master cat) and also ou Le Chat Botté (the booted cat).
Here's the complete story with colorful illustrations.

Wednesday, May 19, 2010

We are Shortsighted

We are a product of our choices. Even when we thought we didn’t have a choice we did.

If we have choices all along why do we feel so discontented? Because we are timing our decisions wrong. Rather than focusing on what will make us happier today we are making choices for the self that we think we will be in future. But when the future comes we are anything but happy about our decisions. How often are you amused by naivety of your younger self? We change and so does the world around us. Our experiences shift our thinking and our thoughts no longer align with our previous ones. We need to realize this disparity and be cognizant that the obvious choices today would still rub us the wrong way tomorrow.

[All this is discussed in detail in Daniel Gilbert’s book ‘Stumbling on Happiness’.]

Tuesday, May 18, 2010

Coders and Insurance

At work a program fell flat and wiped out the backup eliminating any hope of recovery. The coder said she had not expected the program would ever encounter a condition like this and hence never accounted for it. In an ideal situation..., she continued, but she had lost me.

I wonder how could humble people who take out insurance policies on themselves miss to see fallibility of the applications they create. By taking insurance they accepted fallibility of their own body or mind. At the same time they weren’t “expecting” something to happen to them. It was just a way of ensuring things go smooth in the event of a failure.

I would suggest we take out the insurance on our programs too, just in case.

Wednesday, May 05, 2010


Reading has been keeping me busy apart from endless browsing and listless browsing. I find time to watch a 1 hour TV episode but not a 10 minute tutorial. I guess it's all in the mental setup. The mindset that we are too tired to do anything. In 'How to live on 24 hours a day', that author (forgot his name, he isn't a movie star after all; but I often refer to Robert De Niro as 'What just happened' guy for lack of affinity for his name). So the author suggests if we are tired to do anything fruitful we ought to correct our routine. So am trying to do that by going to gym regularly and trying to sleep early.

But I was gonna talk about my reading. So I got a Kindle last month. It's by far my favorite gadget; so light and beautiful; and keeps me away from jumping on the internet and losing my time. The only thing I miss is a touch screen on it which will make using it's dictionary feature super easy. It's great to get all those classics on Kindle and read away.

So since last month I've read quite a few books - The Curious Case of Benjamin Button - an incredible, witty short story. Am a Fitzgerald fan now.

Adventures of Alice in Wonderland, hadn't read the book although I saw the animation. I used to be scared to Queen of Heart as a kid. She wasn't that scary in the book. Perhaps the next in the series will change that opinion.

And then the ultimate - Three men in a boat and to say nothing of the dog. O Man! This is like opium. I would say this is round tine. It's so ineffably funny but yet J penned it! I read it and read again to whoever will listen.

Am now reading the Great Expectations by Charles Dickens. It seems interesting but am still yearning for more of Jerome K Jerome. If I go to gym I reward myself by reading - 'The importance of being Earnest' by Oscar Wild(e). It's a satirical play. During my lunch I've been reading autobiography of Virgin owner - Richard Branson. It's so interesting it feels like fiction.

PS - The name of author is Arnold Bennett.

Tuesday, May 04, 2010


Last week I tried my hands at The Cheesecake Factory style cheesecake. I had intended to stick to the recipe to get it just right. The cake turned out good even after my slight deviations. The recipe suggested a mixed nut crust and it's to die for. It's worth just baking the crust as snack bars.

The tin foil cake-pans I bought ended up smaller than I needed and I didn't have any spring-foam cake-pans. The recipe on Philadelphia Cream Cheese suggested I use the regular 9" dia pan and line it with foil leaving out enough foil to lift the cake out of the pan. It worked quite well and was fun to do it.

The pan turned out to be smaller for the suggested ingredients. Of course I was mixing suggestions from two different recipes. I left out one egg.

When is my Cheesecake done?
I baked the cake as suggested but it cracked and looks like it was due to over baking. To check if your cheesecake is done; give the cake-pan a jerk. If the center wobbles, it needs more time. If it barely moves, it's done.

Monday, March 15, 2010


Journey into the animal kingdom continues from cat, horse to tiger. I guess next would be lion.

Checkout the video with 34 stages of the sketch. It took me 5 seatings spread across 3 months to finish it...mostly because I was lazy and it looked like a daunting task after 50% into it.

Also learned that if you're creating a movie with pics in iMovie it will add Ken burn effects by default and any changes to project properties don't get applied?? Create a new project, alter the project properties and then add pics.

Thursday, February 04, 2010

Sunday, January 31, 2010


My shoulders are sore;
ankle sprained.
hamstrings are pulled;
all the signs of age.
But, hey, I’m not getting old.
It's just that yesterday,
I did snowboard.

I relish snowboarding and the pain that devours me afterward; it reminds me of the fun I had. I started snowboarding in 2007 in Snoqualmie after having given up skiing previous season; I had hurt my knee and wore a knee pad of poison ivy, it was really that itchy, for ten days and limped my way to work.

It didn't go very well on day one of snowboarding. I considered myself inapt at learning but my friend encouraged me and practiced with me. Gave me hope. So I dragged on with the board with one feet tied to it and other lazily pushing it.

With the second and third class I was improving. I'm glad that I had the hope and determination.

I had learned to fall like a leaf and make J turns. I graduated from magic carpet (it's a conveyor belt type ski lift in beginner's area) to chair lift (30 ft off the ground cable lift).

This year I bought my own snowboard :-)

I can ride down without falling down most of the times but I make up for that while getting down the chair lift. It gets me every time. I entangle my snowboard with my co-rider and we fall together. I almost offended someone when I refused to ride the lift with them. I feared for their safety.

Chair lift is a good place to meet people. Last time I met the ski patrol who is a locale to the Mansfield resort and he told me how their street name changed forever when a TV reporter on National TV called 'Possum Run' as 'Opossum Run' to go with O of Ohio.

This time I met someone who stated that he has been skiing/snowboarding his entire life. He started at an age of 2 and is presently 8 or 9 years old.

Yesterday I took lessons to do c-turns and I know that it takes a sprained ankle to do it right.

It's an immense pleasure to snowboard and I'd suggest you to give it a try but let me warn you that it's fatal and addictive.

Snowboarding Video Tutorials

Ski resorts in Columbus open in 1st or 2nd week of Dec and close during 2nd week of March.
Mad River Mountain