Title: [commits] (vajda) [11434] - implemented 'afterChange' attribute aspect to replace onValueChanged()

Diff

Modified: trunk/chandler/Makefile (11433 => 11434)

--- trunk/chandler/Makefile	2006-08-17 10:14:54 UTC (rev 11433)
+++ trunk/chandler/Makefile	2006-08-17 10:28:52 UTC (rev 11434)
@@ -94,7 +94,7 @@
 # When a version changes, the ARCHIVES lists below needs to be updated.
 # these get installed into release or debug
 ARCHIVES = $(CHANDLERARCHIVES)/Launchers-$(SNAP)-0.8-$(BP)C.tar.gz \
-           $(CHANDLERARCHIVES)/chandlerdb-$(SNAP)-0.6-$(BP)35.tar.gz \
+           $(CHANDLERARCHIVES)/chandlerdb-$(SNAP)-0.6-$(BP)36.tar.gz \
            $(CHANDLERARCHIVES)/db-$(SNAP)-4.4.20-$(BP)5.tar.gz \
            $(CHANDLERARCHIVES)/python-$(SNAP)-2.4.3-$(BP)3.tar.gz \
            $(CHANDLERARCHIVES)/epydoc-$(SNAP)-2.1-$(BP)9.tar.gz \

Modified: trunk/chandler/application/schema.py (11433 => 11434)

--- trunk/chandler/application/schema.py	2006-08-17 10:14:54 UTC (rev 11433)
+++ trunk/chandler/application/schema.py	2006-08-17 10:28:52 UTC (rev 11434)
@@ -29,6 +29,7 @@
     'importString', 'parcel_for_module', 'TypeReference',
     'Enumeration', 'Cloud', 'Endpoint', 'addClouds', 'Struct',
     'assertResolved', 'Annotation', 'AnnotationItem',
+    'afterChange',
 ]
 
 all_aspects = Attribute.valueAspects + Attribute.refAspects + ('description',)
@@ -537,6 +538,20 @@
                 if ai not in kind.attributes:
                     kind.attributes.append(ai,name)
 
+        for attrName, names in cls.__dict__.get('__after_change__',{}).items():
+            attr = kind.getAttribute(attrName, True)
+            if attr is not None:
+                if hasattr(attr, 'afterChange'):
+                    afterChange = attr.afterChange
+                    for name in names:
+                        if name not in afterChange:
+                            afterChange.append(name)
+                else:
+                    attr.afterChange = names
+            else:
+                view.logger.warn("no attribute '%s' defined for kind for %s",
+                                 attrName, cls)
+
         def fixup():
             kind.itsParent = parcel_for_module(cls.__module__, view)
             kind.itsName = cls.__name__
@@ -1003,7 +1018,11 @@
     _update_info('addClouds','__kind_clouds__',clouds)
 
 
+def afterChange(**pairs):
+    """Update afterChange aspect on attributes"""
+    _update_info('afterChange', '__after_change__', pairs)
 
