Pylons: Testing Configuration

June 7, 2009 § Leave a comment

It’s nice that Pylons include nosetest and TestUnit as part of its testing framework.

Unfortunately, using those for unit testing inside Pylons is not trivial, not obvious, and inconvenient.

For examples:

  • I can only run nosetests on top-level directory because config is expecting ‘test.ini’ file. That’s inconvenient.
  • It is not obvious how build sqlalchemy’s engine inside tests/ Ideally, I can build the engine based on test.ini configurations.

To answer those questions, this is how my looks like:

The __init__ file solves various problems:

  • I can run nosetests anywhere inside project’s directory tree.
  • With simple convention, __init__ will look for test.ini file on top-level directory.
  • SqlAlchemy engine is built using configuration set in test.ini

I hope this snippet can help readers in getting up to speed in Pylons even quicker.


Yes! Syntax Highlighting for Mako in TextMate!

May 31, 2009 § 1 Comment

For the longest time I kept staring at ‘plain text mode’ while editing Mako templates. No Mas!

TextMate bundle for Mako template has existed.

To install:

  • cd ~/Library/Application\ Support/TextMate/Bundles/
  • svn co

After Reloading your bundle, syntax highlighting is available under HTML (Mako).


HTML Quickie: Long String Overflowing Your Div

May 25, 2009 § 6 Comments

Do you have that problem? I do.

EDIT(05/31/2009): Even better solutions:



General CSS solution:

overflow: scroll


The HTML solution:

use <wbr>. (But you have to figure out yourself where to put the tag)

The IE-specific CSS solution:

word-wrap: break-word

PHP solution:

wordwrap(‘your_very_long_string_here’, 15) // Break after 15 characters

Python solution:

import textwrap

textwrap.fill(‘your_very_long_string_here’, 15) # Break after 15 characters


The Male Programmer Privilege Checklist

May 25, 2009 § Leave a comment

Original Article here:

The article is thoroughly descriptive and I didn’t even realize some of them until I read it.

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

Laconica: Open Source Twitter

May 16, 2009 § Leave a comment

There are so many micro-blogging services nowadays. Sooner or later there will be an open source application for it.

And that application is called Laconica. It is written in PHP.

I haven’t try to install it yet, but it sounds fun.


The project’s Trac