Changeset 213


Ignore:
Timestamp:
Sep 13, 2009, 12:24:22 PM (11 years ago)
Author:
pvkouteren
Message:

Modified SOAPServer to connect to database.
Added functionality to AtomicServices?.

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • IbidasSOAP.py

    r212 r213  
    1010    def __init__(self):
    1111        super(SimpleWSGISoapApp, self).__init__()
     12        IbidasAtomicServices.__init__(self)
    1213       
    1314if __name__=='__main__':
  • web/IbidasAtomicServicesTemp.py

    r200 r213  
    66from IbidasMessage import IbidasMessage
    77import time
     8import config
     9from container import postgres
     10import web.IbidasMessage
    811
    912class IbidasAtomicServices:
     
    2427        iconfig = config.loadConfig('ibidas.ini',_ConfigDefault)
    2528        self.cd = postgres.openConnection(iconfig['database.host'],\
    26             iconfig['database.port'],iconfig['database.name'],\
    27             iconfig['database.user'],iconfig['database.password']).getConSet()
     29                    iconfig['database.port'],iconfig['database.name'],\
     30                    iconfig['database.user'],iconfig['database.password']).getConSet()
     31
     32    def _tableToSerializer(self, table):
     33        objects = []
     34        containerobject = getattr(self.cd, table)
     35        fields = containerobject.fields.name().tolist()
     36        for i in range(len(containerobject)):
     37            object = web.IbidasMessage.name_types['ibidas'+table]()
     38            for field in fields:
     39                setattr(object, field, getattr(containerobject[i], field)())
     40            objects.append(object)
     41        return objects
    2842
    2943    @soapmethod(_returns=String)
     
    7892        return im
    7993       
     94    @soapmethod(IbidasItem, IbidasTerm, _returns=IbidasMessage)
     95    def addItemAndTerm(self, item, term):
     96        """ Return a Message with some items and a term """
     97        im = IbidasMessage()
     98        im.add(item)
     99        im.add(term)
     100        return im
     101         
     102    ''' More serious methods '''
     103   
     104    @soapmethod(_returns=Array(IbidasSet))
     105    def listDatasets(self):
     106        """ Return a list of all available datasets in Ibidas """
     107        return self._tableToSerializer('set')
Note: See TracChangeset for help on using the changeset viewer.