aboutsummaryrefslogtreecommitdiffstats
path: root/server/plugin.py
diff options
context:
space:
mode:
authorZaran <zaran.krleza@gmail.com>2011-01-29 23:59:55 +0100
committerZaran <zaran.krleza@gmail.com>2011-01-29 23:59:55 +0100
commit995686b5ff272fb1fe0e78c087d6855ea93ae85e (patch)
tree2189ec380146661973b47bbdeb598eb047443312 /server/plugin.py
parent1b5acc0c20a0f233b52a63b1f17ea0b3a7587e58 (diff)
downloadalias-995686b5ff272fb1fe0e78c087d6855ea93ae85e.tar.gz
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.
Diffstat (limited to 'server/plugin.py')
-rw-r--r--server/plugin.py14
1 files changed, 7 insertions, 7 deletions
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: