"""
$URL: svn+ssh://svn.mems-exchange.org/repos/trunk/dulcinea/lib/base.py $
$Id: base.py 27812 2006-01-13 16:52:28Z dbinger $

Provides DulcineaPersistent and Copyable.
"""
from durus.persistent import Persistent
from types import ClassType
import new


class Copyable:

    def copy (self):
        klass = self.__class__
        if type(klass) is ClassType:
            newself = new.instance(self.__class__, {})
        elif isinstance(klass, object):
            newself = klass.__new__(klass)
        else:
            raise RuntimeError, "unknown type of class object: %s" % `klass`
        newself.__dict__.update(self.__dict__)
        return newself

    def __copy__ (self):
        return self.copy()


class DulcineaPersistent (Persistent, Copyable):
    pass

