Pylons Quickie: Mako Output

May 24, 2009 § Leave a comment

By default Mako HTML escapes all output.

To NOT have this behavior, change the setting of TemplateLookup in



Pylons Quickie: I want to use distance_of_time_in_words

May 17, 2009 § Leave a comment

distance_of_time_in_words is a useful function that converts boring looking datetime into something more attractive (and SEO optimized) like: 30 seconds ago.

Pylons gain this functionality via WebHelper which blatantly inspired by Rails.

But, out of the box, this functionality does not exists in my templates. To enable it, I need to add this line in

from import distance_of_time_in_words


WebHelpers Documentation

SqlAlchemy Quickie: How to use Distinct

May 15, 2009 § Leave a comment

distinct() method is accessible from Query object. The documentation is kind of obscure, so hopefully this post is helpful for others.


def get_all_category(cls):
return meta.Session.query(cls.category).distinct().all()


SqlAlchemy 04 Documentation about Query object

Pylons Cheat Sheet

May 13, 2009 § Leave a comment

SqlAlchemy in Three Minutes

May 10, 2009 § Leave a comment

The documentations of SqlAlchemy gets better in every version, but I can never remember the steps of creating Engine, Index, and Session.

So, I created 3 minutes tutorial on how to define the ORM class using declaration_base(), build that table, populates, and fetch.

See code here.

Python: Object to JSON

April 27, 2009 § Leave a comment

I want to store python object to JSON. Including a complex one (not just object that contains simple attributes).

Apparently, John Paulett has a need for that too. Here’s his code. The best part is: It uses CJSON! Bingo.

Python: using Memcache Client

April 23, 2009 § Leave a comment

For some reason, it’s always hard to find example on how to create memcache client object using Python.

This time, I will remember:

import memcache
memc = memcache.Client([''])

Where Am I?

You are currently browsing the python category at RAPD.