+
 def importString(name, globalDict=__main__.__dict__):
     """Import an item specified by a string
 

Modified: trunk/chandler/parcels/osaf/app/__init__.py (11433 => 11434)

--- trunk/chandler/parcels/osaf/app/__init__.py	2006-08-17 10:14:54 UTC (rev 11433)
+++ trunk/chandler/parcels/osaf/app/__init__.py	2006-08-17 10:28:52 UTC (rev 11434)
@@ -26,20 +26,22 @@
 import version
 
 class TZPrefs(Preferences):
-    showUI = schema.One(schema.Boolean, initialValue = False)
+    showUI = schema.One(schema.Boolean,
+                        initialValue = False,
+                        afterChange = ['onShowUIChanged'])
     
-    def onValueChanged(self, attrName):
-        if attrName == 'showUI':
-            from osaf.pim.calendar.TimeZone import TimeZoneInfo
+    def onShowUIChanged(self, attrName):
+
+        from osaf.pim.calendar.TimeZone import TimeZoneInfo
             
-            timeZoneInfo = TimeZoneInfo.get(self.itsView)
+        timeZoneInfo = TimeZoneInfo.get(self.itsView)
         
-            # Sync up the default timezone (i.e. the one used when
-            # creating new events).
-            if self.showUI:
-                timeZoneInfo.default = ICUtzinfo.default
-            else:
-                timeZoneInfo.default = ICUtzinfo.floating
+        # Sync up the default timezone (i.e. the one used when
+        # creating new events).
+        if self.showUI:
+            timeZoneInfo.default = ICUtzinfo.default
+        else:
+            timeZoneInfo.default = ICUtzinfo.floating
 
 
 

Modified: trunk/chandler/parcels/osaf/framework/scripting/script.py (11433 => 11434)

--- trunk/chandler/parcels/osaf/framework/scripting/script.py	2006-08-17 10:14:54 UTC (rev 11433)
+++ trunk/chandler/parcels/osaf/framework/scripting/script.py	2006-08-17 10:28:52 UTC (rev 11434)
@@ -52,6 +52,9 @@
     who = schema.One(redirectTo = 'creator')
     date = schema.One(redirectTo = 'lastRan')
 
+    # afterChange
+    schema.afterChange(body = ['onBodyChanged'])
+
     def __init__(self, itsName=None, itsParent=None, itsKind=None, itsView=None,
                  body=None, *args, **keys):
         defaultName = messages.UNTITLED
@@ -85,9 +88,8 @@
             self.body = newValue
             self._change_quietly = oldQuiet
 
-    def onValueChanged(self, name):
-        if name == 'body':
-            self.model_data_changed()
+    def onBodyChanged(self, name):
+        self.model_data_changed()
 
     def model_data_changed(self):
         if self.filePath and not getattr(self, '_change_quietly', False):

Modified: trunk/chandler/parcels/osaf/pim/calendar/Calendar.py (11433 => 11434)

--- trunk/chandler/parcels/osaf/pim/calendar/Calendar.py	2006-08-17 10:14:54 UTC (rev 11433)
+++ trunk/chandler/parcels/osaf/pim/calendar/Calendar.py	2006-08-17 10:28:52 UTC (rev 11434)
@@ -291,7 +291,7 @@
     @group Semi-Private Methods: addToCollection, changeNoModification,
     cleanRule, copyCollections, getEffectiveEndTime, getEffectiveStartTime,
     getEndTime, getFirstInRule, InitOutgoingAttributes, isBetween, isProxy,
-    moveCollections, moveRuleEndBefore, onValueChanged, removeFutureOccurrences,
+    moveCollections, moveRuleEndBefore, onEventChanged, removeFutureOccurrences,
     setEndTime, StampKind, updateRecurrenceEnd, __init__, removeFromCollection
 
     """
@@ -418,7 +418,7 @@
         schema.DateTimeTZ,
         defaultValue = None,
         doc="End time for recurrence, or None, kept up to date by "
-            "onValueChanged.  Note that this attribute is only meaningful "
+            "onEventChanged.  Note that this attribute is only meaningful "
             "on master events")
 
     schema.addClouds(
@@ -1354,13 +1354,26 @@
     changeNames = ('displayName', 'startTime', 'duration', 'location', 'body',
                    'lastModified', 'allDay')
 
-    def onValueChanged(self, name):
+    # KLUDGE: 
+    #   replace the following with the proper schema API syntax
+    #   and possible per-attribute refactoring
+
+    schema.afterChange(displayName=['onEventChanged'],
+                       startTime=['onEventChanged'],
+                       duration=['onEventChanged'],
+                       location=['onEventChanged'],
+                       body=['onEventChanged'],
+                       lastModified=['onEventChanged'],
+                       allDay=['onEventChanged'],
+                       rruleset=['onEventChanged'])
+
+    def onEventChanged(self, name):
         """
         Maintain coherence of the various recurring items associated with self
         after an attribute has been changed.
 
         """
-        # allow initialization code to avoid triggering onValueChanged
+        # allow initialization code to avoid triggering onEventChanged
         rruleset = name == 'rruleset'
         changeName = not rruleset and name in CalendarEventMixin.changeNames
 
@@ -1387,7 +1400,7 @@
         # changeThis won't work with stamping
         elif changeName:
             if DEBUG:
-                logger.debug("about to changeThis in onValueChanged(name=%s) for %s", name, str(self))
+                logger.debug("about to changeThis in onEventChanged(name=%s) for %s", name, str(self))
                 logger.debug("value is: %s", getattr(self, name))
             if name == 'duration' and self == self.getFirstInRule():
                 self.updateRecurrenceEnd()
@@ -1397,7 +1410,7 @@
         first = self.getFirstInRule()
         for event in first.occurrences:
             if event.isGenerated:
-                # don't let deletion result in spurious onValueChanged calls
+                # don't let deletion result in spurious onEventChanged calls
                 event._ignoreValueChanges = True
                 event.delete()
 

Modified: trunk/chandler/parcels/osaf/pim/calendar/Recurrence.py (11433 => 11434)

--- trunk/chandler/parcels/osaf/pim/calendar/Recurrence.py	2006-08-17 10:14:54 UTC (rev 11433)
+++ trunk/chandler/parcels/osaf/pim/calendar/Recurrence.py	2006-08-17 10:28:52 UTC (rev 11434)
@@ -210,6 +210,24 @@
                 "byyearday","byweekno", "byhour", "byminute", "bysecond",
                 "wkst", "byweekday", "freq")
 
