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.
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.
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
real code this time
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
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
dictionary
3. Write Kid html templates to generate the vcard-encoded
data structures
data structures
4. Generate a nice AddressBook-like CSS
stylesheet (which I had to hunt a bit to place in the correct
place)
stylesheet (which I had to hunt a bit to place in the correct
place)
6. Embed xoxo-plist.py in an Automator Action which
searches for values within the specified
key
searches for values within the specified
key
The sample code referenced herein is licensed under
Apache 2.0, unless otherwise
specified.
Leave a Reply