Metadata-Version: 1.0
Name: roles
Version: 0.1.0
Summary: Small implementation of Roles
Home-page: http://github.org/amolenaar/roles
Author: Arjan Molenaar
Author-email: gaphor@gmail.com
License: BSD License
Description: 
        Pythonic implementation of the DCI (Data Context Interaction) pattern
        (http://www.artima.com/articles/dci_vision.html).
        
        The difference with mixins is that this role is applied only to the subject
        instance, not to the subject class (alas, a new class is constructed).
        
        Roles can be applied and revoked. Multiple roles can be applied to an instance.
        Revocation can happen in any particular order.
        
        As a basic example, consider some domain class:
        
        >>> from roles import RoleType
        >>> class DomainClass(object):
        ...     def __init__(self, a=3):
        ...         self.a = a
        >>> instance = DomainClass()
        
        The instance should participate in a collaboration in which it fulfills a
        particular role:
        
        >>> class MyRole(object):
        ...     __metaclass__ = RoleType
        ...     def rolefunc(self):
        ...          return self.a
        
        >>> inrole = MyRole(instance)
        >>> inrole       # doctest: +ELLIPSIS
        <__main__.DomainClass+MyRole object at 0x...>
        >>> isinstance(inrole, DomainClass)
        True
        
        Now the inrole instance can be invoked with the rolefunc() method as if
        it was the DomainClass' one:
        
        >>> inrole.rolefunc()
        3
        
Keywords: role DCI
Platform: All
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: BSD License
Classifier: Natural Language :: English
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Topic :: Software Development :: Libraries
Classifier: Topic :: Utilities