+    # KLUDGE: 
+    #   replace the following with the proper schema API syntax
+    #   and possible per-attribute refactoring
+
+    schema.afterChange(interval = ['onRecurrenceChanged'],
+                       until = ['onRecurrenceChanged'],
+                       bysetpos = ['onRecurrenceChanged'],
+                       bymonth = ['onRecurrenceChanged'],
+                       bymonthday = ['onRecurrenceChanged'],
+                       byyearday = ['onRecurrenceChanged'],
+                       byweekno = ['onRecurrenceChanged'],
+                       byhour = ['onRecurrenceChanged'],
+                       byminute = ['onRecurrenceChanged'],
+                       bysecond = ['onRecurrenceChanged'],
+                       wkst = ['onRecurrenceChanged'],
+                       byweekday = ['onRecurrenceChanged'],
+                       freq = ['onRecurrenceChanged'])
+    
     # dateutil automatically sets these from dtstart, we don't want these
     # unless their length is greater than 1.
     interpretedNames = "byhour", "byminute", "bysecond"
@@ -383,12 +401,12 @@
         self.until = previous
         self.untilIsDate = False
 
-    def onValueChanged(self, name):
+    def onRecurrenceChanged(self, name):
         """If the rule changes, update any associated events."""
         if name in self.allNames:
             for ruletype in ('rruleFor', 'exruleFor'):
                 if self.hasLocalAttributeValue(ruletype):
-                    getattr(self, ruletype).onValueChanged('rrules')
+                    getattr(self, ruletype).onRuleSetChanged('rrules')
 
 
 class RecurrenceRuleSet(items.ContentItem):
