Python Weblog Engine

October 29, 2008 § Leave a comment

Yes, my blog is WordPress service, which is PHP shop. But soon I will have a need to install a blog engine on my own. I would rather have the engine written in Python.

The thing is, there are only a few of them out on the internet:

One of them is PyBloxsom. Such a difficult name to remember. It is file based, a bit different than typical setup. It runs as CGI application or WSGI application or maybe mod_python.

Another one is Django Blog Engine, using SQLite and Django framework. Seems reasonable…

On the other side of my brain, I’d rather have an even simpler blog engine on top of cherrypy and mysql.

So, I up for 2 choices write my own, or Django Blog Engine since PyBloxsom is a bit too funky. If readers know a simple blog engine written on top of cherrypy and mysql, please tell me because I’m not looking forward to writing a blog engine.


SQLObject: Creating table dynamically

October 25, 2008 § Leave a comment

I’ve been using SQLObject for a while now, and I’m 60/40 with it.

I am mostly happy of SQLObject because:

  • The documentation is easy to read.
  • Getting up to speed is ridiculously easy, in less than 5 minutes I have a ‘user’ MySQL table wrapped with class User.
  • The generated SQL is efficient, for all my needs.
  • The returned ResultSet can be sliced, that’s nice. 

Why I’m not happy with it:

  • The invisible ‘id‘ column, that always get created for every new table. I have multiple needs for ORM to just create the table as-is, explicitly (Like how SQLALchemy does).

Why I haven’t switched to SQLAlchemy:

  • I have, but not for all model classes.
  • My noobiness limits me on what I can do with SQLAlchemy. For example, I haven’t figure out how to add Column object to existing Table object (that was created dynamically).  

That being said, SQLObject is very useful if you want to create MySQL table dynamically. You can achieve this by using meta-programming.


def create_or_get_dynamic_mysql_table(name):
      # SQLObject cache all classes that already defined,
      # If 'name' already defined, just get it using findClass()
      dynamic_table_classname = findClass(name)
      # Create new 'name' class
      # If you see the 2nd param of classobj, 'name' class extends SQLObject class
      dynamic_table_classname = classobj( name, (sqlobject.SQLObject,), {} )

   return dynamic_table_classname

# Then Call the createTable method
table_class = create_or_get_dynamic_mysql_table('awesome')


Nose: TDD in Python

October 19, 2008 § 1 Comment

Test Driven Development is awesome. So awesome, you cannot NOT use this methodology.

Here’s why I think TDD is awesome:

  • When implementing a function, and then create its unit test immediately, I have strong confident that my function works because unit test passed.
  • The same thing happen when creating inheritance structure, I know exactly what instance contains which property because unit test passed.
  • When I have my stupid moment, I can confidently refactor ALL of the existing codes, because unit test will correct me if I missed something.

That being said, for Python, there’s Nose.

It’s a unit testing framework that doesn’t get in the way. It gathers unit tests based on certain naming conventions. Any functions or classes that match the following ((?:^|[b_.-])[Tt]est) will be run as unit test. It’s that simple.

Installing nose is as simple as installing any other python module. Do: easy_install nose

With the right unit testing framework, you can put together unit tests quickly. So, there’s no reason not to do it.


Unfuddle: Hosted SVN and Git Solution, Redmine, and Trac

October 14, 2008 § 6 Comments

I have a need for a simple hosted SVN solution for my toy project. I don’t want to make my own bug tracking system, and if I’m using other’s, I want it free (as in beer).

Thus, number one obvious choice is Trac. But it doesn’t really support more than 1 project.

Next is Redmine, an open source bug tracker and project management tool written in Ruby on Rails. Rails is not my cup of tea, but definitely easier to install than Trac. Redmine is pretty awesome, it has these features:

  • Multiple projects support
  • Flexible role based access control.
  • Flexible issue tracking system
  • News, documents & files management
  • Feeds & email notifications.
  • Per project wiki
  • Per project forums
  • Simple time tracking functionality
  • Custom fields for issues, projects and users
  • SCM integration (SVN, CVS, Git, Mercurial, Bazaar and Darcs)
  • Multiple LDAP authentication support
  • User self-registration support
  • Multilanguage support
  • Multiple databases support
Basically everything I need and many things I want. Sounds good and I installed it immediately.

Then, I came across this blog and discover Unfuddle. Unfuddle has all the benefits of Redmine and it is hosted. Furthermore:

  • Unfuddle already support SVN and Git.
  • Unfuddle free account is private, limited to just 2 developers, and max size 100MB. Perfect for my little project.

Eucalyptus: Open Source EC2

October 12, 2008 § Leave a comment

EUCALYPTUS stands for Elastic Utility Computing Architecture for Linking Your Programs To Useful Systems. 

In short, it’s the open source response of Amazon EC2 instance.

Eucalyptus is developed in the MAYHEM Lab within the Computer Science Department at the University of California, Santa Barbara. It implements FreeBSD style licensing.


Eucalyptus Main Page

Flex (not Adobe’s)

October 8, 2008 § Leave a comment

Disclaimer: This post is intended as a reminder for myself.


I need to tokenize (and parse) a language that have very simple grammar. That job is currently done using Python beautifully. But at some point, a C or C++ implementation maybe better (for obvious performance reason). 

What open source tool can I use? This need must have already been addressed long time ago.

I’m quite sure that the parser will have be home-grown. Meanwhile, Flex should be able to fulfill the tokenizer need.

Side Note:

  • Unsurprisingly, AWS SimpleDB syntax follows Backus-Naur form. I’m glad to finally know the formal name for this kind of grammar.

Some word definitions:

  • Lexical Analyzer – This is what common programmers would refer to as tokenizer. It’s input will be transformed into list (or tree) of tokens.
  • Parser – Takes in list (or tree) of tokens, then generates output. 


  • Flex – It’s a general purpose tokenizer, written in C.
  • Backus-Naur form – It’s a common grammar for programming languages.

References that have nothing to do with what I need:

  • JS/CC – Javascript parser written in Javascript
  • Quex – Tokenize string -> C++ lexical analyzers.

Bazaar: Version Control System

October 5, 2008 § Leave a comment

There are numerous distributed Version Control systems nowadays. There are Git, Mercurial, and Bazaar.

From first impression, I like Bazaar, here’s why:

  • It’s written in Python.
  • Furthermore, because it is written in Python, installation is a breeze: `easy_install bzr`
  • It has similar terminology to SVN. That means lower learning curve.
  • Bazaar has really good storage compression. See the comparisons that others have done below.

Bit of History:

Martin Pool started Bazaar when he was just hired by Canonical, ltd.


List of Projects using Bazaar[link]:

Below is not the complete list, see link above for more.

  • Bugzilla@Mozilla
  • GNU Mailman
  • MySQL
  • Squid – Caching Proxy project. It caches frequently visited web pages.

Others have attempted to compare Bazaar vs Git:



Where Am I?

You are currently viewing the archives for October, 2008 at RAPD.