# Path: ipet/concepts/Observer.py
# class Observable:
#     """
#     observables represent the client in the Observer pattern. They have the possibility to nofify their
#     observers and invoke an update every time they change their state
#     """
#     observermap = {}  # : map which has observables as keys, and observers as values
#     def addObserver(self, newobserver):
#         """
#         add an observer to the list of observers
#         """
#         theset = Observable.observermap.setdefault(self, set())
# 
#         theset.add(newobserver)
# 
#     def removeObserver(self, observer):
#         """
#         removes an observer from the list of observers
#         """
#         theset = Observable.observermap.get(self)
#         if theset is not None:
#             theset.remove(observer)
# 
#     def notify(self, *args):
#         """
#         notify all observers about changes in the state
#         """
#         theset = Observable.observermap.setdefault(self, set())
#         for observer in theset:
#             observer.update(*args)
# 
# Path: ipet/concepts/IPETMessageStream.py
# class Message:
#     """
#     class for representing state messages to the user
#     
#     a Message contains a string message and a type
#     """
#     MESSAGETYPE_WARNING = 1
#     MESSAGETYPE_ERROR = 2
#     MESSAGETYPE_INFO = 3
#     MESSAGETYPE_DEBUG = 4
#     messagetypes = {MESSAGETYPE_WARNING, MESSAGETYPE_INFO, MESSAGETYPE_ERROR, MESSAGETYPE_DEBUG}
# 
#     def __init__(self, stringmessage, messagetype):
#         """
#         """
#         self.stringmessage = stringmessage
#         if messagetype not in Message.messagetypes:
#             raise ValueError(Message("Error: wrong messagetype %s, must be in %s" % (repr(messagetype), str(Message.messagetypes)), Message.MESSAGETYPE_ERROR))
#         self.messagetype = messagetype
# 
#     def __str__(self):
#         return self.stringmessage
#     def __unicode__(self):
#         return str(self.stringmessage)
#     def __repr__(self):
#         return self.stringmessage


from .Observer import Observable
from .IPETMessageStream import Message
        for key, val in list(self.stringrepresentations.items()):
            if val == manageable:
                oldstringrepresentation = key
                break
        del self.stringrepresentations[oldstringrepresentation]
        self.deactivate([manageable])

    def reinsertManageable(self, manageable):
        """
        reinserts a manageable after a possible name change that was not 
        
        reinserts a manageable after its name has changed
        """
        active = self.isActive(manageable)
        self.deleteManageable(manageable)
        self.addManageable(manageable)
        if active:
            self.activate([manageable])

    def editObjectAttribute(self, manageable, attributename, newattribute):
        """
        edit an objects attribute and ensure that a changed object representation is directly
        processed
        """
        oldname = self.getStringRepresentation(manageable)
        manageable.editAttribute(attributename, newattribute)
        newname = self.getStringRepresentation(manageable)
        print(newname, newattribute)
        if oldname != newname:
            self.chgManageableName(manageable, oldname, newname)

# Path: ipet/concepts/Observer.py
# class Observable:
#     """
#     observables represent the client in the Observer pattern. They have the possibility to nofify their
#     observers and invoke an update every time they change their state
#     """
#     observermap = {}  # : map which has observables as keys, and observers as values
#     def addObserver(self, newobserver):
#         """
#         add an observer to the list of observers
#         """
#         theset = Observable.observermap.setdefault(self, set())
# 
#         theset.add(newobserver)
# 
#     def removeObserver(self, observer):
#         """
#         removes an observer from the list of observers
#         """
#         theset = Observable.observermap.get(self)
#         if theset is not None:
#             theset.remove(observer)
# 
#     def notify(self, *args):
#         """
#         notify all observers about changes in the state
#         """
#         theset = Observable.observermap.setdefault(self, set())
#         for observer in theset:
#             observer.update(*args)
# 
# Path: ipet/concepts/IPETMessageStream.py
# class Message:
#     """
#     class for representing state messages to the user
#     
#     a Message contains a string message and a type
#     """
#     MESSAGETYPE_WARNING = 1
#     MESSAGETYPE_ERROR = 2
#     MESSAGETYPE_INFO = 3
#     MESSAGETYPE_DEBUG = 4
#     messagetypes = {MESSAGETYPE_WARNING, MESSAGETYPE_INFO, MESSAGETYPE_ERROR, MESSAGETYPE_DEBUG}
# 
#     def __init__(self, stringmessage, messagetype):
#         """
#         """
#         self.stringmessage = stringmessage
#         if messagetype not in Message.messagetypes:
#             raise ValueError(Message("Error: wrong messagetype %s, must be in %s" % (repr(messagetype), str(Message.messagetypes)), Message.MESSAGETYPE_ERROR))
#         self.messagetype = messagetype
# 
#     def __str__(self):
#         return self.stringmessage
#     def __unicode__(self):
#         return str(self.stringmessage)
#     def __repr__(self):
#         return self.stringmessage


# Path: ipet/concepts/Manager.py
from .Observer import Observable
from .IPETMessageStream import Message

        for key, val in list(self.stringrepresentations.items()):
            if val == manageable:
                oldstringrepresentation = key
                break
        del self.stringrepresentations[oldstringrepresentation]
        self.deactivate([manageable])

    def reinsertManageable(self, manageable):
        """
        reinserts a manageable after a possible name change that was not 
        
        reinserts a manageable after its name has changed
        """
        active = self.isActive(manageable)
        self.deleteManageable(manageable)
        self.addManageable(manageable)
        if active:
            self.activate([manageable])

    def editObjectAttribute(self, manageable, attributename, newattribute):
        """
        edit an objects attribute and ensure that a changed object representation is directly
        processed
        """
        oldname = self.getStringRepresentation(manageable)
        manageable.editAttribute(attributename, newattribute)
        newname = self.getStringRepresentation(manageable)
        print(newname, newattribute)
        if oldname != newname:
            self.chgManageableName(manageable, oldname, newname)

        self.notify(Message("Changed attribute %s of %s to %s" % (attributename, newname, newattribute), Message.MESSAGETYPE_INFO))