[MOBY-guts] biomoby commit

Yan Wong yanwong at pub.open-bio.org
Fri Feb 4 12:58:25 UTC 2005


yanwong
Fri Feb  4 07:58:24 EST 2005
Update of /home/repository/moby/moby-live/Python/bioMoby
In directory pub.open-bio.org:/tmp/cvs-serv29563

Modified Files:
	mobyClient.py mobyDataTypes.py mobyMarshal.py mobyRegister.py 
	mobyService.py 
Log Message:


moby-live/Python/bioMoby mobyClient.py,1.3,1.4 mobyDataTypes.py,1.11,1.12 mobyMarshal.py,1.4,1.5 mobyRegister.py,1.3,1.4 mobyService.py,1.3,1.4
===================================================================
RCS file: /home/repository/moby/moby-live/Python/bioMoby/mobyClient.py,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- /home/repository/moby/moby-live/Python/bioMoby/mobyClient.py	2005/02/01 08:52:15	1.3
+++ /home/repository/moby/moby-live/Python/bioMoby/mobyClient.py	2005/02/04 12:58:24	1.4
@@ -32,7 +32,7 @@
     def call_method(self, method, arguments):
         """It invokes a remote method of the bioMoby server
         """
-
+        
         #soapaction is necessary, if not, remote calls don't work
         self.server.soapaction=self.ns+"#"+method
         
