Commits

Adam Lindsay committed 7bcb3a7

Use introspection to handle the BaseHandler.service_type resolution. Should be no need to worry about writing those methods any more.

  • Participants
  • Parent commits 79878e3

Comments (0)

Files changed (2)

 
 DEFAULTPORT = 9900
 WAITPERIOD = 0.01
-SERVICENAME = "Locator"
+SERVICENAME = "locator.Locator"
 
 usage = '''
   python %prog [options]
 class BaseHandler(Base.Iface):
     @classmethod
     def service_type(cls):
-        return 'Base'
+        for base in cls.__bases__:
+            if base.__name__ == 'Iface':
+                return base.__module__
+        return ''
     
     @classmethod
     def service_types(cls):
         "Give the canonical Location"
         return Location(address=self.address, port=self.port)
     
-    @classmethod
-    def service_type(cls):
-        return SERVICENAME
-    
     def join(self, location):
         """
         Parameters:

File storeserver.py

 
 DEFAULTPORT = 9900
 WAITPERIOD = 0.01
-SERVICENAME = "Diststore"
+SERVICENAME = "diststore.Store"
 
 usage = '''
   python %prog [options]
 
 remote_call = partial(location.generic_remote_call, Store.Client)
 
-class StoreHandler(location.LocatorHandler):
+class StoreHandler(location.LocatorHandler, Store.Iface):
     def __init__(self, peer=None, port=9900):
         location.LocatorHandler.__init__(self, peer, port)
         self.store = defaultdict(str)
     
-    @classmethod
-    def service_type(cls):
-        return SERVICENAME
-    
     def get(self, key):
         """
         Parameters: