CMFBoardUninstaller.py
Click here to get the file
Size
2.5 kB
-
File type
text/x-python
File contents
# -*- coding: latin-1 -*-
from cStringIO import StringIO
def uninstall(self):
"""
Uninstalls cmfboard from your Plone site. It deletes all discussions in the
process!
if you need your discussions, you must write your own script to export them,
and then import them again using plones portal discussion.
"""
# first we find *all* objects. If they have a talkback attribute, the
# discussions should be saved in the csv file, and the talkback attribute
# deleted.
# set up printer
out = StringIO()
pr = lambda st: out.write('%s\n' % str(st))
printed = out.getvalue
portal = self.portal_url.getPortalObject()
pr('start')
######
# Delete the talkback attribute on all objects
objects = self.ZopeFind(self, obj_metatypes=[], search_sub=1)
for path, obj in objects:
if hasattr(obj, 'talkback'):
pr('Deleted - %s: %s' % (path, obj.title_or_id()))
del obj.talkback
######
# Delete cmfboard content types
board_types = [
'ForumContentTopic', 'ForumContentTopic', 'ForumFolder', 'ForumMessage',
'ForumNB', 'ForumPoll', 'ForumTopic'
]
objects = self.ZopeFind(self, obj_metatypes=board_types, search_sub=1)
for path, obj in objects[::-1]: # delete backwards, to avoid deleting parents first
parent = obj.aq_parent
parent.manage_delObjects([obj.getId()])
pr('Deleted object at: ' + path)
if not objects:
pr('No CMFBoard content to delete')
######
# Uninstall cmfboard in the quickinstaller
pr('Uninstalling CMFBoard from plone instance via. quickinstaller')
self.portal_quickinstaller.uninstallProducts(products=['CMFBoard'])
# # uncomment this block if you need to remove the PortalTransport product
# # Keeping it, doesn't break the site.
# pr('Uninstalling PortalTransport from plone instance via. quickinstaller')
# self.portal_quickinstaller.uninstallProducts(products=['PortalTransport'])
######
# reinstall plones portal_discussion from the zmi
if hasattr(portal, 'portal_discussion'):
pr('Deleting the cmfboard discussion tool')
portal.manage_delObjects(['portal_discussion'])
if not hasattr(portal, 'portal_discussion'):
pr('Adding default discussion tool')
portal.manage_addProduct['CMFPlone'].manage_addTool('Plone Discussion Tool')
pr('done')
return printed()
Created by
maxm
Last modified
2005-03-07 03:46 PM