[spade2] r2233 committed - - Modified RPC API. Now service P and Q are matched with inputs and ou...

4 views
Skip to first unread message

spa...@googlecode.com

unread,
Jul 30, 2010, 9:44:22 AM7/30/10
to spade-...@googlegroups.com
Revision: 2233
Author: jpalanca
Date: Fri Jul 30 06:42:53 2010
Log: - Modified RPC API. Now service P and Q are matched with inputs and
outputs stored (optionally) in the agent KB
- DF.Service class now has a asContentObject method, so it can be converted
easy to a XML string
- DF now publishes service registrations and unregistrations using pubsub
events
- Fixed some XML and CO generations
- Fixed pubsub module. Now PlatformAgents (with namespace
NS_COMPONENT_ACCEPT) can use pubsub. Fixes issue 60.

http://code.google.com/p/spade2/source/detail?r=2233

Modified:
/trunk/examples/unittests/aidTestCase.py
/trunk/examples/unittests/dadTestCase.py
/trunk/examples/unittests/dfTestCase.py
/trunk/examples/unittests/pubsubTestCase.py
/trunk/examples/unittests/rpcTestCase.py
/trunk/spade/AID.py
/trunk/spade/Agent.py
/trunk/spade/DF.py
/trunk/spade/RPC.py
/trunk/spade/pubsub.py
/trunk/xmppd/modules/pubsub.py

=======================================
--- /trunk/examples/unittests/aidTestCase.py Sun Jul 11 16:13:46 2010
+++ /trunk/examples/unittests/aidTestCase.py Fri Jul 30 06:42:53 2010
@@ -90,7 +90,7 @@
co["name"] ="name1"
co["addresses"] = ["addr1","addresses2"]
co["resolvers"] = ["resolver1"]
- co["properties"] = []
+ #co["properties"] = []

assert aid1.asContentObject() == co

=======================================
--- /trunk/examples/unittests/dadTestCase.py Sun Jul 11 16:13:46 2010
+++ /trunk/examples/unittests/dadTestCase.py Fri Jul 30 06:42:53 2010
@@ -241,7 +241,7 @@
self.assertEqual(dad1.match(dad2),True)

def testXML(self):
- xml1='<name><resolvers list="true"></resolvers><properties
list="true"></properties><name>aidname1</name><addresses
list="true"></addresses></name><lease-time>1000</lease-time><languages
list="true"><languages>language11</languages><languages>sdlanguage11</languages></languages><services
list="true"><services><name>servicename11</name><properties><Q>valueQ1</Q><P>valueP1</P></properties><languages
list="true"><languages>sdlanguage11</languages></languages><ownership>agent11</ownership><type>type11</type><ontologies
list="true"><ontologies>sdontology11</ontologies></ontologies><protocols
list="true"><protocols>sdprotocol11</protocols></protocols></services></services><scope>scope11</scope><ontologies
list="true"><ontologies>ontology11</ontologies><ontologies>sdontology11</ontologies></ontologies><protocols
list="true"><protocols>protocol11</protocols><protocols>sdprotocol11</protocols></protocols>'
+
xml1='<name><name>aidname1</name></name><lease-time>1000</lease-time><languages
list="true"><languages>language11</languages><languages>sdlanguage11</languages></languages><services
list="true"><services><name>servicename11</name><properties><Q>valueQ1</Q><P>valueP1</P></properties><languages
list="true"><languages>sdlanguage11</languages></languages><ownership>agent11</ownership><type>type11</type><ontologies
list="true"><ontologies>sdontology11</ontologies></ontologies><protocols
list="true"><protocols>sdprotocol11</protocols></protocols></services></services><scope>scope11</scope><ontologies
list="true"><ontologies>ontology11</ontologies><ontologies>sdontology11</ontologies></ontologies><protocols
list="true"><protocols>protocol11</protocols><protocols>sdprotocol11</protocols></protocols>'
dad = CreateDAD("1")
sd = CreateSD("1")
dad.addService(sd)
@@ -264,7 +264,7 @@
dad = spade.DF.DfAgentDescription(co=co)

xml1 = dad.asRDFXML()
- xml2='<name><resolvers list="true"></resolvers><properties
list="true"></properties><name>aidname1</name><addresses
list="true"></addresses></name><lease-time>1000</lease-time><languages
list="true"><languages>language11</languages><languages>sdlanguage11</languages></languages><services
list="true"><services><name>servicename11</name><properties><Q>valueQ1</Q><P>valueP1</P></properties><languages
list="true"><languages>sdlanguage11</languages></languages><ownership>agent11</ownership><type>type11</type><ontologies
list="true"><ontologies>sdontology11</ontologies></ontologies><protocols
list="true"><protocols>sdprotocol11</protocols></protocols></services></services><scope>scope11</scope><ontologies
list="true"><ontologies>ontology11</ontologies><ontologies>sdontology11</ontologies></ontologies><protocols
list="true"><protocols>protocol11</protocols><protocols>sdprotocol11</protocols></protocols>'
+
xml2='<name><name>aidname1</name></name><lease-time>1000</lease-time><languages
list="true"><languages>language11</languages><languages>sdlanguage11</languages></languages><services
list="true"><services><name>servicename11</name><properties><Q>valueQ1</Q><P>valueP1</P></properties><languages
list="true"><languages>sdlanguage11</languages></languages><ownership>agent11</ownership><type>type11</type><ontologies
list="true"><ontologies>sdontology11</ontologies></ontologies><protocols
list="true"><protocols>sdprotocol11</protocols></protocols></services></services><scope>scope11</scope><ontologies
list="true"><ontologies>ontology11</ontologies><ontologies>sdontology11</ontologies></ontologies><protocols
list="true"><protocols>protocol11</protocols><protocols>sdprotocol11</protocols></protocols>'

assert xml1==xml2

@@ -351,7 +351,7 @@
content = parser.parse(sl0)
self.assertNotEqual(content,None)

- xml='<name><resolvers list="true"></resolvers><properties
list="true"></properties><name>aidname1</name><addresses
list="true"></addresses></name><lease-time>1000</lease-time><languages
list="true"><languages>language11</languages><languages>sdlanguage11</languages></languages><services
list="true"><services><name>servicename11</name><properties><Q>valueQ1</Q><P>valueP1</P></properties><languages
list="true"><languages>sdlanguage11</languages></languages><ownership>agent11</ownership><type>type11</type><ontologies
list="true"><ontologies>sdontology11</ontologies></ontologies><protocols
list="true"><protocols>sdprotocol11</protocols></protocols></services></services><scope>scope11</scope><ontologies
list="true"><ontologies>ontology11</ontologies><ontologies>sdontology11</ontologies></ontologies><protocols
list="true"><protocols>protocol11</protocols><protocols>sdprotocol11</protocols></protocols>'
+ xml='<name><name>aidname1</name><addresses
list="true"></addresses></name><lease-time>1000</lease-time><languages
list="true"><languages>language11</languages><languages>sdlanguage11</languages></languages><services
list="true"><services><name>servicename11</name><properties><Q>valueQ1</Q><P>valueP1</P></properties><languages
list="true"><languages>sdlanguage11</languages></languages><ownership>agent11</ownership><type>type11</type><ontologies
list="true"><ontologies>sdontology11</ontologies></ontologies><protocols
list="true"><protocols>sdprotocol11</protocols></protocols></services></services><scope>scope11</scope><ontologies
list="true"><ontologies>ontology11</ontologies><ontologies>sdontology11</ontologies></ontologies><protocols
list="true"><protocols>protocol11</protocols><protocols>sdprotocol11</protocols></protocols>'
dad = spade.DF.DfAgentDescription()
dad.loadSL0(content)

=======================================
--- /trunk/examples/unittests/dfTestCase.py Wed Jul 14 06:10:54 2010
+++ /trunk/examples/unittests/dfTestCase.py Fri Jul 30 06:42:53 2010
@@ -94,7 +94,7 @@
s.setName("unittest_name_1_"+param)
s.setOwner(agent.getAID())
s.addP("service_precondition")
- s.setQ("service_postcondition")
+ s.addQ("service_postcondition")
s.setInputs(['login','password'])
s.setOutputs(['account_id'])
s.setDescription("Login Service")
@@ -310,27 +310,6 @@

self.a.result = None

- '''
- #It is not necessary to re-check the Register function. There is a
unittest for it.
- #check service is registered
- Search_DAD(self.a,"a")
-
- self.assertNotEqual(self.a.result, None)
- self.assertEqual(len(self.a.result), 1)
-
- self.assertEqual(self.a.result[0].getAID(), self.a.getAID())
- self.assertEqual(len(self.a.result[0].getServices()), 2)
-
- if self.a.result[0].getServices()[0].getName() not in
['unittest_name_1','unittest_name_2']:
- self.fail()
- if self.a.result[0].getServices()[1].getName() not in
['unittest_name_1','unittest_name_2']:
- self.fail()
-
-
self.assertEqual(self.a.result[0].getServices()[0].getType(),"unittest_type_1")
-
- self.a.result = None
- '''
-
#modify service
Modify_DAD(self.a,"a")

@@ -357,14 +336,6 @@

self.assertEqual(self.a.result, True)

- '''
- #check service is deregistered
- self.a.result = False
- Search_DAD(self.a,"a")
- self.assertEqual(self.a.result, [])
- '''
-
-

def testModifyNotAllowed_DAD(self):

@@ -378,28 +349,6 @@

self.a.result = None

- '''
- #check service is registered
- Search_DAD(self.a,"a")
-
- self.assertNotEqual(self.a.result, None)
- self.assertEqual(len(self.a.result), 1)
-
- self.assertEqual(self.a.result[0].getAID(), self.a.getAID())
- self.assertEqual(len(self.a.result[0].getServices()), 2)
-
- if self.a.result[0].getServices()[0].getName() not in
['unittest_name_1','unittest_name_2']:
- self.fail()
- if self.a.result[0].getServices()[1].getName() not in
['unittest_name_1','unittest_name_2']:
- self.fail()
-
-
self.assertEqual(self.a.result[0].getServices()[0].getType(),"unittest_type_1")
-
self.assertEqual(self.a.result[0].getServices()[1].getType(),"unittest_type_2")
-
- self.a.result = None
- self.b.result = None
- '''
-
#modify service
Modify_DAD(self.b,"a")

@@ -427,13 +376,6 @@

self.assertEqual(self.a.result, True)

- '''
- #check service is deregistered
- self.a.result = False
- Search_DAD(self.a,"a")
- self.assertEqual(self.a.result, [])
- '''
-
def testModifyNotRegistered_DAD(self):

#deregister service
@@ -513,26 +455,6 @@
DeRegister_DAD(self.a,"a")
DeRegister_DAD(self.b,"b")

- '''
- self.assertEqual(self.a.result, True)
-
- self.a.result = None
-
- #check number of services is 1
- EmptySearch_DAD(self.a)
-
- self.assertNotEqual(self.a.result, None)
- self.assertEqual(len(self.a.result), 1)
-
- self.a.result = None
-
- self.assertEqual(self.a.result, True)
-
- #check service is deregistered
- self.a.result = False
- Search_DAD(self.a,"a")
- self.assertEqual(self.a.result, [])
- '''

def testAlreadyRegistered_DAD(self):

@@ -546,22 +468,6 @@

self.a.result = None

- '''
- #check service is registered
- Search_DAD(self.a,"a")
-
- self.assertNotEqual(self.a.result, None)
- self.assertEqual(len(self.a.result), 1)
-
- self.assertEqual(self.a.result[0].getAID(), self.a.getAID())
- self.assertEqual(len(self.a.result[0].getServices()), 2)
-
- if self.a.result[0].getServices()[0].getName() not in
['unittest_name_1','unittest_name_2']:
- self.fail()
-
- self.a.result = None
- '''
-
#register service ALREADY registered
Register_DAD(self.a,"a")

@@ -684,14 +590,6 @@
DeRegister(self.a,"a")
DeRegister(self.b,"a")

- '''
- #check service is not registered
- Search(self.a,"a")
-
- self.assertNotEqual(self.a.result, None)
- self.assertEqual(len(self.a.result), 0)
- '''
-
self.a.result = None

#register service
@@ -841,13 +739,6 @@

self.assertEqual(self.a.result, True)

- '''
- #check service is deregistered
- self.a.result = False
- Search(self.a,"a")
- self.assertEqual(self.a.result, [])
- '''
-
def testModifyNotRegistered(self):
#deregister service
DeRegister(self.a,"a")
@@ -924,14 +815,6 @@

self.a.result = None

- '''
- #check service is deregistered
- self.a.result = False
- Search(self.a,"a")
- self.assertEqual(self.a.result, [])
- '''
-
-
def testAlreadyRegistered(self):

#deregister service
@@ -944,22 +827,6 @@

