Leo + Python: the ultimate scripting tool #7

Edward K. Ream edreamleo at charter.net
Sat Nov 8 17:23:52 CET 2003


Reasons why Leo and Python work so well together:

7. Leo outlines are the ultimate filing cabinet.

One more feature new in Leo 4.0 greatly expands the generality and power of
Leo's outlines combined with Python.  Plugins may now attach arbitrary data
to any node of a Leo outline.  This is done merely by "injecting" an ivar
called  unknownAttributes ivar into Leo's fundamental vnode or tnode objects
(or adding items to the unknownAttributes dict if it already exists).  The
unknownAttributes ivar should be a Python dictionary whose keys are xml
attribute names and whose values are the values of those attributes.

When writing a file, Leo will write "foreign" attributes in the <v> or <t>
xml elements of Leo's .leo file if the corresponding vnode or tnode contains
this unknownAttributes ivar.  Similarly, Leo will create an
unknownAttributes ivar for a vnode or tnode if the corresponding <v> or <t>
element contains an attribute not normally used by Leo.  Leo performs the
standard xml escapes when writing unknown attributes, so plugins can put
_anything_ in the unknownAttributes dictionary.  In particular, plugins may
put xml in v.unknownAttributes or t.unknownAttributes.

This means, for example, that plugins may add anything that can be
represented by xml (and that is _everything_) in any node of a Leo outline.
In effect, Leo's file format is now completely extensible.  BTW, plugins can
override any aspect of Leo's behavior, so not only can Leo passively accept
the data in "extended" .leo files, but plugins can extend Leo to _use_ this
data!

Edward
--------------------------------------------------------------------
Edward K. Ream   email:  edreamleo at charter.net
Leo: Literate Editor with Outlines
Leo: http://webpages.charter.net/edreamleo/front.html
--------------------------------------------------------------------






More information about the Python-list mailing list