At 09:38 PM 6/19/2007 -0400, Phil Jones wrote:
Hi,

I'm Phil Jones, Google Summer of Code student, and I am working on restructuring the Chandler quick entry code to be able to more easily add commands and functionality.

There are a couple of different approaches that JeffreyH and I have been discussing, and I am just looking for some feedback.

Also, if anyone has any good reasons why to use one approach over the other, please share your thoughts.

Approach 1:
Restructure the quick entry commands code into a parcel and persistently install into a known location in Chandler. Extending would create a persistent command parcel and hook into this quick entry code. Quick entry would iterate through the commands to determine what commands are available.

Have a look at the osaf.startup module for an example of how this can be done, using a custom Item type:

http://chandler.osafoundation.org/docs/0.7/running-code-at-startup.html

In the case of osaf.startup, there aren't any keys to the extensions (Startup objects), but of course there could be.


Approach 2:
Use a standard dictionary that is in a known location in Chandler to add new keys with a callback function. Each of these additions can be performed in a parcel, and work similar to the first approach but are not stored using the same persistent mechanism.

If all you need is an ASCII key, and that key doesn't need to contain any '=' signs, you can also use entry points:

http://peak.telecommunity.com/DevCenter/setuptools#extensible-applications-and-frameworks
http://peak.telecommunity.com/DevCenter/PkgResources#entry-points

This would work by adding entry_points to a plugin's setup.py:

    setup(
        ...
entry_points = {'chandler.quick_entry': ['xyz = some.module:some_callback']}
    )

An individual plugin (or the main Chandler setup.py) can list as many keys as it wants to support.

Then, the lookup code can simply use something like:

    for ep in pkg_resources.iter_entry_points('chandler.quick_entry', key):
        callback = ep.load()
        # do something with callback here
        break  # only call the first callback for this key
    else:
        # no callback found


I would recommend that you either use this approach, or the approach of defining a specialized Item class (ala osaf.startup.Startup), rather than creating a special dictionary.

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

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

Reply via email to