iro/offer/provider.py
branchdevel
changeset 171 5619596a0053
parent 169 aabc04843d25
child 180 55ab949cf0f8
equal deleted inserted replaced
170:2a16943f1d05 171:5619596a0053
     1 from functools import partial
     1 from functools import partial
     2 
     2 
       
     3 from iro.error import NoRoute, NoTyp
     3 class Provider():
     4 class Provider():
     4     def __init__(self, name, config, typs={}):
     5     def __init__(self, name, config, typs={}):
     5         self.name = name
     6         self.name = name
     6         self.config = config
     7         self.config = config
     7         self.typs=typs
     8         self.typs=typs
    16 
    17 
    17     def send(self, typ, route, recipient, message):
    18     def send(self, typ, route, recipient, message):
    18         pass
    19         pass
    19 
    20 
    20     def getSendFunc(self, typ, route):
    21     def getSendFunc(self, typ, route):
       
    22         try:
       
    23             if route not in self.typs[typ]:
       
    24                 raise NoRoute(route)
       
    25         except KeyError:
       
    26             raise NoTyp(route)
    21         return partial(self.send, typ, route)
    27         return partial(self.send, typ, route)
    22 
    28