[cig-commits] r5969 - in cs/pythia/trunk: opal/applications
pyre/applications pyre/inventory
leif at geodynamics.org
leif at geodynamics.org
Mon Feb 5 19:53:28 PST 2007
Author: leif
Date: 2007-02-05 19:53:28 -0800 (Mon, 05 Feb 2007)
New Revision: 5969
Added:
cs/pythia/trunk/pyre/applications/ComponentHarnessAdapter.py
Modified:
cs/pythia/trunk/opal/applications/WebApplication.py
cs/pythia/trunk/pyre/applications/ComponentHarness.py
cs/pythia/trunk/pyre/applications/DynamicComponentHarness.py
cs/pythia/trunk/pyre/applications/Executive.py
cs/pythia/trunk/pyre/applications/ServiceDaemon.py
cs/pythia/trunk/pyre/applications/ServiceHarness.py
cs/pythia/trunk/pyre/applications/__init__.py
cs/pythia/trunk/pyre/inventory/Configurable.py
Log:
Improved 'ComponentHarness'. I determined that pruneRegistry() is
worthless, because it only does one-half of the job: it hides the
traits of the harness from the harnessed component, but not
vice-versa. Ergo, filterConfiguration().
Modified: cs/pythia/trunk/opal/applications/WebApplication.py
===================================================================
--- cs/pythia/trunk/opal/applications/WebApplication.py 2007-02-06 02:23:07 UTC (rev 5968)
+++ cs/pythia/trunk/opal/applications/WebApplication.py 2007-02-06 03:53:28 UTC (rev 5969)
@@ -13,7 +13,6 @@
from opal.applications.CGI import CGI
-from pyre.applications.ComponentHarness import ComponentHarness
class WebApplication(CGI):
Modified: cs/pythia/trunk/pyre/applications/ComponentHarness.py
===================================================================
--- cs/pythia/trunk/pyre/applications/ComponentHarness.py 2007-02-06 02:23:07 UTC (rev 5968)
+++ cs/pythia/trunk/pyre/applications/ComponentHarness.py 2007-02-06 03:53:28 UTC (rev 5969)
@@ -43,41 +43,12 @@
return component
- def fini(self):
- """finalize the component"""
-
- if self.component:
- self.component.fini()
-
- return
-
-
def createComponent(self):
"""create the harnessed component"""
raise NotImplementedError(
"class %r must override 'createComponent'" % self.__class__.__name__)
- def prepareComponentCurator(self):
- """prepare the persistent store manager for the harnessed component"""
-
- # by default, assume that this is a mixin class and the host has a
- # notion of its persistent store that it wants to share with the
- # harnessed component
- return self.getCurator()
-
-
- def prepareComponentConfiguration(self, component):
- """prepare the persistent store manager for the harnessed component"""
-
- # by default, assume that this is a mixin class and the host has a
- # registry with settings for the harnessed component
- registry = self.pruneRegistry()
- registry.name = component.name
-
- return registry
-
-
def configureHarnessedComponent(self, component, curator, registry):
"""configure the harnessed component"""
Added: cs/pythia/trunk/pyre/applications/ComponentHarnessAdapter.py
===================================================================
--- cs/pythia/trunk/pyre/applications/ComponentHarnessAdapter.py 2007-02-06 02:23:07 UTC (rev 5968)
+++ cs/pythia/trunk/pyre/applications/ComponentHarnessAdapter.py 2007-02-06 03:53:28 UTC (rev 5969)
@@ -0,0 +1,69 @@
+#!/usr/bin/env python
+#
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#
+# California Institute of Technology
+# (C) 2006 All Rights Reserved
+#
+# {LicenseText}
+#
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#
+
+
+from ComponentHarness import ComponentHarness
+
+
+class ComponentHarnessAdapter(ComponentHarness):
+ """a mixin class used to create a component harness which is itself a component"""
+
+
+ def updateConfiguration(self, registry):
+ """divide settings between myself and the harnessed component"""
+
+ myRegistry, yourRegistry = self.filterConfiguration(registry)
+ self.componentRegistry.update(yourRegistry)
+ return super(ComponentHarnessAdapter, self).updateConfiguration(myRegistry)
+
+
+ def _fini(self):
+ """finalize the component"""
+
+ if self.component:
+ self.component.fini()
+
+ return
+
+
+ def prepareComponentCurator(self):
+ """prepare the persistent store manager for the harnessed component"""
+
+ # the host component has a notion of its persistent store that
+ # it wants to share with the harnessed component
+ return self.getCurator()
+
+
+ def prepareComponentConfiguration(self, component):
+ """prepare the settings for the harnessed component"""
+
+ # the host component has a registry with settings for the
+ # harnessed component
+ registry = self.componentRegistry
+ registry.name = component.name
+
+ return registry
+
+
+ def createComponentRegistry(self):
+ """create a registry instance to store a configuration for the harnessed component"""
+
+ return self.createRegistry()
+
+
+ def __init__(self):
+ ComponentHarness.__init__(self)
+ self.componentRegistry = self.createComponentRegistry()
+ return
+
+
+# end of file
Modified: cs/pythia/trunk/pyre/applications/DynamicComponentHarness.py
===================================================================
--- cs/pythia/trunk/pyre/applications/DynamicComponentHarness.py 2007-02-06 02:23:07 UTC (rev 5968)
+++ cs/pythia/trunk/pyre/applications/DynamicComponentHarness.py 2007-02-06 03:53:28 UTC (rev 5969)
@@ -12,10 +12,10 @@
#
-from ComponentHarness import ComponentHarness
+from ComponentHarnessAdapter import ComponentHarnessAdapter
-class DynamicComponentHarness(ComponentHarness):
+class DynamicComponentHarness(ComponentHarnessAdapter):
def createComponent(self):
Modified: cs/pythia/trunk/pyre/applications/Executive.py
===================================================================
--- cs/pythia/trunk/pyre/applications/Executive.py 2007-02-06 02:23:07 UTC (rev 5968)
+++ cs/pythia/trunk/pyre/applications/Executive.py 2007-02-06 03:53:28 UTC (rev 5969)
@@ -81,20 +81,6 @@
return context.verifyConfiguration(mode)
- def pruneRegistry(self):
- registry = self.registry
-
- for trait in self.inventory.properties():
- name = trait.name
- registry.deleteProperty(name)
-
- for trait in self.inventory.components():
- for name in trait.aliases:
- registry.extractNode(name)
-
- return registry
-
-
# the default application action
def main(self, *args, **kwds):
return
Modified: cs/pythia/trunk/pyre/applications/ServiceDaemon.py
===================================================================
--- cs/pythia/trunk/pyre/applications/ServiceDaemon.py 2007-02-06 02:23:07 UTC (rev 5968)
+++ cs/pythia/trunk/pyre/applications/ServiceDaemon.py 2007-02-06 03:53:28 UTC (rev 5969)
@@ -13,10 +13,10 @@
from Application import Application
from Daemon import Daemon as Stager
-from ComponentHarness import ComponentHarness
+from ComponentHarnessAdapter import ComponentHarnessAdapter
-class ServiceDaemon(Application, Stager, ComponentHarness):
+class ServiceDaemon(ComponentHarnessAdapter, Application, Stager):
class Inventory(Application.Inventory):
@@ -62,7 +62,7 @@
def __init__(self, name):
Application.__init__(self, name, facility='daemon')
Stager.__init__(self)
- ComponentHarness.__init__(self)
+ ComponentHarnessAdapter.__init__(self)
return
Modified: cs/pythia/trunk/pyre/applications/ServiceHarness.py
===================================================================
--- cs/pythia/trunk/pyre/applications/ServiceHarness.py 2007-02-06 02:23:07 UTC (rev 5968)
+++ cs/pythia/trunk/pyre/applications/ServiceHarness.py 2007-02-06 03:53:28 UTC (rev 5969)
@@ -16,7 +16,7 @@
from DynamicComponentHarness import DynamicComponentHarness
-class ServiceHarness(Script, DynamicComponentHarness):
+class ServiceHarness(DynamicComponentHarness, Script):
class Inventory(Script.Inventory):
Modified: cs/pythia/trunk/pyre/applications/__init__.py
===================================================================
--- cs/pythia/trunk/pyre/applications/__init__.py 2007-02-06 02:23:07 UTC (rev 5968)
+++ cs/pythia/trunk/pyre/applications/__init__.py 2007-02-06 03:53:28 UTC (rev 5969)
@@ -14,6 +14,8 @@
from Application import Application
from AppRunner import AppRunner
+from ComponentHarness import ComponentHarness
+from ComponentHarnessAdapter import ComponentHarnessAdapter
from Script import Script
from Shell import Shell
from SuperScript import SuperScript
Modified: cs/pythia/trunk/pyre/inventory/Configurable.py
===================================================================
--- cs/pythia/trunk/pyre/inventory/Configurable.py 2007-02-06 02:23:07 UTC (rev 5968)
+++ cs/pythia/trunk/pyre/inventory/Configurable.py 2007-02-06 03:53:28 UTC (rev 5969)
@@ -83,6 +83,31 @@
return context
+ def filterConfiguration(self, registry):
+ """split <registry> in two, according to which traits are in my inventory"""
+
+ myRegistry = self.createRegistry()
+ yourRegistry = self.createRegistry()
+ yourRegistry.update(registry)
+
+ # Filter-out my properties.
+ for trait in self.inventory.properties():
+ name = trait.name
+ descriptor = registry.properties.get(name)
+ if descriptor:
+ myRegistry.setProperty(name, descriptor.value, descriptor.locator)
+ yourRegistry.deleteProperty(name)
+
+ # Steal nodes which belong to my components.
+ for trait in self.inventory.components():
+ for name in trait.aliases:
+ node = yourRegistry.extractNode(name)
+ if node:
+ myRegistry.attachNode(node)
+
+ return myRegistry, yourRegistry
+
+
def newConfigContext(self):
from ConfigContext import ConfigContext
return ConfigContext()
More information about the cig-commits
mailing list