renaming newuser->newinterface devel
authorSandro Knauß <knauss@netzguerilla.net>
Sun, 18 Dec 2011 16:43:22 +0100
branchdevel
changeset 80 265124610789
parent 79 17a00b99b9fd
child 81 fea4c6760ca5
renaming newuser->newinterface
createdoc.py
iro/newinterface.py
iro/newuser.py
--- a/createdoc.py	Sun Dec 18 13:42:53 2011 +0100
+++ b/createdoc.py	Sun Dec 18 16:43:22 2011 +0100
@@ -8,7 +8,7 @@
 import re
 import inspect
 from iro.user import User as Current
-from iro.newuser import User as New
+from iro.newinterface import Interface as New
 
 from createerm import createSchemaPlot,tables
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/iro/newinterface.py	Sun Dec 18 16:43:22 2011 +0100
@@ -0,0 +1,205 @@
+# -*- coding: utf-8 -*-
+#Copyright (C) 2009  Sandro Knauß <bugs@sandroknauss.de>
+
+#This program is free software; you can redistribute it and/or modify it under the terms
+#of the GNU General Public License as published by the Free Software Foundation;
+#either version 3 of the License, or any later version.
+#This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+#without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+#See the GNU General Public License for more details.
+
+#You should have received a copy of the GNU General Public License
+#along with this program; if not, see <http://www.gnu.org/licenses/>.
+from twisted.web import soap, xmlrpc, resource, server
+import logging
+logging.basicConfig(level=logging.DEBUG, format='%(asctime)s %(name)s(%(processName)s)-%(levelname)s: %(message)s')
+
+class Interface(object):
+    '''class for a xmlrpc user
+    '''
+    
+    def status(self, apikey, id=None, detailed=False):
+        '''Gibt den aktuellen Status eines Auftrages zurück.
+
+        Keywords:
+        apikey[string]: Der API Key
+        id[hash]: Eine Auftragsnummer
+        detailed[boolean]: Details ausgeben
+
+        Return:
+        jobs[list]: Eine Liste der Aufträge.
+        job.name[string]: Angebener Name
+        job.status[string]: Status des Auftrages
+
+
+        '''
+        return ""
+
+    def stop(self, apikey,id):
+        '''Stoppt den angegeben Auftrag.
+
+        Keywords:
+        apikey[string]: Der API Key
+        id[hash]: Eine Auftragsnummer
+
+        Return:
+
+        '''
+        return ""
+    
+    def sms(self, apikey, message, recipients, route="default"):
+        '''Versendet eine SMS.
+
+        Keywords:
+        apikey[string]: Der API Key
+        message[string]: Nachricht
+        recipients[list]: eine Liste von Emfänger-Nummern (gemäß ITU-T E.123)
+        route[string|list]: Route über den geschickt werden soll, 
+                            oder eine Liste von Routen, um Fallbacks anzugeben
+
+        Return:
+        id[hash]: Die ID des Auftrages
+
+        '''
+        return ""
+   
+    
+    def fax(self, apikey, subject, fax, recipients, route="default"):
+        '''Versendet ein FAX.
+
+        Keywords:
+        apikey[string]: Der API Key
+        subject[string]: Der Betreff
+        fax[string]: Das PDF base64 kodiert
+        recipients[list]: Eine Liste von Emfänger-Nummern (gemäß ITU-T E.123)
+        route[string|list]: Route über den geschickt werden soll, 
+                            oder eine Liste von Routen, um Fallbacks anzugeben
+
+        Return:
+        id[hash]: Die ID des Auftrages
+
+        '''
+        return ""
+
+    def mail(self, apikey, subject,  body, recipients, frm, route="default"):
+        '''Versendet eine Email.
+
+        Keywords:
+        apikey[string]: Der API Key
+        subject[string]: Der Betreff
+        body[string]: Der Email Body
+        recipients[list]: Eine Liste von Emailadressen
+        frm[string]: Die Absender Emailadresse
+        route[string|list]: Route über den geschickt werden soll, 
+                            oder eine Liste von Routen, um Fallbacks anzugeben
+
+        Return:
+        id[hash]: Die ID des Auftrages
+
+        '''
+        return ""
+       
+    def routes(self, apikey, typ):
+        '''Gibt eine Liste aller verfügbaren Provider zurück.
+
+        Keywords:
+        apikey[string]: Der API Key
+        typ[string]: Der Typ zu dem die Providerloste ausgeben werden soll
+                     Einer der Liste ["sms","fax","mail"]
+
+        Return:
+        providerlist[list]: Eine Liste aller möglichen Provider
+
+        '''
+        return ""
+        
+    def defaultRoute(self, apikey, typ):
+        '''Gibt den Standardprovider zurück.
+ 
+        Keywords:
+        apikey[string]: Der API Key
+        typ[string]: Der Typ zu dem die Providerloste ausgeben werden soll
+                     Einer der Liste ["sms","fax","mail"]
+
+        Return:
+        provider[string]: Der Standardprovider für den angeben Typ
+
+
+        '''
+        return ""
+
+    def statistic(self,apikey):
+        '''Gibt eine Statik zurück über die versendendeten Nachrichten und des Preises.
+
+        Keywords:
+        apikey[string]: Der API Key
+
+        Return:
+        statistic[list]: Eine Liste nach Nachrichtentypen
+        '''
+        return ""
+
+    def listMethods(self):
+        """Since we override lookupProcedure, its suggested to override
+        listProcedures too.
+        """
+        return self.listProcedures()
+  
+
+    def listProcedures(self):
+        """Since we override lookupProcedure, its suggested to override
+        listProcedures too.
+        """
+        return ['listMethods','status','stop','sms','fax','mail','routes','defaultRoute','statistic']
+
+
+class XMLRPCInterface(Interface,xmlrpc.XMLRPC): 
+    def __init__(self):
+        xmlrpc.XMLRPC.__init__(self) 
+        Interface.__init__(self)
+        self.allowNone = True
+    
+    def lookupProcedure(self, procedurePath):
+        logging.debug("lookupProcedure('%s')"%procedurePath)
+        if procedurePath not in self.listProcedures():
+            raise xmlrpc.NoSuchFunction(self.NOT_FOUND,
+                        "procedure %s not found" % procedurePath)
+        try:
+            return getattr(self,procedurePath)
+        except KeyError:
+            raise xmlrpc.NoSuchFunction(self.NOT_FOUND,
+                        "procedure %s not found" % procedurePath)
+
+class SOAPInterface(Interface,soap.SOAPPublisher): 
+    def __init__(self):
+        soap.SOAPPublisher.__init__(self) 
+        Interface.__init__(self)
+        
+    def lookupFunction(self, functionName):
+        """Lookup published SOAP function.
+
+        Override in subclasses. Default behaviour - publish methods
+        starting with soap_, if they have true attribute useKeywords
+        they are expected to accept keywords.
+        
+        @return: tuple (callable, useKeywords), or (None, None) if not found.
+        """
+        if functionName in self.listProcedures():
+            function = getattr(self, functionName, None)
+            if function:
+                return function, getattr(function, "useKeywords", False)
+            return None
+        else:
+            return None
+
+
+def main():
+    from twisted.internet import reactor
+    root = resource.Resource()
+    root.putChild('RPC2', XMLRPCInterface())
+    root.putChild('SOAP', SOAPInterface())
+    reactor.listenTCP(7080, server.Site(root))
+    reactor.run()
+
+if __name__ == '__main__':
+    main()
--- a/iro/newuser.py	Sun Dec 18 13:42:53 2011 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,205 +0,0 @@
-# -*- coding: utf-8 -*-
-#Copyright (C) 2009  Sandro Knauß <bugs@sandroknauss.de>
-
-#This program is free software; you can redistribute it and/or modify it under the terms
-#of the GNU General Public License as published by the Free Software Foundation;
-#either version 3 of the License, or any later version.
-#This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
-#without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-#See the GNU General Public License for more details.
-
-#You should have received a copy of the GNU General Public License
-#along with this program; if not, see <http://www.gnu.org/licenses/>.
-from twisted.web import soap, xmlrpc, resource, server
-import logging
-logging.basicConfig(level=logging.DEBUG, format='%(asctime)s %(name)s(%(processName)s)-%(levelname)s: %(message)s')
-
-class User(object):
-    '''class for a xmlrpc user
-    '''
-    
-    def status(self, apikey, id=None, detailed=False):
-        '''Gibt den aktuellen Status eines Auftrages zurück.
-
-        Keywords:
-        apikey[string]: Der API Key
-        id[hash]: Eine Auftragsnummer
-        detailed[boolean]: Details ausgeben
-
-        Return:
-        jobs[list]: Eine Liste der Aufträge.
-        job.name[string]: Angebener Name
-        job.status[string]: Status des Auftrages
-
-
-        '''
-        return ""
-
-    def stop(self, apikey,id):
-        '''Stoppt den angegeben Auftrag.
-
-        Keywords:
-        apikey[string]: Der API Key
-        id[hash]: Eine Auftragsnummer
-
-        Return:
-
-        '''
-        return ""
-    
-    def sms(self, apikey, message, recipients, route="default"):
-        '''Versendet eine SMS.
-
-        Keywords:
-        apikey[string]: Der API Key
-        message[string]: Nachricht
-        recipients[list]: eine Liste von Emfänger-Nummern (gemäß ITU-T E.123)
-        route[string|list]: Route über den geschickt werden soll, 
-                            oder eine Liste von Routen, um Fallbacks anzugeben
-
-        Return:
-        id[hash]: Die ID des Auftrages
-
-        '''
-        return ""
-   
-    
-    def fax(self, apikey, subject, fax, recipients, route="default"):
-        '''Versendet ein FAX.
-
-        Keywords:
-        apikey[string]: Der API Key
-        subject[string]: Der Betreff
-        fax[string]: Das PDF base64 kodiert
-        recipients[list]: Eine Liste von Emfänger-Nummern (gemäß ITU-T E.123)
-        route[string|list]: Route über den geschickt werden soll, 
-                            oder eine Liste von Routen, um Fallbacks anzugeben
-
-        Return:
-        id[hash]: Die ID des Auftrages
-
-        '''
-        return ""
-
-    def mail(self, apikey, subject,  body, recipients, frm, route="default"):
-        '''Versendet eine Email.
-
-        Keywords:
-        apikey[string]: Der API Key
-        subject[string]: Der Betreff
-        body[string]: Der Email Body
-        recipients[list]: Eine Liste von Emailadressen
-        frm[string]: Die Absender Emailadresse
-        route[string|list]: Route über den geschickt werden soll, 
-                            oder eine Liste von Routen, um Fallbacks anzugeben
-
-        Return:
-        id[hash]: Die ID des Auftrages
-
-        '''
-        return ""
-       
-    def routes(self, apikey, typ):
-        '''Gibt eine Liste aller verfügbaren Provider zurück.
-
-        Keywords:
-        apikey[string]: Der API Key
-        typ[string]: Der Typ zu dem die Providerloste ausgeben werden soll
-                     Einer der Liste ["sms","fax","mail"]
-
-        Return:
-        providerlist[list]: Eine Liste aller möglichen Provider
-
-        '''
-        return ""
-        
-    def defaultRoute(self, apikey, typ):
-        '''Gibt den Standardprovider zurück.
- 
-        Keywords:
-        apikey[string]: Der API Key
-        typ[string]: Der Typ zu dem die Providerloste ausgeben werden soll
-                     Einer der Liste ["sms","fax","mail"]
-
-        Return:
-        provider[string]: Der Standardprovider für den angeben Typ
-
-
-        '''
-        return ""
-
-    def statistic(self,apikey):
-        '''Gibt eine Statik zurück über die versendendeten Nachrichten und des Preises.
-
-        Keywords:
-        apikey[string]: Der API Key
-
-        Return:
-        statistic[list]: Eine Liste nach Nachrichtentypen
-        '''
-        return ""
-
-    def listMethods(self):
-        """Since we override lookupProcedure, its suggested to override
-        listProcedures too.
-        """
-        return self.listProcedures()
-  
-
-    def listProcedures(self):
-        """Since we override lookupProcedure, its suggested to override
-        listProcedures too.
-        """
-        return ['listMethods','status','stop','sms','fax','mail','routes','defaultRoute','statistic']
-
-
-class XMLRPCUser(User,xmlrpc.XMLRPC): 
-    def __init__(self):
-        xmlrpc.XMLRPC.__init__(self) 
-        User.__init__(self)
-        self.allowNone = True
-    
-    def lookupProcedure(self, procedurePath):
-        logging.debug("lookupProcedure('%s')"%procedurePath)
-        if procedurePath not in self.listProcedures():
-            raise xmlrpc.NoSuchFunction(self.NOT_FOUND,
-                        "procedure %s not found" % procedurePath)
-        try:
-            return getattr(self,procedurePath)
-        except KeyError:
-            raise xmlrpc.NoSuchFunction(self.NOT_FOUND,
-                        "procedure %s not found" % procedurePath)
-
-class SOAPUser(User,soap.SOAPPublisher): 
-    def __init__(self):
-        soap.SOAPPublisher.__init__(self) 
-        User.__init__(self)
-        
-    def lookupFunction(self, functionName):
-        """Lookup published SOAP function.
-
-        Override in subclasses. Default behaviour - publish methods
-        starting with soap_, if they have true attribute useKeywords
-        they are expected to accept keywords.
-        
-        @return: tuple (callable, useKeywords), or (None, None) if not found.
-        """
-        if functionName in self.listProcedures():
-            function = getattr(self, functionName, None)
-            if function:
-                return function, getattr(function, "useKeywords", False)
-            return None
-        else:
-            return None
-
-
-def main():
-    from twisted.internet import reactor
-    root = resource.Resource()
-    root.putChild('RPC2', XMLRPCUser())
-    root.putChild('SOAP', SOAPUser())
-    reactor.listenTCP(7080, server.Site(root))
-    reactor.run()
-
-if __name__ == '__main__':
-    main()