self.a.result = None

- '''
- #check service is registered
- Search(self.a,"a")
-
- self.assertNotEqual(self.a.result, None)
- self.assertEqual(len(self.a.result), 1)
-
- self.assertEqual(len(self.a.result), 1)
- self.assertEqual(self.a.result[0].getOwner(), self.a.getAID())
-
- if self.a.result[0].getName() not in ['unittest_name_1']:
- self.fail()
-
- self.a.result = None
- '''
-
#register service ALREADY registered
Register(self.a,"a")

@@ -973,18 +840,11 @@

self.assertEqual(self.a.result, True)

- '''
- #check service is deregistered
- self.a.result = False
- Search(self.a,"a")
- self.assertEqual(self.a.result, [])
- '''
-


if __name__ == "__main__":
- unittest.main()
- sys.exit()
+ #unittest.main()
+ #sys.exit()

suite = unittest.TestSuite()
suite.addTest(DFTestCase('testRegisterService'))
=======================================
--- /trunk/examples/unittests/pubsubTestCase.py Tue Jul 20 08:35:54 2010
+++ /trunk/examples/unittests/pubsubTestCase.py Fri Jul 30 06:42:53 2010
@@ -150,11 +150,11 @@


if __name__ == "__main__":
- unittest.main()
- sys.exit()
+ #unittest.main()
+ #sys.exit()

suite = unittest.TestSuite()
- suite.addTest(PubSubTestCase('testPublishEvent'))
+ suite.addTest(PubSubTestCase('testCreateEvent'))
result = unittest.TestResult()

suite.run(result)
=======================================
--- /trunk/examples/unittests/rpcTestCase.py Fri Jul 2 08:25:14 2010
+++ /trunk/examples/unittests/rpcTestCase.py Fri Jul 30 06:42:53 2010
@@ -1,6 +1,7 @@
import os
import sys
import time
+import types
import unittest

sys.path.append('../..')
@@ -14,18 +15,18 @@
def _setup(self):
self.result = None

-def sumVec(param):
+def sumVec(vec):
r = 0
- for i in param:
+ for i in vec:
r+=int(i)
- return r
-
-def CreateService(name, owner, params=None):
- return spade.DF.Service(name, owner, P=params)
-
-def Invoke(agent, service):
-
- agent.result = agent.invokeService(service)
+ return {"sum":r}
+
+def CreateService(name, owner, P=None,Q=None):
+ return spade.DF.Service(name, owner, P=P,Q=Q)
+
+def Invoke(agent, service,inputs=None):
+
+ agent.result = agent.invokeService(service,inputs)

def RegisterService(agent, service, method):

@@ -45,8 +46,8 @@

def setUp(self):

- self.Aaid = spade.AID.aid("a@"+host,["xmpp://aa@"+host])
- self.Baid = spade.AID.aid("b@"+host,["xmpp://bb@"+host])
+ self.Aaid = spade.AID.aid("a@"+host,["xmpp://a@"+host])
+ self.Baid = spade.AID.aid("b@"+host,["xmpp://b@"+host])

self.a = MyAgent("a@"+host, "secret")
self.a.start()
@@ -65,14 +66,14 @@
def testInvokeService(self):
DeRegisterService(self.b)

- s = CreateService("VecSum",self.b.getAID(),[10,20])
+ s = CreateService("VecSum",self.b.getAID(),P=["vec"],Q=["sum"])
RegisterService(self.b, s, sumVec)

- Invoke(self.a, s)
+ Invoke(self.a, s,inputs={"vec":[10,20]})
self.assertNotEqual(self.a.result,None)
self.assertNotEqual(self.a.result,False)
- self.assertEqual(len(self.a.result),1)
- self.assertEqual(self.a.result[0],30)
+ self.assertEqual(type(self.a.result),types.DictType)
+ self.assertEqual(self.a.result,{"sum":30})

DeRegisterService(self.b)
self.assertEqual(self.b.result,True)
@@ -82,14 +83,14 @@
def testInvokeOwnService(self):
DeRegisterService(self.b)

- s = CreateService("VecSum",self.b.getAID(),[10,20])
+ s = CreateService("VecSum",self.b.getAID(),P=["vec"],Q=["sum"])
RegisterService(self.b, s, sumVec)

- Invoke(self.b, s)
+ Invoke(self.b, s, inputs={"vec":[10,20]})
self.assertNotEqual(self.b.result,None)
self.assertNotEqual(self.b.result,False)
- self.assertEqual(len(self.b.result),1)
- self.assertEqual(self.b.result[0],30)
+ self.assertEqual(type(self.b.result),types.DictType)
+ self.assertEqual(self.b.result,{"sum":30})

DeRegisterService(self.b)
self.assertEqual(self.b.result,True)
@@ -97,19 +98,19 @@
def testSearchAndInvoke(self):
DeRegisterService(self.b)

- s = CreateService("VecSum",self.b.getAID(),[10,20])
+ s = CreateService("VecSum",self.b.getAID(),P=["vec"],Q=["sum"])
RegisterService(self.b, s, sumVec)

- s2 = CreateService("VecSum",self.b.getAID(),[10,20])
+ s2 = CreateService("VecSum",self.b.getAID(),P=["vec"])
services = SearchService(self.a,s2)
self.assertNotEqual(services,None)
self.assertEqual(len(services),1)

- Invoke(self.a, services[0])
+ Invoke(self.a, services[0],inputs={"vec":[10,20]})
self.assertNotEqual(self.a.result,None)
self.assertNotEqual(self.a.result,False)
- self.assertEqual(len(self.a.result),1)
- self.assertEqual(self.a.result[0],30)
+ self.assertEqual(type(self.a.result),types.DictType)
+ self.assertEqual(self.a.result,{"sum":30})

DeRegisterService(self.b)
self.assertEqual(self.b.result,True)
@@ -117,11 +118,11 @@
def testInvokeBadParams(self):
DeRegisterService(self.b)

- s = CreateService("VecSum",self.b.getAID(),[10,20])
+ s = CreateService("VecSum",self.b.getAID(),P=["vec"],Q=["sum"])
RegisterService(self.b, s, sumVec)

- s2 = CreateService("VecSum",self.b.getAID(),["param1","param2"])
- Invoke(self.a, s2)
+ s2 = CreateService("VecSum",self.b.getAID())
+ Invoke(self.a, s2, inputs={"vec":["param1","param2"]})
self.assertEqual(self.a.result,False)

