[Subversion] / PEAK / src / peak / binding / interfaces.py  

View of /PEAK/src/peak/binding/interfaces.py

Parent Directory | Revision Log
Revision: 655 - (download) (as text)
Sat Nov 9 22:06:07 2002 UTC (21 years, 6 months ago) by pje
File size: 2028 byte(s)
Components now support names and paths:

* Objects created by naming system lookup, binding.New(), or
  AutoCreated, can all now automatically receive information
  about their name as well as their parent component.

* binding.getComponentName() gets an object's name or 'None'

* binding.getComponentPath(c, relativeTo=None) gets an object's
  path from its root component, or as a relative path from
  'relativeTo' (assumes 'relativeTo' is a parent of 'c').
  Unknown names are rendered as '*' in the path.

* Added 'binding.Acquire' after all.

* Improved management of _p_jar/_p_oid by model.Element, using
  _p_jar as the parent component, and _p_oid as the component
  name for elements.

* Added unit tests for name and path support.
"""PEAK Component Binding Interfaces"""

from Interface import Interface
from Interface.Attribute import Attribute

from peak.config.interfaces import IConfigurable, IConfigSource

__all__ = [
    'IBindingFactory', 'IBindingSPI', 'IBindingAPI', 'IComponent',
]


class IBindingFactory(Interface):

    """Class interface for creating bindable components"""

    def __call__(parentComponent=None, componentName=None, **attrVals):
        """Create a new component

        The default constructor signature of a binding component is
        to receive an optional parent to be bound to, an optional name
        relative to the parent, and keyword arguments which will be
        placed in the new object's dictionary, to override the specified
        bindings."""


class IBindingSPI(IConfigSource):

    """Minimum requirements to join a component hierarchy"""

    def getParentComponent():
        """Return the parent component of this object, or 'None'"""

    def getComponentName():
        """Return this component's name relative to its parent, or 'None'"""






class IBindingAPI(IBindingSPI):

    """API supplied by binding.Base and its subclasses

    peak.model's 'StructuralFeature' classes rely on this interface."""

    def lookupComponent(name):
        """Look up a name in context - see 'binding.lookupComponent()'"""


    def setParentComponent(parent):
        """Set the object's parent to 'parent'; raises 'AlreadyRead' if
        the parent has already been used by the component for any purpose."""
        

    def _hasBinding(attr):
        """Return true if binding named 'attr' has been activated"""

    def _getBinding(attr,default=None):
        """Return binding named 'attr' if activated, else return 'default'"""

    def _setBinding(attr,value):
        """Set binding 'attr' to 'value'"""

    def _delBinding(attr):
        """Ensure that no binding for 'attr' is active"""















class IComponent(IBindingAPI, IConfigurable):

    """API supplied by binding.Components"""


cvs-admin@eby-sarna.com

Powered by ViewCVS 1.0-dev

ViewCVS and CVS Help