[Commits] (vajda) - value monitoring is now enabled by flag instead of counter

commits at osafoundation.org commits at osafoundation.org
Sun Aug 29 19:50:31 PDT 2004


Commit by: vajda
Modified files:
chandler/.cvsignore 1.15 1.16
chandler/Makefile 1.40 1.41
chandler/repository/item/Indexes.py 1.4 1.5
chandler/repository/item/Item.py 1.153 1.154
chandler/repository/item/ItemHandler.py 1.44 1.45
chandler/repository/item/Values.py 1.14 1.15
chandler/repository/schema/Kind.py 1.83 1.84

Log message:
   - value monitoring is now enabled by flag instead of counter
   - revisited install target to put .inst files into CHANDLERBIN


ViewCVS links:
http://cvs.osafoundation.org/index.cgi/chandler/.cvsignore.diff?r1=text&tr1=1.15&r2=text&tr2=1.16
http://cvs.osafoundation.org/index.cgi/chandler/Makefile.diff?r1=text&tr1=1.40&r2=text&tr2=1.41
http://cvs.osafoundation.org/index.cgi/chandler/repository/item/Indexes.py.diff?r1=text&tr1=1.4&r2=text&tr2=1.5
http://cvs.osafoundation.org/index.cgi/chandler/repository/item/Item.py.diff?r1=text&tr1=1.153&r2=text&tr2=1.154
http://cvs.osafoundation.org/index.cgi/chandler/repository/item/ItemHandler.py.diff?r1=text&tr1=1.44&r2=text&tr2=1.45
http://cvs.osafoundation.org/index.cgi/chandler/repository/item/Values.py.diff?r1=text&tr1=1.14&r2=text&tr2=1.15
http://cvs.osafoundation.org/index.cgi/chandler/repository/schema/Kind.py.diff?r1=text&tr1=1.83&r2=text&tr2=1.84

Index: chandler/repository/item/Values.py
diff -u chandler/repository/item/Values.py:1.14 chandler/repository/item/Values.py:1.15
--- chandler/repository/item/Values.py:1.14	Thu Aug 19 11:06:25 2004
+++ chandler/repository/item/Values.py	Sun Aug 29 19:50:28 2004
@@ -1,6 +1,6 @@
 
-__revision__  = "$Revision: 1.14 $"
-__date__      = "$Date: 2004/08/19 18:06:25 $"
+__revision__  = "$Revision: 1.15 $"
+__date__      = "$Date: 2004/08/30 02:50:28 $"
 __copyright__ = "Copyright (c) 2002 Open Source Applications Foundation"
 __license__   = "http://osafoundation.org/Chandler_0.1_license_terms.htm"
 
@@ -101,39 +101,25 @@
 
         return self._getFlags(key) & Values.TRANSIENT != 0
 
-    def _clearTransient(self, key):
-
-        self._flags[key] &= ~Values.TRANSIENT
+    def _isMonitored(self, key):
 
-    def _addMonitor(self, key, count=1):
+        return self._getFlags(key) & Values.MONITORED != 0
 
-        if '_monitors' in self.__dict__:
-            self._monitors[key] += count
-        else:
-            self._monitors = { key: count }
+    def _setTransient(self, key):
 
-    def _hasMonitors(self, key):
+        self._setFlag(key, Values.TRANSIENT)
 
-        return '_monitors' in self.__dict__ and key in self._monitors
-        #return True
+    def _setMonitored(self, key):
 
-    def _removeMonitor(self, key):
+        self._setFlag(key, Values.MONITORED)
 
-        monitors = self._getMonitors(key)
+    def _clearTransient(self, key):
 
-        if monitors:
-            self._monitors[key] = monitors - 1
-        else:
-            raise AttributeError, 'no monitors on attribute %s' %(key)
+        self._flags[key] &= ~Values.TRANSIENT
 
-    def _getMonitors(self, key):
+    def _clearMonitored(self, key):
 
-        try:
-            return self._monitors[key]
-        except AttributeError:
-            return 0
-        except KeyError:
-            return 0
+        self._flags[key] &= ~Values.MONITORED
 
     def _xmlValues(self, generator, withSchema, version, mode):
 
@@ -169,12 +155,9 @@
                     attrCard = 'single'
                     attrId = None
 
-                monitors = self._getMonitors(key)
                 attrs = {}
                 if flags:
                     attrs['flags'] = str(flags)
-                if monitors:
-                    attrs['monitors'] = str(monitors)
 
                 try:
                     ItemHandler.xmlValue(repository, key, value, 'attribute',
@@ -185,8 +168,9 @@
                     raise
 
 
-    READONLY = 0x0001          # value is read-only
+    READONLY  = 0x0001         # value is read-only
     TRANSIENT = 0x0002         # value is transient
+    MONITORED = 0x0004         # value is monitored
     
 
 class References(Values):
@@ -223,12 +207,9 @@
         for key, value in self.iteritems():
             if item.getAttributeAspect(key, 'persist', default=True):
                 flags = self._getFlags(key)
-                monitors = self._getMonitors(key)
                 attrs = {}
                 if flags:
                     attrs['flags'] = str(flags)
-                if monitors:
-                    attrs['monitors'] = str(monitors)
                 value._xmlValue(key, item, generator, withSchema, version,
                                 attrs, mode)
 

Index: chandler/repository/item/Indexes.py
diff -u chandler/repository/item/Indexes.py:1.4 chandler/repository/item/Indexes.py:1.5
--- chandler/repository/item/Indexes.py:1.4	Thu Aug 19 11:06:25 2004
+++ chandler/repository/item/Indexes.py	Sun Aug 29 19:50:28 2004
@@ -1,6 +1,6 @@
 
-__revision__  = "$Revision: 1.4 $"
-__date__      = "$Date: 2004/08/19 18:06:25 $"
+__revision__  = "$Revision: 1.5 $"
+__date__      = "$Date: 2004/08/30 02:50:28 $"
 __copyright__ = "Copyright (c) 2002 Open Source Applications Foundation"
 __license__   = "http://osafoundation.org/Chandler_0.1_license_terms.htm"
 
@@ -233,12 +233,12 @@
 
     def insertKey(self, key, afterKey):
 
-        self._valueMap[key].addMonitor(self._attribute)
+        self._valueMap[key].monitorValue(self._attribute, True)
         super(AttributeIndex, self).insertKey(key, afterKey)
 
     def removeKey(self, key):
 
-        self._valueMap[key].removeMonitor(self._attribute)
+        self._valueMap[key].monitorValue(self._attribute, False)
         super(AttributeIndex, self).removeKey(key)
             
     def _xmlValues(self, generator, version, attrs, mode):

Index: chandler/repository/schema/Kind.py
diff -u chandler/repository/schema/Kind.py:1.83 chandler/repository/schema/Kind.py:1.84
--- chandler/repository/schema/Kind.py:1.83	Mon Aug 23 21:36:15 2004
+++ chandler/repository/schema/Kind.py	Sun Aug 29 19:50:28 2004
@@ -1,6 +1,6 @@
 
-__revision__  = "$Revision: 1.83 $"
-__date__      = "$Date: 2004/08/24 04:36:15 $"
+__revision__  = "$Revision: 1.84 $"
+__date__      = "$Date: 2004/08/30 02:50:28 $"
 __copyright__ = "Copyright (c) 2002 Open Source Applications Foundation"
 __license__   = "http://osafoundation.org/Chandler_0.1_license_terms.htm"
 
@@ -90,7 +90,7 @@
             c = classobj(name, tuple(superClasses), {})
 
         self._values['classes'] = { 'python': c }
-        self._values._setFlag('classes', self._values.TRANSIENT)
+        self._values._setTransient('classes')
 
         return c
 

Index: chandler/Makefile
diff -u chandler/Makefile:1.40 chandler/Makefile:1.41
--- chandler/Makefile:1.40	Thu Aug 26 18:10:52 2004
+++ chandler/Makefile	Sun Aug 29 19:50:27 2004
@@ -58,6 +58,16 @@
 HOST=builds.osafoundation.org
 URL=http://$(HOST)/external/$(PLATFORM)
 
+BIN_ARCHIVES_INST = \
+    $(addsuffix .inst, \
+                $(addprefix $(CHANDLERBIN)/$(SNAP)/, \
+                            $(notdir $(BIN_ARCHIVES))))
+
+HOME_ARCHIVES_INST = \
+    $(addsuffix .inst, \
+                $(addprefix $(CHANDLERHOME)/, \
+                            $(notdir $(HOME_ARCHIVES))))
+
 .PHONY: default install clean realclean downloads
 
 default: install
@@ -67,12 +77,12 @@
 $(ARCHIVES):
 	curl -o $@ $(URL)/$(notdir $@)
 
-$(addsuffix .installed, $(notdir $(BIN_ARCHIVES))):
-	tar -C $(CHANDLERBIN) -xvzf ../$(basename $@)
+$(BIN_ARCHIVES_INST):
+	tar -C $(CHANDLERBIN) -xvzf ../$(notdir $(basename $@))
 	touch $@
 
-$(addsuffix .installed, $(notdir $(HOME_ARCHIVES))):
-	tar -C $(CHANDLERHOME) -xvzf ../$(basename $@)
+$(HOME_ARCHIVES_INST):
+	tar -C $(CHANDLERHOME) -xvzf ../$(notdir $(basename $@))
 	touch $@
 
 checkout:
@@ -81,13 +91,12 @@
 	cvs co chandler-python 2>&1 | tee -a cvsco.log; \
 	echo 'Do |grep "^C " ../cvsco.log| to check for potential conflicts'
 
-install: $(ARCHIVES) $(addsuffix .installed, $(notdir $(ARCHIVES)))
+install: $(ARCHIVES) $(BIN_ARCHIVES_INST) $(HOME_ARCHIVES_INST)
 
 clean:
 	rm -rf $(CHANDLERBIN)/$(SNAP) __repository__
-	rm -f $(addsuffix .installed, $(notdir $(ARCHIVES)))
 	rm -f chandler.log randpool.dat
 
 realclean: clean
-	rm -f $(ARCHIVES)
-	rm -fr $(CHANDLERBIN)/debug $(CHANDLERBIN)/release
+	rm -rf $(CHANDLERBIN)/debug $(CHANDLERBIN)/release
+	rm -f $(ARCHIVES) $(HOME_ARCHIVES_INST)

Index: chandler/.cvsignore
diff -u chandler/.cvsignore:1.15 chandler/.cvsignore:1.16
--- chandler/.cvsignore:1.15	Thu Aug 26 18:10:52 2004
+++ chandler/.cvsignore	Sun Aug 29 19:50:27 2004
@@ -7,4 +7,4 @@
 debug
 release
 randpool.dat
-*.installed
+*.inst

Index: chandler/repository/item/Item.py
diff -u chandler/repository/item/Item.py:1.153 chandler/repository/item/Item.py:1.154
--- chandler/repository/item/Item.py:1.153	Mon Aug 23 21:36:14 2004
+++ chandler/repository/item/Item.py	Sun Aug 29 19:50:28 2004
@@ -1,6 +1,6 @@
 
-__revision__  = "$Revision: 1.153 $"
-__date__      = "$Date: 2004/08/24 04:36:14 $"
+__revision__  = "$Revision: 1.154 $"
+__date__      = "$Date: 2004/08/30 02:50:28 $"
 __copyright__ = "Copyright (c) 2002 Open Source Applications Foundation"
 __license__   = "http://osafoundation.org/Chandler_0.1_license_terms.htm"
 
@@ -457,7 +457,7 @@
 
     def _invokeMonitors(self, name, attrDict):
 
-        if attrDict._hasMonitors(name):
+        if attrDict._isMonitored(name):
             from repository.item.Monitors import Monitors
             Monitors.invoke('set', self, name)
 
@@ -469,7 +469,7 @@
             if refDict is not None and item._uuid in refDict:
                 refDict.placeItem(item, None, indexName)
 
-    def addMonitor(self, name, _attrDict=None):
+    def monitorValue(self, name, set=True, _attrDict=None):
 
         if _attrDict is None:
             if self._values.has_key(name):
@@ -487,37 +487,15 @@
                     for i in xrange(len(names) - 1):
                         item = item.getAttributeValue(names[i])
 
-                    return item.addMonitor(name)
+                    return item.monitorValue(name, set)
 
                 else:
                     _attrDict = self._values
 
-        _attrDict._addMonitor(name)
-
-    def removeMonitor(self, name, _attrDict=None):
-
-        if _attrDict is None:
-            if self._values.has_key(name):
-                _attrDict = self._values
-            elif self._references.has_key(name):
-                _attrDict = self._references
-            elif self._kind.getOtherName(name, default=None) is not None:
-                _attrDict = self._references
-            else:
-                redirect = self.getAttributeAspect(name, 'redirectTo',
-                                                   default=None)
-                if redirect is not None:
-                    item = self
-                    names = redirect.split('.')
-                    for i in xrange(len(names) - 1):
-                        item = item.getAttributeValue(names[i])
-
-                    return item.removeMonitor(name)
-
-                else:
-                    _attrDict = self._values
-
-        _attrDict._removeMonitor(name)
+        if set:
+            _attrDict._setMonitored(name)
+        else:
+            _attrDict._clearMonitored(name)
 
     def getAttributeValue(self, name, _attrDict=None, **kwds):
         """
@@ -1348,12 +1326,13 @@
         if self._status & Item.NODIRTY:
             return False
 
-        if attrDict is not None:
-            assert attribute is not None
-            assert attrDict is not None
-            self._invokeMonitors(attribute, attrDict)
-
         if dirty:
+
+            if attrDict is not None:
+                assert attribute is not None
+                assert attrDict is not None
+                self._invokeMonitors(attribute, attrDict)
+
             self._lastAccess = Item._countAccess()
             if self._status & Item.DIRTY == 0:
                 repository = self.getRepositoryView()

Index: chandler/repository/item/ItemHandler.py
diff -u chandler/repository/item/ItemHandler.py:1.44 chandler/repository/item/ItemHandler.py:1.45
--- chandler/repository/item/ItemHandler.py:1.44	Thu Aug 19 11:06:25 2004
+++ chandler/repository/item/ItemHandler.py	Sun Aug 29 19:50:28 2004
@@ -1,6 +1,6 @@
 
-__revision__  = "$Revision: 1.44 $"
-__date__      = "$Date: 2004/08/19 18:06:25 $"
+__revision__  = "$Revision: 1.45 $"
+__date__      = "$Date: 2004/08/30 02:50:28 $"
 __copyright__ = "Copyright (c) 2002 Open Source Applications Foundation"
 __license__   = "http://osafoundation.org/Chandler_0.1_license_terms.htm"
 
@@ -110,10 +110,6 @@
             else:
                 readOnly = False
 
-            monitors = attrs.get('monitors', None)
-            if monitors is not None:
-                self.references._addMonitor(name, int(monitors))
-
             cardinality = self.getCardinality(attribute, attrs)
 
             if cardinality != 'single':
@@ -424,10 +420,6 @@
                 elif isinstance(value, ItemValue):
                     value._setReadOnly()
 
-        monitors = attrs.get('monitors', None)
-        if monitors is not None:
-            self.values._addMonitor(attrs['name'], int(monitors))
-
     def valueEnd(self, itemHandler, attrs, **kwds):
 
         if kwds.has_key('value'):



More information about the Commits mailing list