@@ -48,21 +48,21 @@
             it returns a dictionary {'name':descriptions', ...}
         """
         result={}
-
+        
         #Remote call of the method on the Moby server
         xmlt=self.call_method("retrieveObjectNames", None)
-
+        
         doc=parseString(xmlt)
         
         for node in doc.getElementsByTagName("Object"):
             objectName=node.getAttribute("name")
-
+            
             for subNode in node.childNodes:
                 if subNode.nodeType==subNode.ELEMENT_NODE:
                     for ssNode in subNode.childNodes:
                         if ssNode.nodeType==ssNode.CDATA_SECTION_NODE:
                             result[objectName]=ssNode.nodeValue
-
+        
         return result
 
     def retrieveObjectDefinition(self, objectName):
@@ -72,10 +72,10 @@
         "urn:lsid:biomoby.org:objectrelation:hasa":"HASA",
         "urn:lsid:biomoby.org:objectrelation:has":"HAS"
         }
-
+        
         definition={}
         definition["Relationship"]={}
-
+        
         xmlinput="<retrieveObjectDefinition><objectType>"+objectName+"</objectType></retrieveObjectDefinition>"
         doc=parseString(self.call_method("retrieveObjectDefinition", xmlinput))
         
@@ -85,7 +85,7 @@
                 for elem in child.childNodes:
                     if elem.nodeType==elem.ELEMENT_NODE and elem.nodeName=="objectType" and elem.firstChild:
                         definition["Relationship"][dc[child.getAttribute("relationshipType")]].append((elem.getAttribute("articleName"), elem.firstChild.nodeValue))
-
+            
             elif child.nodeType==child.ELEMENT_NODE:
                 if child.firstChild:
                         definition[str(child.nodeName)]=child.firstChild.nodeValue
@@ -104,23 +104,22 @@
         result=[]
         
         xmlt=self.call_method("retrieveServiceProviders", None)
-
+        
         doc=parseString(xmlt)
         
         for node in doc.getElementsByTagName("serviceProvider"):
             serviceProviderName= node.getAttribute("name")
             result.append(serviceProviderName)
-            
-        return result
-
         
+        return result
+    
     def retrieveNamespaces(self):
         """Retrieves a list of namespaces as a dictionary
         """
         result={}
         
         xmlt=self.call_method("retrieveNamespaces", None)
-
+        
         doc=parseString(xmlt)
         
         for node in doc.getElementsByTagName("Namespace"):
@@ -130,9 +129,8 @@
                     for ssNode in subNode.childNodes:
                         if ssNode.nodeType==ssNode.CDATA_SECTION_NODE:
                             result[ns]=ssNode.nodeValue
-
+        
         return result
-            
 
     def retrieveServiceNames(self):
         """Retrieves a list of service's names as a dictionary {'name':'URI'}
@@ -148,87 +146,84 @@
             authURI=node.getAttribute("authURI")
             
             result[serviceName]=authURI
-   
+        
         return result
 
-
     def retrieveServiceTypes(self):
         """Retrieves a list of service's types as a dictionary {'Name':'Description'}
         """        
         result={}
         
         xmlt=self.call_method("retrieveServiceTypes", None)
-
+        
         doc=parseString(xmlt)
         
         for node in doc.getElementsByTagName("serviceType"):
             st=node.getAttribute("name")      
-
+            
             for subNode in node.childNodes:
                 if subNode.nodeType==subNode.ELEMENT_NODE:
                     for ssNode in subNode.childNodes:
                         if ssNode.nodeType==ssNode.CDATA_SECTION_NODE:
                             result[st]=ssNode.nodeValue
-    
+        
         return result
-
-
+        
     def retrieveServiceWSDLByAuthority(self, serviceName, authority):
         """Retrieves a WSDL from moby from a service name and a URI
         """
         xmlinput="<retrieveService><Service authURI=\"" + authority + "\" serviceName=\"" + serviceName + "\"/></retrieveService>"
         
         xmlt=self.call_method("retrieveService", xmlinput)
-
+        
         doc=parseString(xmlt)
         
         service=doc.firstChild
         wsdl=service.firstChild.nodeValue
-
+        
         return wsdl
-
-
+        
     def retrieveServiceWSDL(self, serviceName):
         """Retrieves a WSDL from the name of a service
         """
         m=self.retrieveServiceNames()
         return self.retrieveServiceWSDLByAuthority(serviceName, m[serviceName])
-
+        
     def retrieveServiceTypesRelationships(self, serviceType, expand):
         """Retrieves the list of service's type's relationships
         """
         result=[]
         
-
+        
         xmlinput="<Relationship><serviceType>" + serviceType + "</serviceType><relationshipType>ISA</relationshipType><expandRelationship>" + `expand` + "</expandRelationship></Relationship>"
         
         xmlt=self.call_method("Relationships", xmlinput)
-
+        
         doc=parseString(xmlt)
         
         for node in doc.getElementsByTagName("Relationship"):
             for serviceType in node.childNodes:
                 if serviceType.nodeType==serviceType.ELEMENT_NODE:
                     result.append(serviceType.firstChild.nodeValue)
-                    
+        
         return result
-    
+        
     def retrieveDataTypesRelationships(self, dataTypeName):
         """Retrieves only ISA relationships
         """
-
+        
         return self.retrieveDataTypesRelationsByType(dataTypeName, 'ISA')
-
+        
     def retrieveDataTypesRelationsByType(self, dataTypeName, relationType):
         """Retrieves data types relationships
         """
-
+        
         result={}
         
         xmlinput="<Relationship><objectType>" + dataTypeName + "</objectType><relationshipType>"+relationType+"</relationshipType><relationshipType>HASA</relationshipType><relationshipType>HAS</relationshipType><expandRelationship>1</expandRelationship></Relationship>"
-
+        
         xmlt=self.call_method("Relationships", xmlinput)
-
+        
         doc=parseString(xmlt)
         
         for node in doc.getElementsByTagName("Relationship"):
@@ -239,15 +234,14 @@
                     relationTypeResults.append(ssNode.firstChild.nodeValue)
                     
             result[relationType]=relationTypeResults
-
-        return result
         
+        return result
         
     def findService(self, mobyQuery):
         """Finds a service from a set of queries
         """
         from mobyService import ServiceQuery ,ServiceList
-
+        
         if mobyQuery.__class__==ServiceQuery:
             xmlInput="<findService>"+str(mobyQuery)+"</findService>"
             
@@ -262,4 +256,4 @@
     def __init__(self, url="http://mobycentral.cbr.nrc.ca/cgi-bin/MOBY05/mobycentral.pl", ns="http://mobycentral.cbr.nrc.ca/MOBY/Central"):
         """Constructor for class Client
         """
-        Central.__init__(self, url, ns)
+        Central.__init__(self, url, ns)
\ No newline at end of file

===================================================================
RCS file: /home/repository/moby/moby-live/Python/bioMoby/mobyDataTypes.py,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- /home/repository/moby/moby-live/Python/bioMoby/mobyDataTypes.py	2005/02/02 16:52:31	1.11
+++ /home/repository/moby/moby-live/Python/bioMoby/mobyDataTypes.py	2005/02/04 12:58:24	1.12
@@ -27,12 +27,12 @@
         self.articleName=articleName
         self.value=value
         self.__isSecondary__=True
-        
+    
     def toMoby(self):
         """Returns the object as a XML
         """
         return "<moby:Parameter moby:articleName='"+self.articleName+"'><moby:value>"+str(self.value)+"</moby:value></moby:Parameter>"
-            
+    
     def __str__(self):
         """Return the Parameter in its XML form
         """
@@ -42,7 +42,7 @@
         """Print the XML on the python command line.
         """
         return self.toMoby()
-            
+    
     def fromMoby(self, xml):
         """Get the attributes from a XML string
         """
@@ -55,9 +55,9 @@
         l=xmlelt.getElementsByTagName("value")
         if len(l)==0:
             l=xmlelt.getElementsByTagName("moby:value")
-
+            
             self.value=l[0].firstChild.nodeValue
-        
+
 class MobyGeneric(object):
     """A Generic object (to use with the Marshaller)
     """
@@ -71,7 +71,7 @@
         
         for name, value in kw.items():
             setattr(self, name, value)
-        
+
 class MobyObject(MobyGeneric):
     """Define a Moby XML Object
        It has methods toMoby and fromMoby 
@@ -86,7 +86,7 @@
         self.__PIB__=[]
         
         self.content=content
-        
+
     
     def toMoby(self):
         """Deserializes the content in XML api
@@ -155,7 +155,7 @@
         result.append("</%s:%s>"%(self.__prefix__, self.__tag__))
         
         return "".join(result)
-        
+    
     def fromMoby(self, xml):
         """Deserialization method
         """
@@ -219,14 +219,14 @@
                 self.content.append(child.nodeValue)
                 
         self.content="".join(self.content)
-        
+    
 
     def __str__(self):
         return self.toMoby()
-        
+    
     def __repr__(self):
         return self.toMoby()
-        
+    
 
 class MobyXref(MobyObject):
     """Describes an Xref
@@ -237,7 +237,7 @@
         self.serviceName=serviceName
         self.evidenceCode=evidenceCode
         self.xrefType=xrefType
-        
+    
     def toMoby(self):
         """Serialize the Xref object
         """
@@ -269,7 +269,7 @@
     def fromMoby(self, xml):
         MobyObject.fromMoby(self, xml)
         self.content = int(self.content)
-        
+
 class MobyFloat(MobyObject):
     """Serialize/deserialize floating point numbers
     """
@@ -279,7 +279,7 @@
     def fromMoby(self, xml):
         MobyObject.fromMoby(self, xml)
         self.content=float(self.content)
-        
+
 
 class MobyString(MobyObject):
     """String Moby object
@@ -304,7 +304,7 @@
         """return the XML form of the Moby Content object
         """
         return self.toMoby()
-        
+    
     def toMoby(self):
         """The XML reprentation of the content
         """
@@ -408,12 +408,12 @@
                     data.append(p)
                     
             self.queryData[queryID]=data
-            
+    
     def __getitem__(self, key):
         """Get a query from his name
         """
         return self.queryData[key]
-        
+    
     def __setitem__(self, key, item):
         """Store a query in the dictionary
         """
@@ -423,12 +423,12 @@
         """Return the number of elements inside the dictionary
         """
         return len(self.queryData)
-        
+    
     def keys(self):
         """Return all queries's name
         """
         return self.queryData.keys()
-        
+    
     def collectionToQueries(self, aCollection):
         """Turn a collection of object into a set of queries
         """
@@ -441,7 +441,7 @@
             queries["%s-%s"%(queryName, queryID)]=aSimple
             
         return queries
-        
+    
     def getObject(self, queryName, objectName):
         """Get an object from a query with its name
         """
@@ -449,14 +449,14 @@
         
         for obj in filter(filterfunc, self.queryData[queryName]):
             return obj
-            
+    
     def getObjects(self, queryName):
         """Retrieve objects from a query
         """
         filterfunc=lambda obj: not hasattr(obj, "__isSecondary__")
         
         return filter(filterfunc, self.queryData[queryName])
-        
+    
     def getParameters(self, queryName):
         """Retrieve parameters from a query
         """
@@ -467,7 +467,7 @@
             result[param.articleName]=param.value
                 
         return result
-        
+    
     def getParameter(self, queryName, parameterName):
         """Retrieve a parameter from a query and his name
         """
@@ -477,7 +477,7 @@
         
         if l:
             return l[0]
-        
+    
     def __repr__(self):
         """put the xml of the Content
         """

===================================================================
RCS file: /home/repository/moby/moby-live/Python/bioMoby/mobyMarshal.py,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- /home/repository/moby/moby-live/Python/bioMoby/mobyMarshal.py	2005/02/01 08:52:15	1.4
+++ /home/repository/moby/moby-live/Python/bioMoby/mobyMarshal.py	2005/02/04 12:58:24	1.5
@@ -24,11 +24,11 @@
         """
         if type(value).__name__=='NoneType':
             return ""
-
+        
         tvalue=type(value).__name__
-
+        
         method="m_"+tvalue
-
+        
         if hasattr(value, "toMoby"):
             return value.toMoby()
         
@@ -36,15 +36,16 @@
             return getattr(self,method)(value,articleName=articleName)
         
         return self._compoundObject(value, articleName=articleName)
-            
-        
+    
+    
     def m_str(self, value, articleName=""):
         """Return a string as itself"""
         from bioMoby.mobyDataTypes  import MobyString
         m=MobyString(content=value, articleName=articleName)
         del MobyString
-        return str(m)
         
+        return str(m)
+    
     def m_unicode(self, value, articleName=""):
         """Turn a unicode string into a mobyString object
         """
@@ -54,7 +55,7 @@
         """Return a string object into a mobyString object
         """
         return self.m_str(value, articleName)
-        
+    
     def m_int(self, value, namespace="", id="", articleName=""):
         """Turn an integer into a Moby XML object
         """
@@ -62,7 +63,7 @@
         m=MobyInteger(value, namespace=namespace, id=id, articleName=articleName)
         
         return m.toMoby()
-        
+    
     def m_float(self, value, namespace="", id="", articleName=""):
         """Turn a float into a Moby XML object
         """
@@ -70,7 +71,7 @@
         m=MobyFloat(value, namespace=namespace, id=id, articleName=articleName)
         
         return m.toMoby()
-        
+    
     def m_list(self, value, articleName=""):
         """Turn a list into a Moby XML object
         """
@@ -96,8 +97,7 @@
         result.append('</moby:Dict>')
         
         return "".join(result)
-
-            
+    
     def m_tuple(self, value, namespace="", articleName=""):
         """Define a tuple as a Moby Object
         """
@@ -109,7 +109,7 @@
         result.append('</moby:Tuple>')
         
         return "".join(result)
-
+    
     def _compoundObject(self, value, articleName=""):
         """transforms an object and all properties into a XML
         """
@@ -140,7 +140,7 @@
             header.append(">")
             
         result.append(" ".join(header))
-
+        
         if properties:
             result.append("".join(properties))            
         
@@ -149,16 +149,14 @@
         
         if properties:
             result.append("</%s>"%tagName)
-
-
-        return r"".join(result)
-        
         
+        return r"".join(result)
+    
     def dumps(self, value, articleName=""):
         """Serialize the object into a Moby XML object
         """
         return self._marshal(value, articleName)
-        
+    
 
 class MobyUnmarshaller:
     """Transform an XML into a Moby Python Object
@@ -168,24 +166,24 @@
         """ Cleaning the name of the object
         """
         import re
-
+        
         aName=str(aName)
         
         if aName=="":
             return ""
-
+        
         if aName=="namespace" or aName=="id" or aName=='content':
             return aName
-
+        
         r=re.compile("\W")
-    
+        
         t=r.split(aName)
-    
+        
         for i in range(0,len(t)):
             t[i]=str.upper(t[i][0])+t[i][1:]
-
+        
         del re
-
+        
         return "".join(t)
 
     def loadn(self, xmlNode):
@@ -198,7 +196,7 @@
         
         #Try to see if this object got a deserializer
         object2build=self._cleanName(nn)
-
+        
         objectName=str.upper(object2build[0])+object2build[1:]
         
         if hasattr(bioMoby.mobyDataTypes, "Moby%s"%objectName):
@@ -224,14 +222,12 @@
 #            from bioMoby.mobyExceptions import EInvalidMobyXML    
             
 #            raise EInvalidMobyXML
-
-        
+    
     def loads(self, xmlString):
         """ Deserializes an xml string and return a bioMoby-Python object
         """
         if xmlString=="":
             return None    
-
 #        _typesmodule=["bioMoby.mobyDataTypes", "bioMoby.ontology"]
             
         doc=parseString(xmlString)
@@ -254,15 +250,16 @@
             return int(value.firstChild.nodeValue.replace("\n","").replace("\t","").replace(" ",""))
         else:
             return 0
-            
+    
     def m_Float(self, value):
         """Turn a Float XML element into a float number
         """
         value.normalize()
         if value.firstChild:
             return float(value.firstChild.nodeValue.replace("\n","").replace("\t","").replace(" ",""))
+        
         return 0.0
-            
+    
     def m_String(self, value):
         """Turn a Moby XML String element into a String object
         """
@@ -273,9 +270,8 @@
         for aChild in value.childNodes:
             if aChild.nodeType==aChild.TEXT_NODE or aChild.nodeType==aChild.CDATA_SECTION_NODE:
                 cnt.append(aChild.wholeText)
-                
-        return        r"".join(cnt)
         
+        return        r"".join(cnt)
 
     def m_Object(self, value):
         """Turn any XML into a generic object
@@ -283,7 +279,7 @@
         filterFunc= lambda x: x.nodeType==x.ELEMENT_NODE
         
         typeName="GMoby%s"%str(value.localName)
-
+        
         from bioMoby.mobyDataTypes import MobyGeneric
         
         NewType=type(typeName, (MobyGeneric,), {})
@@ -296,24 +292,24 @@
         for tupleAttribute in value.attributes.itemsNS():
             #First item, second field:
             setattr(anObject, str(tupleAttribute[0][1]), str(tupleAttribute[1]))
-
+        
         i=0    
         for elem in filter(filterFunc, value.childNodes):
             methodName="m_%s"%str(elem.localName)
-
+            
             articleName=elem.getAttribute("moby:articleName")
             
             if not articleName:
                 articleName=elem.getAttribute("articleName")
-                
+            
             if not articleName:
                 articleName="attribute_%s"%i
-                
+            
             if hasattr(self, methodName):
                 prop=getattr(self, methodName)(elem)
             else:
-                    prop=self.m_Object(elem)
-                
+                prop=self.m_Object(elem)
+            
             if hasattr(anObject, articleName):
                 t=prop
                 if not type(getattr(anObject, articleName)) is list:
@@ -323,17 +319,17 @@
             else:
                 setattr(anObject, articleName, prop)
             i+=1
-
+        
         content=[]
-
+        
         isContentNode= lambda x: x.nodeType==x.TEXT_NODE or x.nodeType==x.CDATA_SECTION_NODE
         
         for elem in filter(isContentNode, value.childNodes):
             content.append(str(elem.nodeValue))
-            
+        
         if content:
             anObject.content(r"".join(content))
-            
+        
         return anObject
 
     def m_MobyContent(self, value):
@@ -347,5 +343,4 @@
         
         del MobyContent
         
-        return mc
-        
+        return mc
\ No newline at end of file

===================================================================
RCS file: /home/repository/moby/moby-live/Python/bioMoby/mobyRegister.py,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- /home/repository/moby/moby-live/Python/bioMoby/mobyRegister.py	2005/02/01 08:52:15	1.3
+++ /home/repository/moby/moby-live/Python/bioMoby/mobyRegister.py	2005/02/04 12:58:24	1.4
@@ -20,10 +20,10 @@
         self.id=""
         self.message=""
         self.RDF=""
-
+        
         #Parse the document, retrieve the success, id, message and RDF fields
         doc=parseString(xmlInput)
-
+        
         if len(doc.getElementsByTagName("success")[0].childNodes)>0:
             self.success=int(doc.getElementsByTagName("success")[0].childNodes[0].nodeValue)
         if len(doc.getElementsByTagName("id")[0].childNodes)>0:
@@ -35,17 +35,17 @@
                 self.RDF=doc.getElementsByTagName("RDF")[0].firstChild.toprettyxml()
         except:
             pass
-
+    
     def __str__(self):
         """Return the moby xml of the instance
         """
         return "<MOBYRegistration><id>"+self.id+"</id><success>"+`self.success`+"</success><message><![CDATA["+self.message+"]]></message><RDF>"+self.RDF+"</RDF></MOBYRegistration>"
-        
+    
     def toTuple(self):
         """return the  tuple form of  the instance
         """
         return (self.id, self.success,  self.message, self.RDF)
-        
+    
     def isSuccess(self):
         """Indicate whether the registration was successful or not
         """
@@ -79,7 +79,7 @@
         GeneralInformations.__init__(self, contact=contactEmail, authURI=authURI, description=description)
         self.relationship=relationship
         self.serviceType=serviceType
-        
+    
     def __str__(self):
         """Return the instance as a Moby XML
         """
@@ -88,22 +88,21 @@
         result.append("<authURI>"+self.authURI+"</authURI>")
         result.append("<Description><![CDATA["+self.description+"]]></Description>")
         result.append('<Relationship relationshipType="'+self.relationship[0]+'">')
-    
+        
         for serviceType in self.relationship[1]:
             result.append('<serviceType>'+serviceType+'</serviceType>')
-
+        
         result.append("</Relationship>")
-            
-
-        return "".join(result)
-
         
+        
+        return "".join(result)
+    
     def register(self):
         """Register the service's type on the moby server
         """
         xmlinput="<registerServiceType>"+str(self)+"</registerServiceType>"
         return RegistrationObject(self.central.call_method("registerServiceType", xmlinput))
-        
+    
     def deregister(self):
         """Deregister the service's Type on moby
         """
@@ -126,7 +125,7 @@
         """
         result=["<objectType>"+self.objectType+"</objectType>"]
         result.append("<Description><![CDATA["+self.description+"]]></Description>")
-                
+        
         for relationship in self.relationships:
             result.append('<Relationship relationshipType="'+relationship[0]+'">')
             
@@ -134,12 +133,11 @@
                 result.append('<objectType articleName="'+objectTypeKey+'">'+relationship[1][objectTypeKey]+'</objectType>')
                 
             result.append("</Relationship>")
-
+        
         result.append("<authURI>"+self.authURI+"</authURI>")
         result.append("<contactEmail>"+self.contact+"</contactEmail>")
-
+        
         return "".join(result)
-
     
     def register(self):
         """Register the  object's class
@@ -160,12 +158,12 @@
     def __init__(self, namespaceType="", contact="", authURI="", description=""):
         GeneralInformations.__init__(self, contact=contact, authURI=authURI,description=description)
         self.namespaceType=namespaceType
-
+    
     def __str__(self):
         """return the XML of the name space
         """
         return "<namespaceType>"+self.namespaceType+"</namespaceType><contactEmail>"+self.contact+"</contactEmail><authURI>"+self.authURI+"</authURI><Description><![CDATA["+self.description+"]]></Description>"
-
+    
     def register(self):
         """Register the namespace on a Moby server
         """
@@ -176,4 +174,4 @@
         """Deregister the namespace
         """
         xmlinput="<deregisterNamespace>"+self.namespaceType+"</deregisterNamespace>"
-        return RegistrationObject(self.central.call_method("deregisterNamespace", xmlinput))
+        return RegistrationObject(self.central.call_method("deregisterNamespace", xmlinput))
\ No newline at end of file

===================================================================
RCS file: /home/repository/moby/moby-live/Python/bioMoby/mobyService.py,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- /home/repository/moby/moby-live/Python/bioMoby/mobyService.py	2005/02/01 08:52:15	1.3
+++ /home/repository/moby/moby-live/Python/bioMoby/mobyService.py	2005/02/04 12:58:24	1.4
@@ -33,16 +33,16 @@
         
         for namespace in self.namespaces:
             result.append('<Namespace>'+namespace+'</Namespace>')
-    
+        
         result.append('</Simple>')
         
         return "".join(result)
-
+    
     def fromXML(self, xml):
         """Return an article from a xml node
         """
         node=parseString(xml)
-
+        
         self.name=node.getAttribute("articleName")
         for otns in node.childNodes:
             if otns.nodeName=="objectType":
@@ -63,12 +63,11 @@
         
         self.enums=enums
 
-    
     def toTuple(self):
         """Return the object as a tuple
         """
         return (self.name, self.type, self.default, self.min, self.max, self.enums)
-            
+    
     def __str__(self):
         """Return the xml form of the object
         """
@@ -83,23 +82,23 @@
             
         if self.max !='':
             result.append('<max>'+self.max+'</max>')
-
+        
         for enum in self.enums:
             result.append('<enum>'+enum+'</enum>')
-
+        
         result.append('</Parameter>')
-
+        
         return "".join(result)
-
+    
     def fromXML(self, xml):
         """Return a parameter from a xml
         """
         
         node=parseString(xml)        
-
+        
         self.enums=[]
         self.name=node.getAttribute("articleName")
-
+        
         for childNode in node.childNodes:
             if childNode.nodeName=="datatype":
                 self.type=childNode.firstChild.nodeValue
@@ -129,11 +128,11 @@
         self.protocol="moby"
         self.authURI=""
         self.serviceName=""
-
+        
         self.expandObjects=0
         self.expandServices=1
         self.authoritative=0
-
+        
         if 'serviceName' in kw:
             self.serviceName=kw['serviceName']
         if 'serviceType' in kw:
@@ -148,15 +147,15 @@
             self.outputObjects=kw['outputObjects']
         if 'keywords' in kw:
             self.keywords=kw['keywords']
-            
+    
     def submits2XML(self, entries):
         """Tranforms inputs/outputs into xml
         """
-
+        
         import string
         result=[]
         for submit in entries:
-
+            
             #first look if it is an article or a collection
             #first case
             if submit[1].__class__ is string or submit[1].__class__ is str:
@@ -165,42 +164,41 @@
                 #otns[1] namespace
                 for namespace in submit[2]:
                     result.append("<Namespace>"+namespace+"</Namespace>")
-
+                
                 result.append("</Simple>")
                 #it is a collection
             else:
                 result.append('<Collection articleName="'+submit[0]+'">')
-
+                
                 for simpleArticle in submit[1]:
                     result.append('<Simple articleName="'+simpleArticle[0]+'"><objectType>'+simpleArticle[1]+'</objectType>')
                     for namespace in simpleArticle[2]:
                         result.append("<Namespace>"+namespace+"</namespace>")
-
+                    
                     result.append("</Simple>")
                         
                 result.append("</Collection>")
-
+        
         del string                    
         return "".join(result)
-
-
+    
     def keywords2XML(self, keywords):
         """Transform keywords into xml
         """
         result=[]
+        
         for keyword in keywords:
             result.append("<keyword>"+keyword+"</keyword>")
-            
-
+        
+        
         return "".join(result)
-
-
+    
     def __str__(self):
         """Give the xml form of the query
         """
         result=["<inputObjects><Input>"]
         result.append(self.submits2XML(self.inputObjects))
-
+        
         result.append("</Input></inputObjects><outputObjects><output>")
         result.append(self.submits2XML(self.outputObjects))
         result.append("</output></outputObjects>")
@@ -208,18 +206,18 @@
         result.append("<serviceType>"+self.serviceType+"</serviceType>")
         result.append("<Protocol>moby</Protocol>")
         result.append("<authURI>"+self.authURI+"</authURI>")
-
+        
         if self.serviceName != "" and self.serviceName !="dummy":
             result.append("<serviceName>"+self.serviceName+"</serviceName>")
-
+        
         result.append("<expandObjects>"+`self.expandObjects`+"</expandObjects>")
         result.append("<expandServices>"+`self.expandServices`+"</expandServices>")
         result.append("<authoritative>"+`self.authoritative`+"</authoritative>")
         result.append("<keywords>")
         result.append(self.keywords2XML(self.keywords))
         result.append("</keywords>")
-
-
+        
+        
         return "".join(result)
 
 
@@ -236,10 +234,10 @@
             
             -A WSDL
         """
-
+        
         GeneralInformations.__init__(self)
         self.namespace="http://biomoby.org/"
-
+        
         self.name=""
         self.type=""
         self.category=""
@@ -251,7 +249,7 @@
         self.secondaryArticles=[]
         self.methods=[]
         self.results=""
-
+        
         if len(arg)==1 and arg[0].__class__ is dict:
             arg=arg[0]
             for key in arg.keys():
@@ -291,11 +289,11 @@
         """
         self.methods=[]
         doc=parseString(wsdl)
-
+        
         for method in doc.getElementsByTagName("operation"):
             if method.getAttribute("name") not in self.methods:
                 self.methods.append(method.getAttribute("name"))
-
+        
         if self.url=="":
             for url in doc.getElementsByTagName("soap:address"):
                 self.url=url.getAttribute("location")
@@ -310,7 +308,7 @@
         """
         
         from SOAPpy import SOAPProxy
-
+        
         webservice=SOAPProxy(self.url,namespace=self.namespace)
         
         if method=="":
@@ -318,34 +316,34 @@
                 method=self.name
             else:
                 method=self.methods[0]
-
+        
         if method not in self.methods:
             from bioMoby.mobyExceptions import ENotAWSMethod
             raise ENotAWSMethod
-
+        
         webservice.soapaction=self.namespace+"#"+method
-
+        
         if debug:
             webservice.config.debug=1
         
         toQuery=str(query)
-
+        
         del  SOAPProxy
-
+        
         result=webservice.invoke(method, toQuery)
         
         if returnXml:
             return result
-            
+        
         #try to return a MobyContent Object instead
         from bioMoby.mobyDataTypes import MobyContent
         mc=MobyContent()
         mc.fromMoby(result)
         
         del MobyContent
-
+        
         return mc
-            
+    
     def __str__(self):
         """Returns The moby xml form of the web service
         """
@@ -358,7 +356,7 @@
         result.append("<contactEmail>"+self.contact+"</contactEmail>")
         result.append("<authoritativeService>"+`self.authoritative`+"</authoritativeService>")
         result.append("<Description><![CDATA["+self.description+"]]></Description>")
-
+        
         result.append("<Input>")
         
         for inputObject in self.inputObjects:
@@ -366,25 +364,25 @@
                 result.append(str(inputObject))
             elif inputObject.__class__ is dict:
                 result.append('<Collection articleName="'+inputObject.keys()[0]+'">')
-
+                
                 for aSimple in inputObject[inputObject.keys()[0]]:
                     result.append(str(aSimple))
-
+                
                 result.append("</Collection>")
             else:
                 from mobyExceptions import EInvalidArgument
                 raise EInvalidArgument, "Bad input object"
-            
+        
         result.append("</Input>")
-
+        
         result.append("<Output>")
-
+        
         for output in self.outputObjects:
             if output.__class__ is ServiceArticle:
                 result.append(str(output))
             elif output.__class__ is dict:
                 result.append('<Collection articleName="'+output.keys()[0]+'">')
-
+                
                 for aSimple in output[output.keys()[0]]:
                     result.append(str(aSimple))
                     
@@ -392,19 +390,18 @@
             else:
                 from mobyExceptions import EInvalidArgument
                 raise EInvalidArgument, "Bad output object"
-                    
-
+        
+        
         result.append("</Output>")
-
+        
         result.append("<secondaryArticles>")
         
         for secondaryArticle in self.secondaryArticles:
             result.append(str(secondaryArticle))
-
+        
         result.append("</secondaryArticles>")
-
+        
         return "".join(result)
-    
 
     def register(self):
         """Register the service on the Moby server    
@@ -435,8 +432,7 @@
         """
         
         self.results=self.execute(mobyContent, returnXml=(mobyContent.__class__ is str))
-                
-        
+    
     def start(self, mobycontent, timeout=-1):
         """Start the service as it was a thread
         """
@@ -447,16 +443,14 @@
             self._execThread=Thread(target=self._executeThread, args=(mobycontent,))
         else:
             self._execThread=Thread(target=self._executeThread, args=(mobycontent,), timeout=timeout)
-
-        self._execThread.start()
         
+        self._execThread.start()
+    
     def join(self):
         """Same as Thread.join
         """
         self._execThread.join()
-        
-        
-        
+    
 class ServiceList:
     """Class representing a service's list
     """
@@ -466,16 +460,16 @@
         """
         
         simpleArticle=ServiceArticle(name='',type='',namespaces=[])
-
+        
         simpleArticle.name=node.getAttribute("articleName")
         for otns in node.childNodes:
             if otns.nodeName=="objectType":
                 simpleArticle.type=otns.firstChild.nodeValue
             elif otns.nodeName=="Namespace":
                 simpleArticle.namespaces.append(otns.firstChild.nodeValue)
-                
+        
         return simpleArticle
-
+    
     def toCollection(self, node):
         """Return a collection of articles
         """
@@ -485,21 +479,20 @@
         for simpleArticle in node.childNodes:
             if simpleArticle.nodeName=="Simple":
                 collection.append(self.toSimpleArticle(simpleArticle))
-            
+        
         result[collectionName]=collection
         
         return result
     
-
     def toSecondary(self, node):
         """Return a parameter from a xml
         """
         secondary=ServiceSecondary(name="", type="", default="", min="", max="", enums=[])
-
+        
         secondary.enums=[]
-
+        
         secondary.name=node.getAttribute("articleName")
-
+        
         for childNode in node.childNodes:
             if childNode.nodeName=="datatype":
                 if childNode.firstChild:
@@ -516,18 +509,18 @@
             elif childNode.nodeName=="enum":
                 if childNode.firstChild:
                     secondary.enums.append(childNode.firstChild.nodeValue)
-
+        
         return secondary
 
     def __init__(self, xmlt):
         """Give the instance of an object from xml
         """
         self.list=[]
-
+        
         doc=parseString(xmlt)
         #for each service
         for node in doc.getElementsByTagName("Service"):
-
+            
             service=Service()
             service.name=node.getAttribute("serviceName")
             service.methods=[service.name]
@@ -565,7 +558,7 @@
                     for secondary in child.childNodes:
                         if secondary.nodeName=="Parameter":
                             service.secondaryArticles.append(self.toSecondary(secondary))
-                            
+            
             self.list.append(service)
 
     def getServiceByName(self, nameOfService):
@@ -574,7 +567,7 @@
         for service in self.list:
             if service.name==nameOfService:
                 return service
-                
+        
         return None
     
     def getServiceByAuthURI(self, authURI):
@@ -583,7 +576,7 @@
         for service in self.list:
             if service.authURI==authURI:
                 return service
-                
+        
         return None
 
     def __getitem__(self, key):




More information about the MOBY-guts mailing list