Anonymous avatar Anonymous committed df93fd7

MibTree and derivatives now maintain branchVersionId scalar which modifies
to a new value every time a change occurs to subtree components

Comments (0)

Files changed (1)

pysnmp/smi/mibs/SNMPv2-SMI.py

     # Subtrees registration
     
     def registerSubtrees(self, *subTrees):
-        """Register subtrees at this tree. Subtrees are always attached
-           at the level of this tree, not subtrees."""
+        self.branchVersionId += 1
         for subTree in subTrees:
             if subTree.name in self._vars:
                 raise error.SmiError(
                     'MIB subtree %s already registered at %s' %  (subTree.name, self)
                     )
             self._vars[subTree.name] = subTree
-            MibTree.branchVersionId = MibTree.branchVersionId + 1
 
     def unregisterSubtrees(self, *names):
-        """Detach subtrees from this tree"""
+        self.branchVersionId += 1
         for name in names:
             # This may fail if you fill a table by exporting MibScalarInstances
             # but later drop them through SNMP.
                     'MIB subtree %s not registered at %s' %  (name, self)
                     )
             del self._vars[name]
-            MibTree.branchVersionId = MibTree.branchVersionId + 1
 
     # Tree traversal
 
         self.getBranch(name, idx).writeCommit(name, val, idx, acInfo)
     
     def writeCleanup(self, name, val, idx, acInfo):
+        self.branchVersionId += 1
         self.getBranch(name, idx).writeCleanup(name, val, idx, acInfo)
     
     def writeUndo(self, name, val, idx, acInfo):
         self.syntax = self.__newSyntax
         
     def writeCleanup(self, name, val, idx, acInfo):
+        self.branchVersionId += 1
         debug.logger & debug.flagIns and debug.logger('writeCleanup: %s=%r' % (name, val))
         # Drop previous value
         self.__newSyntax = self.__oldSyntax = None
             self.writeCommit(name, val, idx, acInfo)
 
     def createCleanup(self, name, val, idx, acInfo):
+        self.branchVersionId += 1
         debug.logger & debug.flagIns and debug.logger('createCleanup: %s=%r' % (name, val))
         if val is not None:
             self.writeCleanup(name, val, idx, acInfo)
         else:
             raise error.NoSuchObjectError(idx=idx, name=name)
     def destroyCommit(self, name, val, idx, acInfo): pass
-    def destroyCleanup(self, name, val, idx, acInfo): pass
+    def destroyCleanup(self, name, val, idx, acInfo):
+        self.branchVersionId += 1
     def destroyUndo(self, name, val, idx, acInfo): pass
 
 # Conceptual table classes
         self.__rowOpWanted = {}
         self.__valIdx = {} # column instance value to OID index
         self.__valIdxId = -1
-        
+    
     # No branches here, terminal OIDs only
     def getBranch(self, name, idx):
         if name in self._vars:
                           self.__createdInstances[name], self._vars.get(name)
 
     def createCleanup(self, name, val, idx, acInfo):
+        self.branchVersionId += 1
         # Drop by-value index
         self.__valIdx.clear()
         
             del self._vars[name]
         
     def destroyCleanup(self, name, val, idx, acInfo):
+        self.branchVersionId += 1
         # Drop by-value index
         self.__valIdx.clear()
         
             raise self.__rowOpWanted[name]
 
     def writeCleanup(self, name, val, idx, acInfo):
+        self.branchVersionId += 1
         # Drop by-value index
         self.__valIdx.clear()
         
     def writeCommit(self, name, val, idx, acInfo):
         self.__delegate('Commit', name, val, idx, acInfo)
     def writeCleanup(self, name, val, idx, acInfo):
+        self.branchVersionId += 1
         self.__delegate('Cleanup', name, val, idx, acInfo)
     def writeUndo(self, name, val,  idx, acInfo):
         self.__delegate('Undo', name, val, idx, acInfo)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.