Skip to content

Instantly share code, notes, and snippets.

@jensens
Created July 22, 2016 15:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jensens/356ab35614c4c0a7c626d8ba4a7a8479 to your computer and use it in GitHub Desktop.
Save jensens/356ab35614c4c0a7c626d8ba4a7a8479 to your computer and use it in GitHub Desktop.
Cleanup LRF from ordering garbage. Upgrades plone.app.multilingual 2.0a3 to 2.0.1
<configure
xmlns="http://namespaces.zope.org/zope"
xmlns:browser="http://namespaces.zope.org/browser"
xmlns:zcml="http://namespaces.zope.org/zcml">
<browser:page
class=".upgradelrf.Upgrade"
for="plone.app.multilingual.content.lrf.LanguageRootFolder"
name="lp-migrate-lrf"
permission="cmf.ManagePortal"
/>
</configure>
# -*- coding: utf-8 -*-
from zope.publisher.browser import BrowserView
blacklist = [
'acl_users',
'archetype_tool',
'caching_policy_manager',
'content_type_registry',
'error_log',
'HTTPCache',
'MailHost',
'mimetypes_registry',
'plone_utils',
'portal_actionicons',
'portal_actions',
'portal_archivist',
'portal_atct',
'portal_calendar',
'portal_catalog',
'portal_controlpanel',
'portal_css',
'portal_diff',
'portal_discussion',
'portal_factory',
'portal_form_controller',
'portal_groupdata',
'portal_groups',
'portal_historiesstorage',
'portal_historyidhandler',
'portal_interface',
'portal_javascripts',
'portal_languages',
'portal_memberdata',
'portal_membership',
'portal_metadata',
'portal_migration',
'portal_modifier',
'portal_password_reset',
'portal_properties',
'portal_purgepolicy',
'portal_quickinstaller',
'portal_referencefactories',
'portal_registration',
'portal_registry',
'portal_repository',
'portal_setup',
'portal_skins',
'portal_tinymce',
'portal_transforms',
'portal_types',
'portal_uidannotation',
'portal_uidgenerator',
'portal_uidhandler',
'portal_undo',
'portal_url',
'portal_view_customizations',
'portal_workflow',
'RAMCache',
'reference_catalog',
'ResourceRegistryCache',
'translation_service',
'uid_catalog',
# here all the LRF ids need to be listed
'de',
'en',
]
class Upgrade(BrowserView):
def __call__(self):
result = ['Check for garbage in ordering....']
order = self.context.getOrdering()
to_remove = []
for oid in order._order():
if oid in blacklist:
to_remove.append(oid)
for oid in to_remove:
order.notifyRemoved(oid)
result.append('{0} removed from pos+order'.format(oid))
return '\n'.join(result)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment