Yesterday I added a new feature that lets you conveniently access items contained in parcels without needing to directly use repository paths, UUIDs, or other mechanisms. It works similarly to an "xmlns" declaration in parcel.xml, except you use it in Python code.

I originally wrote it to experiment with ways to speed up the parcel loader, but from discussion during some of today's meetings I gather that other people are interested in knowing about it.

The feature is ``schema.ns``, and you can use it something like this:

    from application import schema

    ...

    # code that needs access to items in the "osaf.current" parcel
    current = schema.ns('osaf.current', repoView)
    current_contact = current.Contact.item

Basically, it makes the named parcel accessible via dotted attribute access, giving you either the contents of the module (classes, methods, etc.), or the contents of the parcel (i.e. items). It is considerably faster than access via absolute repository paths such as "//parcels/osaf/current/Contact".

In any case, we want to stop using paths as a primary access method, so that we can get rid of kludges like __parcel__, and so that developers only have to learn and remember one kind of "address" for parcel items. Over time, we'll hopefully be able to remove all parcel path dependencies from the Chandler code base, which will also be helpful in flattening the currently very deep package hierarchy.

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

Open Source Applications Foundation "Dev" mailing list
http://lists.osafoundation.org/mailman/listinfo/dev

Reply via email to