Created
June 20, 2011 14:18
-
-
Save willb/1035680 to your computer and use it in GitHub Desktop.
Example session with tagging support in the Wallaby client library
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import wallaby | |
# the "tagging" module patches the Wallaby client library with | |
# support for tag operations | |
import tagging | |
# We'll start by setting up a Wallaby client library session against | |
# the broker on localhost | |
from qmf.console import Session | |
console = Session() | |
console.addBroker() | |
raw_store, = console.getObjects(_class="Store") | |
store = wallaby.Store(raw_store, console) | |
# call this method after the store client is initialized so that | |
# the tagging library knows how to create missing groups | |
tagging.setup(store) | |
# Clear out all of the memberships on a fake node | |
store.getNode("fake-node.example.com").modifyMemberships("REPLACE", [], {}) | |
# After clearing a node's membership list, it will have no tags | |
store.getNode("fake-node.example.com").getTags() | |
# You can also access the tags of a given node via its "tags" attribute | |
store.getNode("fake-node.example.com").tags | |
# by convention, we're preceding tags with "@" here | |
store.getNode("fake-node.example.com").modifyTags("ADD", ["@Foo", "@Blitz"], create_missing_tags=True) | |
# This should return ["@Foo", "@Blitz"] | |
store.getNode("fake-node.example.com").tags | |
# This should return ["===TAGS_BELOW===", "@Foo", "@Blitz"] | |
store.getNode("fake-node.example.com").memberships |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment