[Dev] mapping python back to the repository
Morgen Sagen
morgen at osafoundation.org
Tue Feb 15 11:13:30 PST 2005
On Feb 15, 2005, at 10:43 AM, Alec Flett wrote:
> Andi Vajda wrote:
>
> When creating an item instance (or a subclass thereof) you need to
> pass three things:
> - a name, which is optional and is useful for debugging
> - a parent, which determines where the item lives in the repository
> - a kind, which is optional. A kindless item is limited in what it
> can do
> but is useful as a container of other items, its children (see
> above).
>
> kind.newItem() seems to work for me, but I'm curious in exploring the
> python-constructor method further, if only to understand how it works:
>
> I've had no luck passing in a view parameter, I still don't get
> default attribute values from the Kind.. but your last bullet makes me
> think that I need to pass in a kind manually. You mention that its
> optional, but if I don't pass one in, what Kind gets hooked up?
>
> Alec
> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
>
> Open Source Applications Foundation "Dev" mailing list
> http://lists.osafoundation.org/mailman/listinfo/dev
>
For example, try this in PyCrust (Test -> Show Pycrust debugger):
>>> import wx
>>> view = wx.GetApp().repository.view
>>> import osaf.contentmodel.ItemCollection
>>> ic = osaf.contentmodel.ItemCollection.ItemCollection(view=view)
Since the ItemCollection class (in
parcels/osaf/contentmodel/ItemCollection.py) has its myKindPath
attribute set to "//parcels/osaf/contentmodel/ItemCollection" and is a
subclass of ChandlerItem, the constructor determines the right kind to
use. Its initial values are all set as well.
More information about the Dev
mailing list