DeRegisterService(self.b)
@@ -129,7 +130,7 @@
def testInvokeNotExistingService(self):
DeRegisterService(self.b)

- s = CreateService("VecSum",self.b.getAID(),[10,20])
+ s = CreateService("VecSum",self.b.getAID(),P=["vec"])

Invoke(self.a, s)
self.assertNotEqual(self.a.result,None)
@@ -138,36 +139,73 @@
def testInvokeTwice(self):
DeRegisterService(self.b)

- s = CreateService("VecSum",self.b.getAID(),[10,20])
+ s = CreateService("VecSum",self.b.getAID(),P=["vec"],Q=["sum"])
RegisterService(self.b, s, sumVec)

- Invoke(self.a, s)
+ Invoke(self.a, s, inputs={"vec":[10,20]})
self.assertNotEqual(self.a.result,None)
self.assertNotEqual(self.a.result,False)
- self.assertEqual(len(self.a.result),1)
- self.assertEqual(self.a.result[0],30)
+ self.assertEqual(self.a.result,{"sum":30})
+
+ Invoke(self.a, s, inputs={"vec":[20,20]})
+ self.assertNotEqual(self.a.result,None)
+ self.assertNotEqual(self.a.result,False)
+ self.assertEqual(self.a.result,{"sum":40})
+
+ DeRegisterService(self.b)
+ self.assertEqual(self.b.result,True)
+ services = SearchService(self.a,s)
+ self.assertEqual(len(services),0)
+
+ def testInvokeService_withKB(self):
+ DeRegisterService(self.b)
+
+ s = CreateService("VecSum",self.b.getAID(),P=["vec"],Q=["sum"])
+ RegisterService(self.b, s, sumVec)
+
+ self.a.KB["vec"] = [10,20]

Invoke(self.a, s)
self.assertNotEqual(self.a.result,None)
self.assertNotEqual(self.a.result,False)
- self.assertEqual(len(self.a.result),1)
- self.assertEqual(self.a.result[0],30)
-
+ self.assertEqual(self.a.KB["sum"],30)
+
+ DeRegisterService(self.b)
+ self.assertEqual(self.b.result,True)
+ services = SearchService(self.a,s)
+ self.assertEqual(len(services),0)
+
+ del self.a.KB["sum"]
+ del self.a.KB["vec"]
+
+ def testInvokeServiceMissingParams_withKB(self):
+ DeRegisterService(self.b)
+
+ s = CreateService("VecSum",self.b.getAID(),P=["vec"],Q=["sum"])
+ RegisterService(self.b, s, sumVec)
+
+ Invoke(self.a, s)
+ self.assertEqual(self.a.result,False)
+ if self.a.KB.has_key("sum"): self.fail()

DeRegisterService(self.b)
self.assertEqual(self.b.result,True)
services = SearchService(self.a,s)
self.assertEqual(len(services),0)
-

if __name__ == "__main__":
unittest.main()
sys.exit()
suite = unittest.TestSuite()
- suite.addTest(RPCTestCase('testSearchAndInvoke'))
+ suite.addTest(RPCTestCase('testInvokeService_withKB'))
result = unittest.TestResult()

suite.run(result)
+ print str(result)
+ for f in result.errors:
+ print f[0]
+ print f[1]
+
for f in result.failures:
print f[0]
print f[1]
=======================================
--- /trunk/spade/AID.py Sun Jul 11 16:13:46 2010
+++ /trunk/spade/AID.py Fri Jul 30 06:42:53 2010
@@ -199,15 +199,18 @@
"""
co = ContentObject()
co["name"] = self.getName()
- co["addresses"] = []
- for addr in self.getAddresses():
- co["addresses"].append(addr)
- co["resolvers"] = []
- for r in self.getResolvers():
- co["resolvers"].append(r)
- co["properties"] = []
- for p in self.getProperties():
- co["properties"].append(p)
+ if self.getAddresses()!=[]:
+ co["addresses"] = []
+ for addr in self.getAddresses():
+ co["addresses"].append(addr)
+ if self.getResolvers()!=[]:
+ co["resolvers"] = []
+ for r in self.getResolvers():
+ co["resolvers"].append(r)
+ if self.getProperties()!=[]:
+ co["properties"] = []
+ for p in self.getProperties():
+ co["properties"].append(p)
return co

def asXML(self):
=======================================
--- /trunk/spade/Agent.py Tue Jul 20 08:35:54 2010
+++ /trunk/spade/Agent.py Fri Jul 30 06:42:53 2010
@@ -38,6 +38,7 @@
import SocketServer
import colors
import cPickle as pickle
+import uuid


import DF
@@ -152,6 +153,9 @@
#Remote Procedure Calls support
self.RPC = {}
self.addBehaviour(RPC.RPCServerBehaviour(),
Behaviour.MessageTemplate(Iq(typ='set',queryNS=NS_RPC)))
+
+ #BDI Support
+ self.KB = {} #Knowledge Base

def WUIController_admin(self):
import types
@@ -1215,13 +1219,14 @@
if not self._running:
try:
behaviour._receive = self._receive
+ behaviour.myAgent = self
behaviour.onStart()
behaviour._process()
behaviour.onEnd()
del behaviour
return True
- except:
- self.DEBUG("Failed the execution of the OFFLINE
behaviour "+str(behaviour),"err")
+ except Exception,e:
+ self.DEBUG("Failed the execution of the OFFLINE
behaviour "+str(behaviour)+": "+str(e),"err")
return False
else:
self.addBehaviour(behaviour,template)
@@ -1277,7 +1282,6 @@
msg = ACLMessage.ACLMessage()
template = Behaviour.ACLTemplate()
template.setConversationId(msg.getConversationId())
- import uuid
r = str(uuid.uuid4()).replace("-","")
msg.setReplyWith(r)
template.setInReplyTo(r)
@@ -1297,7 +1301,6 @@
msg = ACLMessage.ACLMessage()
template = Behaviour.ACLTemplate()
template.setConversationId(msg.getConversationId())
- import uuid
r = str(uuid.uuid4()).replace("-","")
msg.setReplyWith(r)
template.setInReplyTo(r)
@@ -1317,7 +1320,6 @@
msg = ACLMessage.ACLMessage()
template = Behaviour.ACLTemplate()
template.setConversationId(msg.getConversationId())
- import uuid
r = str(uuid.uuid4()).replace("-","")
msg.setReplyWith(r)
template.setInReplyTo(r)
@@ -1346,7 +1348,6 @@
else:
template.setSender(self.getDF())
template.setConversationId(msg.getConversationId())
- import uuid
r = str(uuid.uuid4()).replace("-","")
msg.setReplyWith(r)
template.setInReplyTo(r)
@@ -1391,7 +1392,6 @@
template.setSender(self.getDF())

template.setConversationId(msg.getConversationId())
- import uuid
r = str(uuid.uuid4()).replace("-","")
msg.setReplyWith(r)
template.setInReplyTo(r)
@@ -1421,7 +1421,6 @@
msg = ACLMessage.ACLMessage()
template = Behaviour.ACLTemplate()
template.setConversationId(msg.getConversationId())
- import uuid
r = str(uuid.uuid4()).replace("-","")
msg.setReplyWith(r)
template.setInReplyTo(r)
@@ -1449,7 +1448,8 @@
if sd.getProperty("outputs"):
s.setOutputs(sd.getProperty("outputs"))
if sd.getProperty("P"):
for p in sd.getProperty("P"): s.addP(p)
- if sd.getProperty("Q"): s.setQ(sd.getProperty("Q"))
+ if sd.getProperty("Q"):
+ for q in sd.getProperty("Q"): s.addQ(q)
s.getDAD().getServices()[0].setType(sd.getType())
for o in sd.getOntologies(): s.setOntology(o)
r.append(s)
@@ -1476,7 +1476,6 @@
msg = ACLMessage.ACLMessage()
template = Behaviour.ACLTemplate()
template.setConversationId(msg.getConversationId())
- import uuid
r = str(uuid.uuid4()).replace("-","")
msg.setReplyWith(r)
template.setInReplyTo(r)
@@ -1492,7 +1491,7 @@
self.runBehaviourOnce(b,t)
return b.result

- def invokeService(self, service):
+ def invokeService(self, service, inputs=None):
"""
invokes a service using jabber-rpc (XML-RPC)
the service template is a DF.Service
@@ -1502,10 +1501,12 @@
self.DEBUG("Service MUST be a DF.Service instance",'error')
return False

- num = str(random.getrandbits(32))
- b = RPC.RPCClientBehaviour(service,num)
- t =
Behaviour.MessageTemplate(Iq(typ='result',queryNS="jabber:iq:rpc",attrs={'id':num}))
- t2 =
Behaviour.MessageTemplate(Iq(typ='error',queryNS="jabber:iq:rpc",attrs={'id':num}))
+ num = str(uuid.uuid4()).replace("-","")
+
+ if inputs==None: inputs = self.KB
+
+ b = RPC.RPCClientBehaviour(service,inputs,num)
+ t = Behaviour.MessageTemplate(Iq(typ="result",attrs={'id':num}))

if self._running:
# Online
=======================================
--- /trunk/spade/DF.py Wed Jul 14 06:10:54 2010
+++ /trunk/spade/DF.py Fri Jul 30 06:42:53 2010
@@ -7,6 +7,7 @@
import BasicFipaDateTime
from SL0Parser import *
from content import ContentObject
+import xmpp
import copy
import thread

@@ -178,9 +179,15 @@
return -1


+ self.DEBUG("Service succesfully deregistered: "+
str(dad),'ok')
reply.setPerformative("inform")
reply.setContent("(done "+self.msg.getContent() + ")")
self.myAgent.send(reply)
+
+ #publish event
+ s = Service(dad=dad).asContentObject()
+ node = xmpp.Node(node=str(s))
+ self.myAgent.publishEvent("DF:Service:Register",node)

return 1

