"""
$URL: svn+ssh://svn.mems-exchange.org/repos/trunk/dulcinea/lib/base.py $
$Id: base.py 31344 2008-11-21 20:45:40Z dbinger $
"""
from durus.persistent import PersistentObject
from copy import copy
from qp.lib.spec import Specified, Mixin

class Copyable (Mixin):

    def copy(self):
        return copy(self)


class DulcineaPersistent (PersistentObject, Specified, Copyable):


    def __copy__(self):
        new_instance = PersistentObject.__new__(self.__class__)
        new_instance.__setstate__(self.__getstate__())
        return new_instance

    def __eq__(self, other):
        return (self.__class__ == getattr(other, '__class__', None) and
            other.__getstate__() == self.__getstate__())

    def __ne__(self, other):
        return not self == other

    def __hash__(self):
        return id(self)
