[Dev] mapping python back to the repository
Morgen Sagen
morgen at osafoundation.org
Tue Feb 15 10:32:23 PST 2005
On Feb 15, 2005, at 10:09 AM, Alec Flett wrote:
> Right now, we have a way of mapping a repository kind back to a
> python class - you just say <classes ...>*python class*</classes>
>
> The problem I'm running into now is that I want to create an instance
> of a python class and an entry in the repository, but I'm not really
> sure what the proper way is. Specifically, I want to create an
> ItemCollection, but when I say
>
> c = ItemCollection()
>
> I'm finding that the repository work doesn't get done - the
> attributes on the object don't get hooked up right, etc. I guess this
> makes sense though - how would it know which Kind to map the class to?
Any class that is a subclass of ContentModel.ChandlerItem knows what
its kind is because the class is supposed to have myKindPath attribute
set. ItemCollection is such a class, but you need to pass in at least
a view or a parent to the constructor.
c = ItemCollection(view=someView)
...will create an ItemCollection under //userdata.
After I implemented this feature (the logic lives in ChandlerItem),
Andi proposed (and implemented, I believe) support for equivalent
functionality within the data model itself, but I have yet to migrate
our content model to it.
~morgen
More information about the Dev
mailing list