Exemplo n.º 1
0
 def __init__(self):
     #get romeo configuration
     self._config = copy.deepcopy(config.APPLICATIONS)
     #default plugin provider
     self._default = copy.deepcopy(ApplicationPlugin)
     self._classMap = {ApplicationPlugin.__name__: self._default}
     self._instanceMap = {}
     #interface magic tricks
     components.registerAdapter(self.AppManagerAdaptToPlugin, AppManager,
                                IDroneDApplication)
Exemplo n.º 2
0
    def makeAdaptable(self, klass):
        """take care of registering this plugin with a zope interface adapter.

           @param klass L{IDroneDApplication} implementor
           @return L{IDroneDApplication} implementor
        """
        #register for adaptation to an AppManager Model
        components.registerAdapter(
            self.ApplicationPluginAdaptToAppManager,
            klass,  #plugin that needs adaptation
            IDroneModelAppManager)
        return klass
Exemplo n.º 3
0
    def makeAdaptable(self, klass):
        """take care of registering this plugin with a zope interface adapter.

           @param klass L{IDroneDApplication} implementor
           @return L{IDroneDApplication} implementor
        """
        #register for adaptation to an AppManager Model
        components.registerAdapter(
            self.ApplicationPluginAdaptToAppManager,
            klass, #plugin that needs adaptation
            IDroneModelAppManager
        )
        return klass
Exemplo n.º 4
0
 def __init__(self):
     #get romeo configuration
     self._config = copy.deepcopy(config.APPLICATIONS)
     #default plugin provider
     self._default = copy.deepcopy(ApplicationPlugin)
     self._classMap = {ApplicationPlugin.__name__: self._default}
     self._instanceMap = {}
     #interface magic tricks
     components.registerAdapter(
         self.AppManagerAdaptToPlugin,
         AppManager, 
         IDroneDApplication
     )
Exemplo n.º 5
0
            except InvalidProcess: pass #raise all others
        else:
            self.process = RemoteProcess(ai.pid)
        #make an attempt to update the original caller
        if hasattr(original, 'pid'):
            try: original.pid = self.process.pid
            except: pass
        if hasattr(original, 'inode'):
            try: original.inode = self.process.inode
            except: pass

    def __getattribute__(self, name):
        try: return object.__getattribute__(self, name)
        except: return self.process.__getattribute__(name)
#provide an adapter for L{IDroneModelAppInstance} to L{IKittProcess}
components.registerAdapter(AdaptToProcess,AppInstance,IKittProcess)
#provide an adapter for L{IDroneModelAppProcess} to L{IKittProcess}
components.registerAdapter(AdaptToProcess,AppProcess,IKittProcess)

class AdaptToNullProcess(object):
    """I can adapt a L{IDroneModelAppProcess} provider or a 
       L{IDroneModelAppInstance} provider to a L{IKittNullProcess} provider.

       I hold no references to the Original Object after Instantiation.
    """
    implements(IKittNullProcess)
    def __init__(self, original):
        self.process = NullProcess()
        #make an attempt to update the original caller
        if hasattr(original, 'pid'):
            try: original.pid = self.process.pid
Exemplo n.º 6
0
                pass
        if hasattr(original, 'inode'):
            try:
                original.inode = self.process.inode
            except:
                pass

    def __getattribute__(self, name):
        try:
            return object.__getattribute__(self, name)
        except:
            return self.process.__getattribute__(name)


#provide an adapter for L{IDroneModelAppInstance} to L{IKittProcess}
components.registerAdapter(AdaptToProcess, AppInstance, IKittProcess)
#provide an adapter for L{IDroneModelAppProcess} to L{IKittProcess}
components.registerAdapter(AdaptToProcess, AppProcess, IKittProcess)


class AdaptToNullProcess(object):
    """I can adapt a L{IDroneModelAppProcess} provider or a 
       L{IDroneModelAppInstance} provider to a L{IKittNullProcess} provider.

       I hold no references to the Original Object after Instantiation.
    """
    implements(IKittNullProcess)

    def __init__(self, original):
        self.process = NullProcess()
        #make an attempt to update the original caller