From 995686b5ff272fb1fe0e78c087d6855ea93ae85e Mon Sep 17 00:00:00 2001 From: Zaran Date: Sat, 29 Jan 2011 23:59:55 +0100 Subject: Retrieve both the key and perm at the same time for performance reason. Also make the key a subitem (instead of an attribute) of the result stanza. --- server/plugin.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'server/plugin.py') diff --git a/server/plugin.py b/server/plugin.py index 80e9863..892977e 100644 --- a/server/plugin.py +++ b/server/plugin.py @@ -9,7 +9,7 @@ from sleekxmpp.xmlstream.handler.callback import Callback from sleekxmpp.xmlstream.matcher.xpath import MatchXPath from sleekxmpp.stanza.iq import Iq -from object import Object +from object import Object, ObjectError from permission import PermissionError class AliasQuery(ElementBase): @@ -17,12 +17,12 @@ class AliasQuery(ElementBase): name = 'query' plugin_attrib = 'alias' interfaces = set(('node', 'type', 'content', 'permission', 'key')) - sub_interfaces = set(('content', 'permission')) + sub_interfaces = set(('content', 'permission', 'key')) def addItem(self, node, key, permission = None): item = AliasItem(None, self) item['node'] = node - item['key']= key + item['key'] = key if permission is not None: item['permission'] = str(permission) @@ -30,7 +30,7 @@ class AliasItem(ElementBase): namespace = 'alias:query' name = 'item' plugin_attrib = 'item' - interfaces = set(('node', 'permission', 'key' )) + interfaces = set(('node', 'permission', 'key')) class AliasPlugin(base.base_plugin): @@ -63,8 +63,9 @@ class AliasPlugin(base.base_plugin): node = iq['alias']['node'] if not node: node = hashlib.sha1(callee).hexdigest() + node = Object(callee, node) - + if iq['alias']['type'] == 'items': try: childs = node.get_child_list(caller) @@ -80,8 +81,7 @@ class AliasPlugin(base.base_plugin): if iq['alias']['type'] == 'content': try: - content = node.get_content(caller) - key = node.get_key(caller) + content, key = node.get_content(caller) except PermissionError: self.send_permission_error(iq, 'Permission') else: -- cgit v1.2.3-70-g09d2