@@ -645,7 +663,7 @@
         @type  end: C{datetime}
 
         """
-        #change the rule, onValueChanged will trigger cleanRule for master
+        #change the rule, onRuleSetChanged will trigger cleanRule for master
         for rule in getattr(self, 'rrules', []):
             if (not rule.hasLocalAttributeValue('until') or
                (rule.calculatedUntil() >= end)):
@@ -654,12 +672,16 @@
 
     RULENAMES = ('rrules', 'exrules', 'rdates', 'exdates')
 
-    def onValueChanged(self, name):
+    schema.afterChange(rrules = ['onRuleSetChanged'],
+                       exrules = ['onRuleSetChanged'],
+                       rdates = ['onRuleSetChanged'],
+                       exdates = ['onRuleSetChanged'])
+
+    def onRuleSetChanged(self, name):
         """If the RuleSet changes, update the associated event."""
-        if name in self.RULENAMES and not getattr(self, '_ignoreValueChanges', False):
+        if not getattr(self, '_ignoreValueChanges', False):
             if self.hasLocalAttributeValue('events'):
                 for event in self.events:
                     event.getFirstInRule().cleanRule()
                     # assume we have only one conceptual event per rrule
                     break
-

Modified: trunk/chandler/parcels/osaf/pim/calendar/TimeZone.py (11433 => 11434)

--- trunk/chandler/parcels/osaf/pim/calendar/TimeZone.py	2006-08-17 10:14:54 UTC (rev 11433)
+++ trunk/chandler/parcels/osaf/pim/calendar/TimeZone.py	2006-08-17 10:28:52 UTC (rev 11434)
@@ -29,6 +29,7 @@
 
     default = schema.One(
         schema.TimeZone,
+        afterChange = ['onDefaultChanged']
     )
 
     # List of well-known time zones (for populating drop-downs).
@@ -119,19 +120,18 @@
         if tz is not None and view is not None:
             PyICU.TimeZone.setDefault(tz.timezone)
 
-    def onValueChanged(self, name):
+    def onDefaultChanged(self, name):
         # Repository hook for attribute changes.
-        if name == 'default':
-            default = self.default
-            canonicalDefault = self.canonicalTimeZone(default)
-            # Make sure that PyICU's default timezone is synched with
-            # ours
-            if (canonicalDefault is not None and
-                canonicalDefault is not PyICU.ICUtzinfo.floating):
-                PyICU.ICUtzinfo.default = canonicalDefault
-            # This next if is required to avoid an infinite recursion!
-            if canonicalDefault is not default:
-                self.default = canonicalDefault
+        default = self.default
+        canonicalDefault = self.canonicalTimeZone(default)
+        # Make sure that PyICU's default timezone is synched with
+        # ours
+        if (canonicalDefault is not None and
+            canonicalDefault is not PyICU.ICUtzinfo.floating):
+            PyICU.ICUtzinfo.default = canonicalDefault
+        # This next if is required to avoid an infinite recursion!
+        if canonicalDefault is not default:
+            self.default = canonicalDefault
 
 def installParcel(parcel, oldVersion = None):
     # Get our parcel's namespace

Modified: trunk/chandler/projects/Chandler-PhotoPlugin/photos/Photos.py (11433 => 11434)

--- trunk/chandler/projects/Chandler-PhotoPlugin/photos/Photos.py	2006-08-17 10:14:54 UTC (rev 11433)
+++ trunk/chandler/projects/Chandler-PhotoPlugin/photos/Photos.py	2006-08-17 10:28:52 UTC (rev 11434)
@@ -35,7 +35,7 @@
     dateTaken = schema.One(schema.DateTime)
     file = schema.One(schema.Text)
     exif = schema.Mapping(schema.Text, initialValue={})
-    photoBody = schema.One(schema.Lob)
+    photoBody = schema.One(schema.Lob, afterChange=['onPhotoBodyChanged'])
 
     about = schema.One(redirectTo = 'displayName')
     date = schema.One(redirectTo = 'dateTaken')
@@ -104,9 +104,8 @@
             logger.debug("Couldn't process EXIF of Photo %s (%s)" % \
                 (self.itsPath, e))
 
-    def onValueChanged(self, attribute):
-        if attribute == "photoBody":
-            self.processEXIF()
+    def onPhotoBodyChanged(self, attribute):
+        self.processEXIF()
 
 
 class Photo(PhotoMixin, pim.Note):

Modified: trunk/chandler/repository/item/Indexed.py (11433 => 11434)

--- trunk/chandler/repository/item/Indexed.py	2006-08-17 10:14:54 UTC (rev 11433)
+++ trunk/chandler/repository/item/Indexed.py	2006-08-17 10:28:52 UTC (rev 11434)
@@ -234,6 +234,8 @@
 
             index.moveKeys(moves)
             for key in insertions:
+                if key in index:
+                    index.removeKey(key)
                 index.insertKey(key)
 
         self._setDirty(True)
@@ -643,7 +645,6 @@
                                                        count, repair)
                         else:
                             result = False
-
             finally:
                 self._indexes = indexes
                     

Modified: trunk/chandler/repository/item/Indexes.py (11433 => 11434)

--- trunk/chandler/repository/item/Indexes.py	2006-08-17 10:14:54 UTC (rev 11433)
+++ trunk/chandler/repository/item/Indexes.py	2006-08-17 10:28:52 UTC (rev 11434)
@@ -854,6 +854,13 @@
 
         uuid, attr, name = self._super
         index = getattr(self._valueMap._getView()[uuid], attr).getIndex(name)
+
+        # this should only happen during merge when the subindex is merged first
+        if k0 not in index:
+            index.insertKey(k0)
+        if k1 not in index:
+            index.insertKey(k1)
+
         skipList = index.skipList
 
         return skipList.position(k0) - skipList.position(k1)

Modified: trunk/chandler/repository/item/Item.py (11433 => 11434)

--- trunk/chandler/repository/item/Item.py	2006-08-17 10:14:54 UTC (rev 11433)
+++ trunk/chandler/repository/item/Item.py	2006-08-17 10:28:52 UTC (rev 11434)
@@ -37,7 +37,7 @@
     """
 
     def __init__(self, itsName=None, itsParent=None, itsKind=None,
-                 _uuid=None, _noMonitors=False, fireOnValueChanged=True,
+                 _uuid=None, _noMonitors=False, fireAfterChange=True,
                  **values):
         """
         Construct an Item.
@@ -95,7 +95,7 @@
                 self.setDirty(Item.NDIRTY | Item.NODIRTY)
 
             if values:
-                self._setInitialValues(values, fireOnValueChanged)
+                self._setInitialValues(values, fireAfterChange)
         finally:
             self._status &= ~Item.NODIRTY
 
@@ -104,16 +104,18 @@
                                        'add', 'collection', 'extent',
                                        self.itsUUID)
 
-    def _setInitialValues(self, values, fireOnValueChanged):
+    def _setInitialValues(self, values, fireAfterChange):
 
         for name, value in values.iteritems():
             setattr(self, name, value)
 
-        if fireOnValueChanged:
-             'onValueChanged', None)
-            if onValueChanged is not None:
+        if fireAfterChange:
+            kind = self.itsKind
+            if kind is not None:
                 for name in values.iterkeys():
-                    onValueChanged(name)
+                    attr = kind.getAttribute(name, True, self)
+                    if attr is not None:
+                        attr.c.invokeAfterChange(self, name)
 
     def __iter__(self):
         """
@@ -1357,7 +1359,7 @@
         return item
 
     def clone(self, name=None, parent=None,
-              exclude=(), fireOnValueChanged=True, **values):
+              exclude=(), fireAfterChange=True, **values):
 
         cls = type(self)
         item = cls.__new__(cls)
@@ -1378,7 +1380,7 @@
             item._references._clone(self._references, exclude)
 
             if values:
-                item._setInitialValues(values, fireOnValueChanged)
+                item._setInitialValues(values, fireAfterChange)
         finally:
             item._status &= ~Item.NODIRTY
         

Modified: trunk/chandler/repository/packs/schema/model/Alias.kind (11433 => 11434)

--- trunk/chandler/repository/packs/schema/model/Alias.kind	2006-08-17 10:14:54 UTC (rev 11433)
+++ trunk/chandler/repository/packs/schema/model/Alias.kind	2006-08-17 10:28:52 UTC (rev 11434)
@@ -10,6 +10,8 @@
     <ref name="attributes" otherName="kinds"
          cardinality="list" otherCard="list">
 
+      <ref alias="typeIndex" type="path">/Core/typeIndex</ref>
+
       <!-- 
          - plus local attributes below:
          -     types

Modified: trunk/chandler/repository/packs/schema/model/Attribute.kind (11433 => 11434)

--- trunk/chandler/repository/packs/schema/model/Attribute.kind	2006-08-17 10:14:54 UTC (rev 11433)
+++ trunk/chandler/repository/packs/schema/model/Attribute.kind	2006-08-17 10:28:52 UTC (rev 11434)
@@ -16,7 +16,7 @@
          - plus local attributes below:
          -     required, persisted, indexed, notify,
 	 -     cardinality, type,
-	 -     defaultValue, initialValue,
+	 -     defaultValue, initialValue, afterChange,
          -     inheritFrom, redirectTo, otherName,
 	 -     deletePolicy, copyPolicy, countPolicy,
          -     kinds, superAttribute, subAttributes,
@@ -50,6 +50,10 @@
 
     <attribute name="cardinality">single</attribute>
     <attribute name="defaultValue" type="bool">False</attribute>
+    <attribute name="afterChange" cardinality="list">
+      <value>_afterAspectChange</value>
+      <value>_afterRequiredChange</value>
+    </attribute>
   </item>
 
   <item withSchema="True">
@@ -68,6 +72,10 @@
 
     <attribute name="cardinality">single</attribute>
     <attribute name="defaultValue" type="bool">True</attribute>
+    <attribute name="afterChange" cardinality="list">
+      <value>_afterAspectChange</value>
+      <value>_afterPersistedChange</value>
+    </attribute>
   </item>
 
   <item withSchema="True">
@@ -86,6 +94,10 @@
 
     <attribute name="cardinality">single</attribute>
     <attribute name="defaultValue" type="bool">False</attribute>
+    <attribute name="afterChange" cardinality="list">
+      <value>_afterAspectChange</value>
+      <value>_afterIndexedChange</value>
+    </attribute>
   </item>
 
   <item withSchema="True">
@@ -122,6 +134,10 @@
 
     <attribute name="cardinality">single</attribute>
     <attribute name="defaultValue">single</attribute>
+    <attribute name="afterChange" cardinality="list">
+      <value>_afterAspectChange</value>
+      <value>_afterCardinalityChange</value>
+    </attribute>
   </item>
 
   <item withSchema="True">
@@ -137,6 +153,10 @@
 
     <attribute name="cardinality">single</attribute>
     <attribute name="otherName">typeFor</attribute>
+    <attribute name="afterChange" cardinality="list">
+      <value>_afterAspectChange</value>
+      <value>_afterTypeChange</value>
+    </attribute>
   </item>
 
   <item withSchema="True">
@@ -154,6 +174,10 @@
          type="path" otherCard="list">/Core/Anything</ref>
 
     <attribute name="cardinality">single</attribute>
+    <attribute name="afterChange" cardinality="list">
+      <value>_afterAspectChange</value>
+      <value>_afterDefaultValueChange</value>
+    </attribute>
   </item>
 
   <item withSchema="True">
@@ -174,6 +198,27 @@
   </item>
 
   <item withSchema="True">
+    <name>afterChange</name>
+    <kind type="path">//Schema/Core/Attribute</kind>
+    <class module="repository.schema.Attribute">Attribute</class>
+    <parent type="path">//Schema/Core/Attribute</parent>
+
+    <ref name="kinds" otherName="attributes"
+         cardinality="list" otherCard="list">
+      <ref type="path" otherAlias="afterChange">..</ref>
+    </ref>
+
+    <ref name="type" otherName="typeFor" 
+         type="path" otherCard="list">/Core/Importable</ref>
+
+    <attribute name="cardinality">list</attribute>
+    <attribute name="afterChange" cardinality="list">
+      <value>_afterAspectChange</value>
+      <value>_afterAfterChangeChange</value>
+    </attribute>
+  </item>
+
+  <item withSchema="True">
     <name>inheritFrom</name>
     <kind type="path">//Schema/Core/Attribute</kind>
     <class module="repository.schema.Attribute">Attribute</class>
@@ -188,6 +233,10 @@
          type="path" otherCard="list">/Core/Importable</ref>
 
     <attribute name="cardinality">single</attribute>
+    <attribute name="afterChange" cardinality="list">
+      <value>_afterAspectChange</value>
+      <value>_afterInheritFromChange</value>
+    </attribute>
   </item>
 
   <item withSchema="True">
@@ -205,6 +254,10 @@
          type="path" otherCard="list">/Core/Importable</ref>
 
     <attribute name="cardinality">single</attribute>
+    <attribute name="afterChange" cardinality="list">
+      <value>_afterAspectChange</value>
+      <value>_afterRedirectToChange</value>
+    </attribute>
   </item>
 
   <item withSchema="True">
@@ -222,6 +275,10 @@
          type="path" otherCard="list">/Core/Importable</ref>
 
     <attribute name="cardinality">single</attribute>
+    <attribute name="afterChange" cardinality="list">
+      <value>_afterAspectChange</value>
+      <value>_afterOtherNameChange</value>
+    </attribute>
   </item>
 
   <item withSchema="True">

Modified: trunk/chandler/repository/packs/schema/model/Kind.kind (11433 => 11434)

--- trunk/chandler/repository/packs/schema/model/Kind.kind	2006-08-17 10:14:54 UTC (rev 11433)
+++ trunk/chandler/repository/packs/schema/model/Kind.kind	2006-08-17 10:28:52 UTC (rev 11434)
@@ -77,6 +77,9 @@
     <attribute name="cardinality">list</attribute>
     <attribute name="otherName">subKinds</attribute>
     <attribute name="initialValue" type="list"></attribute>
+    <attribute name="afterChange" cardinality="list">
+      <value>_afterSchemaChange</value>
+    </attribute>
   </item>
 
   <item withSchema="True">
@@ -107,6 +110,9 @@
 
     <attribute name="cardinality">list</attribute>
     <attribute name="otherName">kinds</attribute>
+    <attribute name="afterChange" cardinality="list">
+      <value>_afterSchemaChange</value>
+    </attribute>
   </item>
 
   <item withSchema="True">

Modified: trunk/chandler/repository/packs/schema/model/Type.kind (11433 => 11434)

--- trunk/chandler/repository/packs/schema/model/Type.kind	2006-08-17 10:14:54 UTC (rev 11433)
+++ trunk/chandler/repository/packs/schema/model/Type.kind	2006-08-17 10:28:52 UTC (rev 11434)
@@ -5,7 +5,7 @@
   <item withSchema="True">
     <name>TypeKind</name>
     <kind type="path">//Schema/Core/Kind</kind>
-    <class module="repository.schema.Types">Kind</class>
+    <class module="repository.schema.Kind">Kind</class>
 
     <ref name="attributes" otherName="kinds" cardinality="list" 
          otherCard="list">
@@ -49,9 +49,11 @@
     <ref name="attributes" otherName="kinds" cardinality="list" 
          otherCard="list">
 
+      <ref alias="typeIndex" type="path">/Core/typeIndex</ref>
+
       <!-- 
          - plus local attributes below:
-         -     implementationTypes, typeIndex
+         -     implementationTypes
         -->
     </ref>
 
@@ -82,19 +84,4 @@
     <attribute name="cardinality">dict</attribute>
   </item>
 
-  <item withSchema="True">
-    <name>typeIndex</name>
-    <kind type="path">//Schema/Core/Attribute</kind>
-    <class module="repository.schema.Attribute">Attribute</class>
-    <parent type="path">//Schema/Core/Type</parent>
-
-    <ref name="kinds" otherName="attributes"
-         cardinality="list" otherCard="list">
-      <ref type="path" otherAlias="typeIndex">..</ref>
-    </ref>
-
-    <attribute name="otherName">types</attribute>
-    <attribute name="cardinality">single</attribute>
-  </item>
-
 </items>

Modified: trunk/chandler/repository/packs/schema/model/items/Monitors.item (11433 => 11434)

--- trunk/chandler/repository/packs/schema/model/items/Monitors.item	2006-08-17 10:14:54 UTC (rev 11433)
+++ trunk/chandler/repository/packs/schema/model/items/Monitors.item	2006-08-17 10:28:52 UTC (rev 11434)
@@ -7,30 +7,4 @@
     <kind type="path">//Schema/Core/Monitors</kind>
   </item>
 
-  <item>
-    <kind type="path">//Schema/Core/Monitor</kind>
-    <class module="repository.schema.Kind">SchemaMonitor</class>
-
-    <ref name="dispatcher" type="path">../Monitors</ref>
-    <ref name="item" type="path">.</ref>
-    <attribute name="attribute">attributes</attribute>
-    <attribute name="op">set</attribute>
-    <attribute name="method">schemaChange</attribute>
-    <attribute name="args"></attribute>
-    <attribute name="kwds"></attribute>
-  </item>
-
-  <item>
-    <kind type="path">//Schema/Core/Monitor</kind>
-    <class module="repository.schema.Kind">SchemaMonitor</class>
-
-    <ref name="dispatcher" type="path">../Monitors</ref>
-    <ref name="item" type="path">.</ref>
-    <attribute name="method">schemaChange</attribute>
-    <attribute name="op">set</attribute>
-    <attribute name="attribute">superKinds</attribute>
-    <attribute name="args"></attribute>
-    <attribute name="kwds"></attribute>
-  </item>
-
 </items>

Added: trunk/chandler/repository/packs/schema/model/typeIndex.attr (11433 => 11434)

--- trunk/chandler/repository/packs/schema/model/typeIndex.attr	2006-08-17 10:14:54 UTC (rev 11433)
+++ trunk/chandler/repository/packs/schema/model/typeIndex.attr	2006-08-17 10:28:52 UTC (rev 11434)
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="iso-8859-1"?>
+
+<item withSchema="True">
+  <name>typeIndex</name>
+  <kind type="path">//Schema/Core/Attribute</kind>
+  <class module="repository.schema.Attribute">Attribute</class>
+
+  <attribute name="otherName">types</attribute>
+  <attribute name="cardinality">single</attribute>
+</item>

Modified: trunk/chandler/repository/persistence/RepositoryView.py (11433 => 11434)

--- trunk/chandler/repository/persistence/RepositoryView.py	2006-08-17 10:14:54 UTC (rev 11433)
+++ trunk/chandler/repository/persistence/RepositoryView.py	2006-08-17 10:28:52 UTC (rev 11434)
@@ -60,8 +60,9 @@
     # 0.6.6: added support for MethodFilteredSet
     # 0.6.7: watchers reworked to use RefDict
     # 0.6.8: removed support for persistent collection queue subscriptions
+    # 0.6.9: added 'afterChange' attribute aspect
     
