Please note: this project is inactive since early 2006

5.3 Miscellaneous developer's hints

How to dynamically identify a nested EditingContext?
Simply invoke parentObjectStore() on it ; if the result is another EditingContext, it is nested. Otherwise it is a regular EditingContext.
>>> from Modeling.EditingContext import EditingContext
>>> parent_ec=EditingContext()
>>> ec=EditingContext(parent_ec)
>>> ec.parentObjectStore().__class__==EditingContext
>>> parent_ec.parentObjectStore().__class__==EditingContext

How to determine whether a given EditingContext is a (grand-)child of an other one?

Use the method isaChildOf, which examines the parent/children hierarchy and answers appropriately:

>>> from Modeling.EditingContext import EditingContext
>>> grand_parent_ec=EditingContext()
>>> parent_ec=EditingContext(grand_parent_ec)
>>> ec=EditingContext(parent_ec)
>>> ec.isaChildOf(parent_ec)
>>> ec.isaChildOf(grand_parent_ec)

Is it possible to get the children of a given EditingContext?


Comments are welcome: Sebastien Bigaret / Modeling Home Page
Hosted Logo