[Zope] __setstate__ not happening.

Lennart Regebro lennart@regebro.nu
Sun, 27 Jan 2002 13:26:47 +0100


From: "Lennart Regebro" <lennart@regebro.nu>
> I tried to upgrade my objects using __setstate__, but nothing happened. As
> far as I can tell, __setstate__ is not even called. Is there some other
> magic that needs to be done except creating the __setstate__ method?

OK, I found the bug, stupid me. It was just that Persistant.__setstate__ was
overriding my __setstate__ from a later subclass... :-)

But still, I'm not able to upgrade things properly. __setstate__ is executed
now, and it currently looks like this:

    def __setstate__(self, state):
        Persistent.__setstate__(self, state)
        if hasattr(self, '_object_workflow_version'):
            old_ver = self._object_workflow_version
        else:
            old_ver = '0.0'

        print "DEBUG, old version", old_ver
        if old_ver != '1.0':
            self._object_workflow_version = '1.0'
            #self.upgradeWorkflow()
        print self._object_workflow_version


This always have the same effect. When restarting the server, no objects
have the _object_workflow_version attribute. So I set it. After a server
restart, they are all gone again. I can change _object_workflow_version
without trouble if I do it somewhere else, but any changes to
_object_workflow_version or any otehr attributes I do in __setstate__
doesn't persist after a restart of Zope.

I don't get it.