Category Archives: Python

The perfect crop using PIL

I’ve always wanted to display good looking thumbnail pictures with each thumbnail having the same width and height (dimension). Using some calculations, cropping and resizing, I was able to create thumbnails cropped from center and scaled down to my width/height … Continue reading

Posted in Python | Tagged , , , , | 4 Comments

Boto – set content type and other headers upon upload

I always though that you can set the Amason S3’s response headers when using boto’s generate_url API. I was wrong. We can only set those things upon upload, perhaps the docs I am reading is outdated or I’m reading it … Continue reading

Posted in Python | Tagged , , , , | Leave a comment

Django – creating timezone aware datetime objects

After developing some codes for few hours, when I finally tried to test it, I am greeted with this timezone related error. After reviewing Django docs, it is clearly stated that it has full support for timezones and that it … Continue reading

Posted in Python | Tagged , , | Leave a comment

Django – verbose console logging in development server

The moment you set DEBUG = False in development server for Django, you will be clueless about what’s going on for every error your application may encounter. If you just want to show verbose error messages on the console (when … Continue reading

Posted in Python | Tagged , , , | 1 Comment

Sending Email in Google AppEngine for Python

Google AppEngine provides an API services for sending emails. I’ve setup a contact form to use such feature. I used a couple of validations, security tokens via custom sessions and the mail service to implement this feature in my site. … Continue reading

Posted in Python | Tagged , , , , | Leave a comment

Sessions on Google AppEngine for Python

In PHP world, creating sessions is so easy when using built ins. To customize, secure and make it fast, you have to create a whole new architecture to do that. In my experience with Google AppEngine, your only choice is … Continue reading

Posted in Python | Tagged , , , , , | Leave a comment

Validatish – a Python validation library

I was looking for a good validation library in Python and then I found validatish. As usual, it uses exceptions every time it encounters an error. I like its simplicity and ease of use. Below is how I used it … Continue reading

Posted in Python | Tagged , , , | Leave a comment

Trival – Passing list or dictionary as argument in Python

So you got a cool API with lots of magic? Then suddenly you wanted something like dynamically passing parameters when needed. A common pattern wherein you call an arbitrary method with arbitrary arguments. I know this is trival but if … Continue reading

Posted in Python | Tagged , , | Leave a comment

Redirecting URLs in Google AppEngine for Python

A month ago, I decided to re-structure my URLs but have no plan on handling redirects for indexed URLs by search engines. I’ve been receiving several 404 errors on my logs and finally decided to do a 301 redirect to … Continue reading

Posted in Python | Tagged , , , , | Leave a comment

Re-writing lysender.com – a Google AppEngine Python adventure

My portfolio site is definitely a very small site with almost no visitors at all. Written in Kohana and was previously hosted in Pagodabox, I’ve migrated it to Google AppEngine for Python 2.7. It was fun and frustrating at the … Continue reading

Posted in Python | Tagged , , , , , , | Leave a comment