"""$URL: svn+ssh://svn.mems-exchange.org/repos/trunk/dulcinea/lib/interaction.py $
$Id: interaction.py 25864 2005-01-17 15:31:22Z dbinger $
"""

from dulcinea.history import History

class Interactable:

    """Storage for a set of interaction events on an object of interest

    Instance attributes:
      interactions : History
        the interaction history with this interactible object
    """

    interactions_is = History

    EMAIL = 'email'
    MAIL = 'mail'
    PHONE = 'phone'
    FAX = 'fax'
    OTHER = 'other'

    INTERACTION_CODES = (EMAIL, MAIL, PHONE, FAX, OTHER)

    decorator = str

    def __init__(self):
        self.interactions = History()

    def get_decorator(self):
        return self.__class__.decorator

    def with_decorator(self, decorator):
        self.__class__.decorator = decorator
        return self

    def get_interaction_history(self):
        return self.interactions

    def get_interaction_codes(self):
        return self.INTERACTION_CODES

    def record_interaction(self, user, code, comment):
        self.interactions.add_event(user, code, comment)


