Broken objects occur when the class for a pickled object cannot be imported. To change the location of a class, you need to provide an alias at the old location so that the object can be unpickled, i.e. MyOldClassName = MyNewClassName. You can only remove MyOldClassName after you have updated all of the pickles (with your code below).
Laurence Adam GROSZER wrote: > Hello, > > I'm having a problem with broken objects here. > It's coming when I'm trying to evolve generations and the generation > just touches all objects in the ZODB to store them again with the > non-deprecated classes. > > The code is like this: > storage = context.connection._storage > > next_oid = None > n = 0 > while True: > oid, tid, data, next_oid = storage.record_iternext(next_oid) > > obj = context.connection.get(oid) > # Make sure that we tell all objects that they have been changed. Who > # cares whether it is true! :-) > obj._p_activate() > obj._p_changed = True > > if next_oid is None: > break > > > 2008-11-04T19:40:16 ERROR SiteError > http://localhost:8080/++etc++process/@@generations.html > Traceback (most recent call last): > File "F:\W\Zope3\src\zope\publisher\publish.py", line 133, in publish > result = publication.callObject(request, obj) > ... > File "F:\W\Zope3\src\zope\tal\talinterpreter.py", line 343, in interpret > handlers[opcode](self, args) > File "F:\W\Zope3\src\zope\tal\talinterpreter.py", line 583, in > do_setLocal_tal > self.engine.setLocal(name, self.engine.evaluateValue(expr)) > File "F:\W\Zope3\src\zope\tales\tales.py", line 696, in evaluate > return expression(self) > File "F:\W\Zope3\src\zope\tales\expressions.py", line 217, in __call__ > return self._eval(econtext) > File "F:\W\Zope3\src\zope\tales\expressions.py", line 211, in _eval > return ob() > File "F:\W\Zope3\src\zope\app\generations\browser\managers.py", line 182, > in evolve > transaction.commit() > File "F:\W\Zope3\src\transaction\_manager.py", line 93, in commit > return self.get().commit() > File "F:\W\Zope3\src\transaction\_transaction.py", line 322, in commit > self._commitResources() > File "F:\W\Zope3\src\transaction\_transaction.py", line 416, in > _commitResources > rm.commit(self) > File "F:\W\Zope3\src\ZODB\Connection.py", line 541, in commit > self._commit(transaction) > File "F:\W\Zope3\src\ZODB\Connection.py", line 586, in _commit > self._store_objects(ObjectWriter(obj), transaction) > File "F:\W\Zope3\src\ZODB\Connection.py", line 620, in _store_objects > p = writer.serialize(obj) # This calls __getstate__ of obj > File "F:\W\Zope3\src\ZODB\serialize.py", line 405, in serialize > meta = klass, newargs() > File "F:\W\Zope3\src\ZODB\broken.py", line 325, in __getnewargs__ > return self.__Broken_newargs__ > AttributeError: 'VocabularyManager' object has no attribute > '__Broken_newargs__' > > _______________________________________________ For more information about ZODB, see the ZODB Wiki: http://www.zope.org/Wikis/ZODB/ ZODB-Dev mailing list - ZODB-Dev@zope.org http://mail.zope.org/mailman/listinfo/zodb-dev