TurboGear Demo for Mac OS X AddressBook

October 26, 2005 § Leave a comment

To give equal time to my Python friends, here is
the source code
for a demo TurboGears web application that publishes a Mac
OS X Address Book. In addition to TurboGears, this
requires pre-installing PyObjc. There is also an Automator action demonstrating XOXO
extraction
, which requires Tiger.



Click [Read More] for information about how
it was done, and what I learned.

First of all, I will confess I was too harsh on CherryPy. It does indeed handle REST-friendly
urls just fine. However, it did confirm my sense that its syntax was
heavier-weight than Rails. Not enormously, but enough that I noticed, which
adds some friction to my development
process.

That said, this project was
easier for me than it would’ve been in Rails since:

a. I already grok Python, and I had to write some
real code this time
b. PyObjc is somewhat more mature (or at least
better-known) than RubyCocoa
c. The supporting tools (i.e., xoxo.py) were already in Python
d. I wasn’t doing CRUD, so I didn’t miss the lack
of scaffolding

However, the main point
was to establish that REST-Enabled XHTML can be done in Python as
easily as Ruby, and to that extent it
succeeded.

Roughly speaking, what I did
was:

1. Follow the TurboGears tutorial, but use ABAddressBook instead of a database
2. Create a Python class mapping ABPerson into a vcard-keyed
dictionary
3. Write Kid html templates to generate the vcard-encoded
data structures
4. Generate a nice AddressBook-like CSS
stylesheet (which I had to hunt a bit to place in the correct
place)
5. General urls for use with AHAH (aka JAH/AJAX)
6. Embed xoxo-plist.py in an Automator Action which
searches for values within the specified
key

The sample code referenced herein is licensed under
Apache 2.0, unless otherwise
specified.


Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

What’s this?

You are currently reading TurboGear Demo for Mac OS X AddressBook at iHack, therefore iBlog.

meta

%d bloggers like this: