You'll need to traverse your whole ZODB manually, I'm afraid. If these objects are content objects, you should be able to use the standard OFS methods:
from collections import deque
from datetime import datetime
import transaction
from zope.app.component.hooks import setSite
from Testing.makerequest import makerequest
from AccessControl.SecurityManagement import newSecurityManager
from my.newproduct.types import ArchetypesContentType
site_id = 'Plone' # adjust to match your Plone site object id.
admin_user = 'admin' # usually 'admin', probably won't need adjusting
app = makerequest(app)
site = app[site_id]
setSite(site)
user = app.acl_users.getUser(admin_user).__of__(site.acl_users)
newSecurityManager(None, user)
def treeWalker(root):
# stack holds (parent, id, obj) tuples
stack = deque([(None, None, root)])
while stack:
parent, id, next = stack.popleft()
try:
stack.extend((next, id, child) for id, child in next.objectItems())
except AttributeError:
# No objectItems method
pass
yield parent, id, next
count = 0
for parent, id, obj in treeWalker(site):
if isinstance(obj, ArchetypesContentType):
print 'Found content type object {} at {}'.format(id, '/'.join(object.getPhysicalPath()))
obj._p_changed = True # mark it as changed, force a commit
count += 1
if count % 100 == 0:
# flush changes so far to disk to minimize memory usage
transaction.savepoint(True)
print '{} - Processed {} items'.format(datetime.now(), count)
transaction.commit()
This assumes you already included the work-around you linked to; there is little point in trying to do the above with ZODB.broken.Broken
objects.
The above script acts as a bin/instance run
script, run it as such:
bin/instance run path/to/this/script.py
You are going to process everything in the site, a fairly hefty process that will involve a lot of cache churn and possibly a large commit with potential conflicts. You do not want to run this as a through-the-web script, really.