@@ -227,10 +234,16 @@
self.myAgent.DEBUG("FAILURE: Service could not be
deregistered: "+str(err),'error')
return -1

+ self.DEBUG("Service succesfully deregistered: "+
str(dad),'ok')
reply.setPerformative("inform")
reply.setContent("(done "+self.msg.getContent() + ")")
self.myAgent.send(reply)

+ #publish event
+ s = Service(dad=dad).asContentObject()
+ node = xmpp.Node(node=str(s))
+ self.myAgent.publishEvent("DF:Service:UnRegister",node)
+
return 1


@@ -303,11 +316,19 @@
return -1


+ self.DEBUG("Service succesfully registered: "+
str(dad),'ok')
reply.setPerformative("inform")
co_rep =
ContentObject(namespaces={"http://www.fipa.org/schemas/fipa-rdf0#":"fipa:"})
co_rep["fipa:done"] = "true"
reply.setContentObject(co_rep)
self.myAgent.send(reply)
+
+ #publish event
+ self.myAgent.DEBUG("Publishing Event: "+str(dad))
+ s = Service(dad=dad).asContentObject()
+ node = xmpp.Node(node=str(s))
+ self.myAgent.publishEvent("DF:Service:Register",node)
+
return 1

elif co["fipa:action"]["fipa:act"] == "deregister":
@@ -341,6 +362,7 @@
if dad.getServices() == []:
self.myAgent.db_mutex.acquire()
del
self.myAgent.servicedb[dad.getAID().getName()]
+ self.DEBUG("Deleting all agent entries: " +
str(not self.myAgent.servicedb.has_key(dad.getAID().getName())))
self.myAgent.db_mutex.release()
else:
for ss in dad.getServices():
@@ -358,11 +380,18 @@
self.myAgent.DEBUG("FAILURE: internal-error 'could
not deregister service': "+str(err),'error')
return -1

+ self.DEBUG("Service succesfully deregistered: "+
str(dad),'ok')
reply.setPerformative("inform")
co_rep =
ContentObject(namespaces={"http://www.fipa.org/schemas/fipa-rdf0#":"fipa:"})
co_rep["fipa:done"] = "true"
reply.setContentObject(co_rep)
self.myAgent.send(reply)
+
+ #publish event
+ s = Service(dad=dad).asContentObject()
+ node = xmpp.Node(node=str(s))
+ self.myAgent.publishEvent("DF:Service:UnRegister",node)
+
return 1


@@ -725,6 +754,10 @@
mt.setPerformative("request")
mt.setProtocol('fipa-request')
self.addBehaviour(db,Behaviour.MessageTemplate(mt))
+
+ #create service events
+ self.createEvent("DF:Service:Register")
+ self.createEvent("DF:Service:UnRegister")


class DfAgentDescription:
@@ -743,6 +776,8 @@
self.loadSL0(content)

if co:
+ if co.has_key("df-agent-description"):
+ co = co["df-agent-description"]
if co.name:
self.name = AID.aid(co = co.name)
if co.services:
@@ -790,6 +825,7 @@
co["languages"] = copy.copy(self.languages)
if self.scope:
co["scope"] = copy.copy(self.scope)
+
return co


@@ -1241,31 +1277,42 @@

class Service:

- def __init__(self, name=None, owner=None, P=[], Q=[], inputs=[],
outputs=[], description= None, ontology=None, dad = None):
-
- if dad:
- self.setDAD(dad)
-
- else:
- self.name = name
- self.owner = owner
- self.dad = DfAgentDescription()
- self.dad.setAID(owner)
- if ontology: self.dad.addOntologies(ontology)
-
-
- if name!=None:
- sd = ServiceDescription()
- sd.setName(name)
- if owner!=None: sd.setOwnership(owner.getName())
- if P!=[]: sd.addProperty("P",P)
- if Q!=[]: sd.addProperty("Q",Q)
- if inputs!=[]: sd.addProperty("inputs",inputs)
- if outputs!=[]: sd.addProperty("outputs",outputs)
- if ontology!=None: sd.addOntologies(str(ontology))
- if description!=None:
sd.addProperty("description",str(description))
-
- self.dad.addService(sd)
+ def __init__(self, name=None, owner=None, P=[], Q=[], inputs=[],
outputs=[], description= None, ontology=None, dad = None, co = None):
+
+ self.name = name
+ self.owner = owner
+ self.dad = DfAgentDescription()
+ sd = ServiceDescription()
+
+ if co and co.has_key("service"):
+ if co.service.name: name = co.service.name
+ if co.service.owner: owner = AID.aid(co=co.service.owner)
+ if co.service.ontology: ontology = co.service.ontology
+ if co.service.P: P = co.service.P
+ if co.service.Q: Q = co.service.Q
+ if co.service.description: description = co.service.description
+
+ #self.name = name
+ #self.owner = owner
+ #self.dad = DfAgentDescription()
+ if owner: self.dad.setAID(owner)
+ if ontology: self.dad.addOntologies(ontology)
+
+
+
+ if name!=None:
+ sd.setName(name)
+ if owner!=None: sd.setOwnership(owner.getName())
+ if P!=[]: sd.addProperty("P",P)
+ if Q!=[]: sd.addProperty("Q",Q)
+ if inputs!=[]: sd.addProperty("inputs",inputs)
+ if outputs!=[]: sd.addProperty("outputs",outputs)
+ if ontology!=None: sd.addOntologies(str(ontology))
+ if description!=None:
sd.addProperty("description",str(description))
+
+ self.dad.addService(sd)
+
+ if dad: self.setDAD(dad)

def setName(self,name):
self.name = name
@@ -1317,18 +1364,29 @@
services.append(s)
self.dad.services = services

- def getP(self): return self.dad.getServices()[0].getProperty("P")
-
- def setQ(self,Q):
+ def getP(self):
+ if self.dad.getServices()==[]: return []
+ p = self.dad.getServices()[0].getProperty("P")
+ if p==None: return []
+ else: return p
+
+ def addQ(self,Q):
if self.dad.getServices() == []:
self.dad.addService(ServiceDescription())
services = []
for s in self.dad.getServices():
- s.properties['Q']=Q
+ q = s.getProperty("Q")
+ if not q: q=[]
+ q.append(Q)
+ s.addProperty('Q',q)
services.append(s)
- self.dad.services = services
-
- def getQ(self): return self.dad.getServices()[0].getProperty("Q")
+ self.dad.services = services
+
+ def getQ(self):
+ if self.dad.getServices()==[]: return []
+ q = self.dad.getServices()[0].getProperty("Q")
+ if q==None: return []
+ else: return q

def setInputs(self,inputs):
if self.dad.getServices() == []:
@@ -1339,7 +1397,9 @@
services.append(s)
self.dad.services = services

- def getInputs(self): return
self.dad.getServices()[0].getProperty("inputs")
+ def getInputs(self):
+ if self.dad.getServices()==[]: return []
+ return self.dad.getServices()[0].getProperty("inputs")

def setOutputs(self,outputs):
if self.dad.getServices() == []:
@@ -1350,7 +1410,9 @@
services.append(s)
self.dad.services = services

- def getOutputs(self): return
self.dad.getServices()[0].getProperty("outputs")
+ def getOutputs(self):
+ if self.dad.getServices()==[]: return []
+ return self.dad.getServices()[0].getProperty("outputs")

def setDescription(self,description):
if self.dad.getServices() == []:
@@ -1361,12 +1423,16 @@
services.append(s)
self.dad.services = services

- def getDescription(self): return
self.dad.getServices()[0].getProperty("description")
+ def getDescription(self):
+ if self.dad.getServices()==[]: return []
+ return self.dad.getServices()[0].getProperty("description")

def getType(self):
+ if self.dad.getServices()==[]: return []
return self.dad.getServices()[0].getType()

def setType(self, typ):
+ if self.dad.getServices()==[]: return []
self.dad.getServices()[0].setType(typ)

def setDAD(self,dad):
@@ -1391,6 +1457,22 @@
def __str__(self):
return str(self.dad)

+ def __repr__(self):
+ return str(self.asContentObject())
+
+ def asContentObject(self):
+
+ co = ContentObject()
+ co["service"]=ContentObject()
+ if self.getName()!=None: co.service["name"] = self.getName()
+ if self.getOwner()!=None: co.service["owner"] =
self.getOwner().asContentObject()
+ if self.getOntology()!=[]: co.service["ontology"] =
self.getOntology()
+ if self.getP()!=[]: co.service["P"] = self.getP()
+ if self.getQ()!=[]: co.service["Q"] = self.getQ()
+ if self.getDescription()!=None: co.service["description"] =
self.getDescription()
+
+ return co
+
def asHTML(self):
s = '<table class="servicesT" cellspacing="0">'
s += '<tr><td class="servHd">Name</td><td
class="servBodL">'+self.getName()+'</td></tr>'
=======================================
--- /trunk/spade/RPC.py Fri Jul 2 08:25:14 2010
+++ /trunk/spade/RPC.py Fri Jul 30 06:42:53 2010
@@ -2,6 +2,8 @@
import xmlrpclib
import xmpp

+import types
+
class RPCServerBehaviour(Behaviour.EventBehaviour):

def _process(self):
@@ -10,15 +12,15 @@
if self.msg != None:
if self.msg.getType() == "set":

- self.myAgent.DEBUG("RPC request received: "+str(self.msg))
+ self.myAgent.DEBUG("RPC request
received: "+str(self.msg),'info',"rpc")

mc = self.msg.getTag('query')
params, name = xmlrpclib.loads("<?xml version='1.0'?>%s" %
str(mc))
name=name.lower()
- self.myAgent.DEBUG("Params processed: name="+name+"
params="+str(params) + " in " + str(self.myAgent.RPC.keys()))
+ self.myAgent.DEBUG("Params processed: name="+name+"
params="+str(params) + " in " + str(self.myAgent.RPC.keys()),"info","rpc")

if not self.myAgent.RPC.has_key(name):
- self.myAgent.DEBUG("RPC: 404 method not found",'error')
+ self.myAgent.DEBUG("RPC: 404 method not
found",'error',"rpc")
xmlrpc_res = xmlrpclib.dumps(
xmlrpclib.Fault(404, "method not found"))
reply = self.msg.buildReply("error")

reply.setQueryPayload([xmpp.simplexml.XML2Node(xmlrpc_res)])
@@ -29,12 +31,13 @@

service,methodCall = self.myAgent.RPC[name]

- self.myAgent.DEBUG("service and method: "+ str(service)
+ " --> " + str(methodCall))
-
- self.myAgent.DEBUG("Comparing service.getP(): "+
str(service.getP()) + " with params--> " + str(params))
+ self.myAgent.DEBUG("service and method: "+ str(service)
+ " --> " + str(methodCall),"info","rpc")
+
+ self.myAgent.DEBUG("Comparing service.getP(): "+
str(service.getP()) + " with params--> " + str(params),"info","rpc")
+ ps = params[0].keys()
for p in service.getP():
- if str(p) not in str(params):
- self.myAgent.DEBUG("RPC: 500 missing
precondition: "+str(p)+ " is not in "+str(params),'error')
+ if str(p) not in ps:
+ self.myAgent.DEBUG("RPC: 500 missing
precondition: "+str(p)+ " is not in "+str(params),'error',"rpc")
xmlrpc_res = xmlrpclib.dumps(
xmlrpclib.Fault(500, "missing precondition"))
reply = self.msg.buildReply("error")

reply.setQueryPayload([xmpp.simplexml.XML2Node(xmlrpc_res)])
@@ -44,18 +47,17 @@
return

try:
- self.myAgent.DEBUG("Calling method "+str(methodCall)+"
with params "+str(params))
+ self.myAgent.DEBUG("Calling method "+str(methodCall)+"
with params "+str(params),"info","rpc")
if params == (None,):
result = methodCall()
else:
- result = methodCall(params)
- xmlrpc_res = xmlrpclib.dumps( tuple([result]) ,
methodresponse=True,allow_none=True)
- reply = self.msg.buildReply("result")
-
reply.setQueryPayload([xmpp.simplexml.XML2Node(xmlrpc_res)])
- self.myAgent.send(reply)
- self.myAgent.DEBUG("RPC: method succesfully served: "+
str(reply),'ok')
+ args=""
+ for k,v in params[0].items():
+ args+=str(k)+"="+str(v)+","
+ args=args[:-1]
+ result = eval("methodCall("+args+")")
except Exception,e:
- self.myAgent.DEBUG("RPC: 500 method
error: "+str(e),'error')
+ self.myAgent.DEBUG("RPC: 500 method
error: "+str(e),'error',"rpc")
xmlrpc_res = xmlrpclib.dumps(
xmlrpclib.Fault(500, "method error: "+str(e)))
reply = self.msg.buildReply("error")

reply.setQueryPayload([xmpp.simplexml.XML2Node(xmlrpc_res)])
@@ -63,63 +65,111 @@
reply.setFrom(self.myAgent.JID)
self.myAgent.send(reply)
return
+
+ #Check postconditions
+ try:
+ fail=False
+ outputs={}
+ if type(result) == types.DictType:
+ for q in service.getQ():
+ if q not in result.keys():
+ fail=True
+ break
+ else: outputs[q]=result[q]
+ params = (outputs,)
+ else:
+ self.myAgent.DEBUG("RPC method MUST return a
dict.",'error',"rpc")
+ fail=True
+ except:
+ fail=True
+ if fail:
+ self.myAgent.DEBUG("RPC: 500 missing
postcondition: "+str(service.getQ()),'error',"rpc")
+ xmlrpc_res = xmlrpclib.dumps(
xmlrpclib.Fault(500, "missing postcondition"))
+ reply = self.msg.buildReply("error")
+
reply.setQueryPayload([xmpp.simplexml.XML2Node(xmlrpc_res)])
+ reply.setType("result")
+ reply.setFrom(self.myAgent.JID)
+ self.myAgent.send(reply)
+ return
+
+ #Everything was ok. Return results
+ xmlrpc_res = xmlrpclib.dumps( params ,
methodresponse=True,allow_none=True)
+ reply = self.msg.buildReply("result")
+
reply.setQueryPayload([xmpp.simplexml.XML2Node(xmlrpc_res)])
+ self.myAgent.send(reply)
+ self.myAgent.DEBUG("RPC: method succesfully served: "+
str(reply),'ok',"rpc")
+

else:
- self.myAgent.DEBUG("RPCServerBehaviour returned with no
message", "warn")
+ self.myAgent.DEBUG("RPCServerBehaviour returned with no
message", "warn","rpc")

class RPCClientBehaviour(Behaviour.OneShotBehaviour):

- def __init__(self, service,num):
+ def __init__(self, service, inputs, num):
Behaviour.OneShotBehaviour.__init__(self)
self.service = service
+ self.inputs = inputs
self.num = num

def _process(self):
self.result=None

#send IQ methodCall
- params = None
+ params = {}
ps = None
ps = self.service.getP()
#self.service.getDAD().getServices()[0].getProperty("P")
- params = tuple(ps)
- self.myAgent.DEBUG("Params processed: "+str(params))
+ for p in ps: #check all Preconditions are True
+ if not p in self.inputs.keys():
+ #if "askBelieve" in dir(self.myAgent):
+ # if not self.myAgent.askBelieve(p):
+ self.myAgent.DEBUG("Precondition "+ str(p) + " is not
satisfied. Can't call method "+self.service.getName(),'error',"rpc")
+ self.result=False
+ return
+ else: params[p] = self.inputs[p]
+
+ #params = tuple(ps)
+ self.myAgent.DEBUG("Params processed: "+str(params),"info","rpc")

#if agent is a BDIAgent check preconditions
- if "askBelieve" in dir(self.myAgent):
- for p in params:
- if not self.myAgent.askBelieve(p):
- self.result=False
- self.myAgent.DEBUG("Precondition "+ str(p) + " is not
satisfied. Can't call method "+self.service.getName(),'error')
- return
-
- payload = xmlrpclib.dumps( params ,
methodname=self.service.getName(),allow_none=True)
- self.myAgent.DEBUG("Marshalled "+payload)
+ #if "askBelieve" in dir(self.myAgent):
+ # for p in params:
+ # if not self.myAgent.askBelieve(p):
+ # self.result=False
+ # self.myAgent.DEBUG("Precondition "+ str(p) + " is not
satisfied. Can't call method "+self.service.getName(),'error',"rpc")
+ # return
+
+ payload = xmlrpclib.dumps( (params,) ,
methodname=self.service.getName(),allow_none=True)
+ self.myAgent.DEBUG("Marshalled "+payload,"info","rpc")
payload_node = xmpp.simplexml.XML2Node(payload)
to = xmpp.protocol.JID(self.service.getOwner().getName())
iq =
xmpp.protocol.Iq(typ='set',queryNS="jabber:iq:rpc",frm=self.myAgent.JID,to=to,attrs={'id':self.num})
iq.setQueryPayload([payload_node])
- self.myAgent.DEBUG("Calling method with: "+str(iq))
+ self.myAgent.DEBUG("Calling method with: "+str(iq),"info","rpc")
self.myAgent.send(iq)
- self.myAgent.DEBUG(self.service.getName() + " method called.
Waiting for response",'ok')
+ self.myAgent.DEBUG(self.service.getName() + " method called.
Waiting for response",'ok',"rpc")

#receive IQ methodResponse
self.msg = self._receive(True)
if self.msg != None:
- self.myAgent.DEBUG("Response received for
method "+self.service.getName()+":" +str(self.msg),'ok')
+ self.myAgent.DEBUG("Response received for
method "+self.service.getName()+":" +str(self.msg),'ok',"rpc")
if self.msg.getType() == "result":
try:
params, method = xmlrpclib.loads("<?xml
version='1.0'?>%s" % self.msg)
- self.DEBUG("Returned params "+str(params),'ok')
- self.result = [params[0]]
+ self.DEBUG("Returned params "+str(params),'ok',"rpc")
+ self.result = params[0]
#if agent is a BDIAgent add result params as
postconditions
- if "addBelieve" in dir(self.myAgent):
- for q in params: #[0]:
- self.myAgent.addBelieve(q)
- return [params[0]]
+ #if "addBelieve" in dir(self.myAgent):
+ for k,q in self.result.items(): #[0]:
+ #self.myAgent.addBelieve(q)
+ self.myAgent.KB[k]=q
+ return self.result
except Exception,e:
- self.myAgent.DEBUG("Error executing RPC
service: "+str(e))
+ self.myAgent.DEBUG("Error executing RPC
service: "+str(e),"error","rpc")
self.result = False
return False
+ else:
+ self.result = False
+ return False
else:
self.result = False
return False
=======================================
--- /trunk/spade/pubsub.py Fri Jul 16 10:41:53 2010
+++ /trunk/spade/pubsub.py Fri Jul 30 06:42:53 2010
@@ -1,4 +1,4 @@
-from spade.Behaviour import MessageTemplate, OneShotBehaviour
+from Behaviour import MessageTemplate, OneShotBehaviour

from xmpp.protocol import *
from xmpp.simplexml import Node
@@ -39,8 +39,12 @@
iq.setID(id)
b = self._sendAndReceiveBehav(iq,getContents)

- self.myAgent.addBehaviour(b,t)
- b.join()
+ if self.myAgent._running:
+ self.myAgent.addBehaviour(b,t)
+ b.join()
+ else:
+ self.myAgent.runBehaviourOnce(b,t)
+
return b.result

class _sendAndReceiveBehav(OneShotBehaviour):
@@ -49,6 +53,8 @@
self.iq = iq
self.getContents = getContents
self.timeout = 15
+ self.result = (None,None)
+
def _process(self):
#print 'Sending ', str(self.iq)
self.myAgent.send(self.iq)
=======================================
--- /trunk/xmppd/modules/pubsub.py Fri Jul 16 10:41:53 2010
+++ /trunk/xmppd/modules/pubsub.py Fri Jul 30 06:42:53 2010
@@ -42,8 +42,7 @@
self.items_timestamp[id] =
datetime.utcnow().isoformat().split('.')[0] + 'Z'
#print self.items_timestamp[id], self.items[id], id
except Exception,e:
- print 'Exception in addItem'
- print e
+ self.DEBUG('Exception in addItem: '+str(e),"error")

def __repr__(self):
return 'PSNode(%s, %s)' % (self.id, self.type)
@@ -61,6 +60,7 @@

for ns in (NS_PUBSUB, NS_PUBSUB_ERRORS, NS_PUBSUB_EVENTS,
NS_PUBSUB_OWNER):
server.Dispatcher.RegisterHandler('iq', self.PubSubIqHandler,
typ='set', ns=ns, xmlns=NS_CLIENT)
+ server.Dispatcher.RegisterHandler('iq', self.PubSubIqHandler,
typ='set', ns=ns, xmlns=NS_COMPONENT_ACCEPT)

def _getIqError(self, iq, name, specific=None):
if specific is None:
@@ -95,8 +95,7 @@
s = self._owner.getsession(jid)
s.send(msg)
except Exception,e:
- print 'Exception in sendItem'
- print e
+ self.DEBUG('Exception in sendItem: '+str(e),"error")


#TODO: If we had a maximum, we should remove the first item here.
Doing a FIFO.
@@ -152,8 +151,12 @@
# Add node
#print self.nodes
self.DEBUG('Creating node: %s' % create_node, 'info')
+
+ id = stanza.getAttr('id')
+ if isinstance(stanza,Protocol): stanza = Iq(node=stanza)

iq = stanza.buildReply('result')
+ if id: iq.setID(id)
pubsub_node = Node(tag='pubsub', attrs={'xmlns':NS_PUBSUB})
pubsub_node.addChild(node=create_node)
iq.addChild(node=pubsub_node)
@@ -368,4 +371,4 @@
except NodeProcessed:
raise NodeProcessed
except Exception,e:
- print e
+ self.DEBUG("Exception in PubSub Handler: " + str(e),"error")

Reply all
Reply to author
Forward
0 new messages