Dump the workflow states
Thankfully, I have lots of backups. Even better, I have a QA server, which has a pretty recent snapshot from Production. If I can see what states the items had before I messed them up, then I could reset the ones that are wrong. (If it's too many to do manually, I can always hack a python script, right?)
I tried several different approaches. This one actually worked:
def dump_catalog_by_state():
#Import stuff and set up environment.
from Products.CMFCore.utils import getToolByName
from AccessControl.SecurityManagement import newSecurityManager
from Products.CMFCore.tests.base.security import OmnipotentUser
admin = OmnipotentUser()
newSecurityManager(None, admin)
OUTPUT_PATH = '/var/tmp/dump/'
#Now do it.
print "Getting list of plone sites...",
#getPloneSites is our own custom Script python.
#You could give it a list of site objects, I suppose.
sites = app.getPloneSites()
print "Found %s site(s)." % len(sites)
for site in sites:
catalog = getToolByName(site, 'portal_catalog')
states = ['open', 'pending', 'private', 'restricted', ]
for state in states:
print "Querying '%s' catalog for items in the '%s' state" % (site.id, state),
items = catalog({'review_state': state})
print "Found %s item(s)." % len(items)
urls = [item.getPath() + '\n' for item in items]
#Dump to file.
filename = "%s%s-%s" % (OUTPUT_PATH, site.id, state)
print "Dumping to %s" % filename,
dump = file(filename, "w")
dump.writelines(urls)
dump.close()
print "Dumped."
I copied-and-pasted this function into the debug shell (bin/instance debug) and ran it. Out came a lot of text files! This is exactly the information I needed.
