ZODB Object evolution and class variables ?

Andreas Martin a.martin at perfectwww.de
Mon Nov 4 16:52:18 EST 2002


Hallo !

I'm a Zopenewbie and just experimenting with own Zope Python products.
I created e sample News Product that should automatically set the id
of a new instance to an autogenerated number.

The class looks like this:

class News(SimpleItem):
    "A News object"

    meta_type = "News"

    actualKey = 0

    def __init__(self, teaser):
        self.key          = News.actualKey
        News.actualKey   += 1
        self.id           = str(self.key)
        self.teaser       = teaser

That's ok but when I change the class definition I have the problem
that my class variable "actualkey" starts again by 0.

I managed to add new instance attributes like "teaser" and a
__setstate__ function is working fine.

My only problem is the global class variable, that is changed to 0
when I refresh my product in the zope management interface.

Thanks for help



More information about the Python-list mailing list