示例#1
0
 def test_sync_acl(self):
   self.assertEqual(self.connected, True)
   ret = zookeeper.create(self.handle, "/zk-python-acltest", "nodecontents", [ZOO_OPEN_ACL_UNSAFE], zookeeper.EPHEMERAL)
   acls = zookeeper.get_acl(self.handle, "/zk-python-acltest")
   self.assertEqual(acls[1], [ZOO_OPEN_ACL_UNSAFE])
   self.assertRaises(zookeeper.InvalidACLException,zookeeper.set_acl,self.handle, "/zk-python-acltest", -1, ZOO_ACL_READ)
   zookeeper.set_acl(self.handle, "/zk-python-acltest", -1, [ZOO_ACL_READ])
   acls = zookeeper.get_acl(self.handle, "/zk-python-acltest")
   self.assertEqual(acls[1], [ZOO_ACL_READ])
示例#2
0
    def set_acl(self, path, acls, version=-1):
	"""Set the ACL for the node of the given path.

        Set the ACL for the node of the given path if such a node exists and
	(optionally) the given version matches the version of the node.

        :Parameters:
            - `path`: path to node
	    - `acls`: list of acls (ACL objects) to apply
	    - `version`: (optional) expected node version to update

        :Throws:
	    - `InvalidACLException`: if the acl is invalid
	    - `NoNodeException`: if the given path does not exist
	    - `BadVersionException`: if the node is of a different version
	"""
	acls = [acl.to_dict() for acl in acls]

	val = _zookeeper.set_acl(self.zk_handle, path, version, acls)
	assert val == zookeeper.constants.OK