[PEAK] Using peak.model as an observer subject
    Doug Quale 
    quale1 at charter.net
       
    Thu Sep  2 10:57:02 EDT 2004
    
    
  
"Phillip J. Eby" <pje at telecommunity.com> writes:
> At 11:06 PM 9/1/04 -0500, Doug Quale wrote:
> >OK, I hadn't considered the possibility that feature objects could be
> >shared by different objects.  How would that happen, and under what
> >circumstances would we want to do it?
> 
> They're *always* shared; they live in the class as descriptors, not in
> individual instances.
Thanks, I might understand it now.  I shouldn't say feature objects
because that isn't accurate.  Sometimes the feature descriptor classes
will be distinct.  I had only considered very simple cases:
    class myElement(model.Element):
         class xFeature(ObservableAttr):
             pass
         class yFeature(ObservableAttr):
             pass
I had never thought to try it, but it seems to work to share a feature
class like this:
    class xFeature(ObservableAttr):
        pass
    class ElementA(model.Element):
        xFeature = xFeature
    class ElementB(model.Element):
        xFeature = xFeature
In this case storing the event source in the feature will lose.  I
think that this might not be the use case you have in mind.  Instead,
looking at the bulletins example and in peak.metamodels, it seems that
it's more useful to share feature descriptor classes that are used for
a feature's referencedType.
    
    
More information about the PEAK
mailing list