Category: Python

The famous Zen of python was written by Tim Peters. As now I will be writing posts here about Python too, so I thought I should start with the Zen of Python.

Small Easter Egg

If you have Python Interpreter you might want to try out the following.import this

The Zen of Python

Beautiful is better than ugly. Explicit is better than implicit. Simple is better than complex. Complex is better than complicated. Flat is better than nested. Sparse is better than dense. Readability counts. Special cases aren’t special enough to break the rules. Although practicality beats purity. Errors should never pass silently. Unless explicitly silenced. In the face of ambiguity, refuse the temptation to guess. There should be one– and preferably only one –obvious way to do it. Although that way may not be obvious at first unless you’re Dutch. Now is better than never. Although never is often better than right now. If the implementation is hard to explain, it’s a bad idea. If the implementation is easy to explain, it may be a good idea. Namespaces are one honking great idea — let’s do more of those!

If you will have a look at OAuth examples on twitter apiwiki there are already examples available to use Sign in with Twitter with Django, so why this new howto and example code. Because being a perfectionist I like things to be the standard way, so for authentication django allows you to specify your own customized authentication backends. I thought why should not that be utilized to authenticate the Django User object with twitter.

There are few pre-requisites listed below in the order they are needed:

12. Goto http://localhost:8000/login and you will be redirected to twitter for authentication, and if you have done everything correctly then after Allowing your application you will see the message that your are logged in.

Using OAuth for authentication is quite different then using Basic Auth in many ways, first major difference is that one don’t know the username until it is requested from twitter after completing the authentication process.

Get user information

This api call was not present in python-twitter and the user info call expected that there we know the username before making call, but this is not the case with OAuth, so we have to request User Information so we can use it in our application.

NOTE: Need to create the new instance of OAuthApi using access_token from last step.

If you are a python developer and you tried to develop some application for twitter, you must have came acrossed python-twitter. Which provides you a pythonic interface to twitter, by allowing you to access almost all twitter objects as python objects. python-twitter is still in devleopment, and hence still does not have the OAuth compatibility. I am being a oauth pro, deicided to write a derived class from python-twitter, to allow OAuth to be used as the authentication mechnism for python-twitter.

python-twitter is being developed by our beloved google’s employee: DeWitt Clinton

In the next following posts I will posting about how I am using it with Django specifically and how I have writter my TwitterAuthBackend for Django. The whole purpose of publishing the code is to get improvements and reviews on the code, so I have allowed non-members to review the above project on code.google.com, you are more then welcome to post your coments here or review the code on the project. Let me know if you don’t understand anything by asking questions in comments.

As you all might have noticed that I was not posting for a while now, actually had been taken overy by few projects. But today I thought to post about the updates from Google App Engine. Google App Engine have released the Cookbook where you can submit your recipies or can benefit from other people’s snippets of code.

One more thing that Google App Engine team has done which is really useful, they have included the documentation with SDK, so if you are offline you will still have access to SDK. This will not let your engine stops even if you are not connected to internet.

If you haven’t been following Google App Engine Blog, according to latest post the Google App Engine is getting popularity and many programmers are learning python just to play with App Engine. According to Marzia Niccolai on Google App Engine Blog:

So, if you want to host your application on reliable Google platform then you gotta learn Python to make your next app in Google App Engine. Google App Engine is going to be the next big thing if they started supporting rest of the languages like PHP, Ruby and Perl which they have already promised. So stay tuned.

Google I/O the developer event that happened in SanFransisco, many were able to join it but there are thousands of people who were not able to join it Google has not forgotten them. The videos of almost all the talks has been posted but the best one is “Rapid Development wiht Python, Django and Google App Engine“.

Its a must watch video so I decided to share it here. I hope you will benefit from it. You can get the presentation slides from here.

If you like the above video then there are few other good videos too related to Google App Engine, so if you ware interested in learning Google App Engine and not only that but there are videos for other Google technologies which include Gears, Gadgets, OpenSocial and gData. Have look at Google I/O session videos posted with slides

Wow! Great news for python developer out there, Google has open the signup for their App Engine. Now every one can signup for the App Engine account. If you haven’t got your account yet and want to be on the bleeding edge of web development, then go and signup for App Engine and have some fun with App Engine SDK then you can upload you app.

Google App Engine has also introduced to new API which includes Image manipulation and our all time favourite memcache API. So, its time to put the fun back into web development and lets develop some useful apps based on App Engine.

If you are Django Developer then you can put your Django Apps on Google App Engine too. Happy developing.

Note: If you are not a developer and want to see something developed on App Engine, then leave a comment and may be some of us will do it for fun.