[Dev] FYI: creating items from Python code

Phillip J. Eby pje at telecommunity.com
Tue Aug 9 16:12:54 PDT 2005


A couple of weeks ago, I added a new feature to schema.Item subclasses that 
allows you to create or update existing items in a parcel, and an 
'installParcel()' hook that allows you to create a parcel's items from 
Python code.  It turns out that I forgot to announce these feature here, 
although a number of people heard about it via IRC, the commit message, and 
other places, and have already put it into use.  For example, Morgen 
created the osaf.app package using this feature, Ted has used it in the 
flickr parcel, Bryan Stearns refactored the attribute editors parcel to use 
it, and I converted the certstore.data package to use it to load 
certificates directly from a .pem file instead of having to convert it to a 
parcel.xml.

For more information, you can look at 'application/schema_api.txt', which 
has a section called "Parcel-Loading Tools" beginning around line 577.  You 
can also look at the __init__.py of the parcels I mentioned above (except 
for certstore.data, which is in certstore/data.py) for examples of how to 
define an 'installParcel()' routine and how to use the 'update()' method to 
create items.

So far, I've gotten pretty positive feedback about the convenience of 
creating items with Python as compared to parcel.xml, and it's several 
times faster compared to loading the equivalent items in parcel.xml 
files.  So, there has been some discussion about getting rid of parcel.xml 
altogether, and just using Python as our format for setting up parcel 
items.  I believe Katie will be posting a more official proposal/call for 
votes on this issue shortly, but she wanted to make sure everybody got a 
chance to look at how item creation in Python looks/works before forming an 
opinion, and I just realized I had never sent a dev list posting about the 
new features.  (For some reason I thought I'd also sent my commit message 
(http://viewcvs.osafoundation.org/chandler/?rev=6169&view=rev) to the dev 
list, but of course it only went to the commits list.)



More information about the Dev mailing list