-    CORE_SCHEMA_VERSION = 0x00060800
+    CORE_SCHEMA_VERSION = 0x00060900
 
     def __init__(self, repository, name, version):
         """

Modified: trunk/chandler/repository/schema/Attribute.py (11433 => 11434)

--- trunk/chandler/repository/schema/Attribute.py	2006-08-17 10:14:54 UTC (rev 11433)
+++ trunk/chandler/repository/schema/Attribute.py	2006-08-17 10:28:52 UTC (rev 11434)
@@ -145,47 +145,54 @@
         self.schemaHash = hash = self._hashItem()
         return hash
 
-    def onValueChanged(self, name):
+    def _afterAspectChange(self, name):
 
-        if name in Attribute.valueAspects or name in Attribute.refAspects:
-            values = self._values
+        if 'schemaHash' in self._values:
+            del self.schemaHash
+            if 'kinds' in self._references:
+                for kind in self.kinds:
+                    kind._afterAttributeHashChange()
 
-            if 'schemaHash' in values:
-                del self.schemaHash
-                if 'kinds' in self._references:
-                    for kind in self.kinds:
-                        kind.onValueChanged('attributeHash')
+    def _afterCardinalityChange(self, name):
 
-            c = getattr(self, 'c', None)
-            if c is not None:
+        self.c.cardinality = self._values
+        
+    def _afterPersistedChange(self, name):
 
-                if name == 'cardinality':
-                    c.cardinality = values
+        self.c.persisted = self._values.get('persisted', True)
 
-                elif name == 'persisted':
-                    c.persisted = values.get('persisted', True)
+    def _afterRequiredChange(self, name):
 
-                elif name == 'required':
-                    c.required = values.get('required', False)
+        self.c.required = self._values.get('required', False)
 
-                elif name == 'indexed':
-                    c.indexed = values.get('indexed', False)
+    def _afterIndexedChange(self, name):
 
-                elif name == 'inheritFrom':
-                    c.noInherit = (values, 'inheritFrom', 'redirectTo')
+        self.c.indexed = self._values.get('indexed', False)
 
-                elif name == 'defaultValue':
-                    c.defaultValue = values
+    def _afterInheritFromChange(self, name):
 
-                elif name == 'redirectTo':
-                    c.redirectTo = (values, 'redirectTo', 'inheritFrom')
+        self.c.noInherit = (self._values, 'inheritFrom', 'redirectTo')
 
-                elif name == 'otherName':
-                    c.otherName = values
+    def _afterDefaultValueChange(self, name):
 
-                elif name == 'type':
-                    c.typeID = self._references
+        self.c.defaultValue = self._values
 
+    def _afterRedirectToChange(self, name):
+
+        self.c.redirectTo = (self._values, 'redirectTo', 'inheritFrom')
+
+    def _afterOtherNameChange(self, name):
+
+        self.c.otherName = self._values
+
+    def _afterTypeChange(self, name):
+
+        self.c.typeID = self._references
+
+    def _afterAfterChangeChange(self, name):
+
+        self.c.afterChange = self._values
+
     def findMatch(self, view, matches=None):
 
         uuid = self._uuid
@@ -209,7 +216,7 @@
 
     valueAspects = ('required', 'persisted', 'indexed', 'notify',
                     'cardinality', 'defaultValue', 'initialValue',
-                    'inheritFrom', 'redirectTo', 'otherName',
+                    'inheritFrom', 'redirectTo', 'otherName', 'afterChange',
                     'deletePolicy', 'copyPolicy', 'countPolicy', 'domains')
 
     refAspects = ('type', 'superAttribute')

Modified: trunk/chandler/repository/schema/Kind.py (11433 => 11434)

--- trunk/chandler/repository/schema/Kind.py	2006-08-17 10:14:54 UTC (rev 11433)
+++ trunk/chandler/repository/schema/Kind.py	2006-08-17 10:28:52 UTC (rev 11434)
@@ -24,7 +24,6 @@
 from repository.item.Item import Item, MissingClass
 from repository.item.RefCollections import RefList
 from repository.item.Sets import AbstractSet
-from repository.item.Monitors import Monitors, Monitor
 from repository.item.Values import Values, References
 from repository.item.PersistentCollections import PersistentCollection
 from repository.persistence.RepositoryError import RecursiveLoadItemError
@@ -917,12 +916,18 @@
         self.schemaHash = hash = self._hashItem()
         return hash
 
-    def onValueChanged(self, name):
+    def _afterSchemaChange(self, attrName):
 
-        if name == 'attributeHash':
-            if 'schemaHash' in self._values:
-                del self.schemaHash
+        c = getattr(self, 'c', None)
+        if c is not None:
+            if c.monitorSchema or c.attributesCached:
+                self.flushCaches(attrName)
 
+    def _afterAttributeHashChange(self):
+
+        if 'schemaHash' in self._values:
+            del self.schemaHash
+
     def findMatch(self, view, matches=None):
 
         uuid = self._uuid
@@ -967,16 +972,6 @@
     _descriptors = {}
     
 
-class SchemaMonitor(Monitor):
-
-    def schemaChange(self, op, kind, attrName):
-
-        if isinstance(kind, Kind):
-            c = kind.c
-            if c.monitorSchema or c.attributesCached:
-                kind.flushCaches(attrName)
-
-
 class Extent(Item):
 
     def iterItems(self, recursive=True):




_______________________________________________
Commits mailing list
[email protected]
http://lists.osafoundation.org/mailman/listinfo/commits

Reply via email to