Author: tmckay
Date: 2011-08-29 15:47:22 +0000 (Mon, 29 Aug 2011)
New Revision: 4938
Modified:
trunk/sage/python/sage/wallaby/wallabyoperations.py
Log:
Add edit_features routine to replace feature set on a group.
Modified: trunk/sage/python/sage/wallaby/wallabyoperations.py
===================================================================
--- trunk/sage/python/sage/wallaby/wallabyoperations.py 2011-08-26 18:22:16 UTC (rev
4937)
+++ trunk/sage/python/sage/wallaby/wallabyoperations.py 2011-08-29 15:47:22 UTC (rev
4938)
@@ -434,7 +434,8 @@
node -- a wallaby.Node object or the name of a wallaby.Node object
- tags -- the new set of tags for the node, list or tuple.
+ tags -- the new set of tags for the node,
+ list or tuple of strings
'''
if type(node) in (str, unicode):
n = node
@@ -449,6 +450,9 @@
start = time.time()
n.modifyTags("REPLACE", list(tags), create_missing_tags=True)
n.update()
+ # refresh the groups and tags so that membership informatio
+ # is up to date.
+ self.refresh(WBTypes.GROUPS,WBTypes.TAGS)
except Exception, e:
log.debug("WallabyOperations: edit_tags, exception suppressed,
%s" % str(e))
return False
@@ -456,6 +460,34 @@
log.debug("WallabyOperations: edit_tags %s" % delta)
return True
+ def edit_features(self, group, *features):
+ '''
+ Replace existing features in a group with the specified features.
+
+ group -- a wallaby.Group object or the name of a wallaby.Group object
+
+ features -- the new set of features for the group,
+ list or tuple of strings
+ '''
+ if type(group) in (str, unicode):
+ g = group
+ else:
+ g = group.name
+ self._lock.acquire()
+ if g in self._cache[WBTypes.GROUPS].data:
+ g = self._cache[WBTypes.GROUPS].data[g]
+ self._lock.release()
+ try:
+ start = time.time()
+ g.modifyFeatures("REPLACE", features)
+ g.update()
+ except Exception, e:
+ log.debug("WallabyOperations: edit_features, exception suppressed,
%s" % str(e))
+ return False
+ delta = time.time() - start
+ log.debug("WallabyOperations: edit_features %s" % delta)
+ return True
+
def set_interval(self, which, refresh):
'''
Set an individual refresh interval for a data item.
Show replies by date