Skip to content

Commit

Permalink
Removing Portal Language Tool
Browse files Browse the repository at this point in the history
  • Loading branch information
bloodbare committed Mar 2, 2015
1 parent 23fe74b commit f48ab56
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 1 deletion.
6 changes: 6 additions & 0 deletions plone/app/upgrade/__init__.py
Expand Up @@ -115,3 +115,9 @@ def getNonInstallableProducts(self):
else:
from Products.ATContentTypes.tool import metadata
alias_module('Products.CMFPlone.MetadataTool', metadata)

try:
from Products.PloneLanguageTool import interfaces
except ImportError:
alias_module('Products.PloneLanguageTool.interfaces', bbb)
alias_module('Products.PloneLanguageTool.LanguageTool', bbb)
16 changes: 16 additions & 0 deletions plone/app/upgrade/bbb.py
@@ -1,6 +1,7 @@
from OFS.SimpleItem import SimpleItem
from Products.CMFCore.utils import registerToolInterface
from zope.interface import Interface
from ZPublisher import BeforeTraverse


CalendarTool = SimpleItem
Expand All @@ -11,6 +12,21 @@
TinyMCE = SimpleItem


class LanguageTool(SimpleItem):

def __call__(self, container, req):
pass

def manage_beforeDelete(self, item, container):
if item is self:
handle = self.meta_type + '/' + self.getId()
BeforeTraverse.unregisterBeforeTraverse(container, handle)


class ILanguageTool(Interface):
pass


class ITinyMCE(Interface):
pass

Expand Down
64 changes: 64 additions & 0 deletions plone/app/upgrade/v50/betas.py
Expand Up @@ -3,15 +3,79 @@
from Products.CMFPlone.interfaces import IMailSchema
from Products.CMFPlone.interfaces import IMarkupSchema
from Products.CMFPlone.interfaces import ISecuritySchema
from Products.CMFPlone.interfaces import ILanguageSchema
from plone.app.upgrade.utils import loadMigrationProfile
from plone.registry.interfaces import IRegistry
from zope.component import getUtility
from zope.component.hooks import getSite
from Products.CMFCore.interfaces import ISiteRoot


def to50beta1(context):
"""5.0alpha3 -> 5.0beta1"""
loadMigrationProfile(context, 'profile-plone.app.upgrade.v50:to50beta1')
upgrade_portal_language(context)


def upgrade_portal_css_to_registry(context):
pass


def upgrade_portal_js_to_registry(context):
pass


def upgrade_portal_language(context):
portal = getSite()
registry = getUtility(IRegistry)
# XXX: Somehow this code is excecuted for old migration steps as well
# ( < Plone 4 ) and breaks because there is no registry. Looking up the
# registry interfaces with 'check=False' will not work, because it will
# return a settings object and then fail when we try to access the
# attributes.
try:
lang_settings = registry.forInterface(ILanguageSchema, prefix='plone')
except KeyError:
return
# Get old values

# Merge default language options to registry
portal = getUtility(ISiteRoot)
if portal.hasProperty('default_language'):
default_lang = portal.getProperty('default_language')

portal_properties = getToolByName(context, "portal_properties", None)
if portal_properties is not None:
site_properties = getattr(portal_properties, 'site_properties', None)
if site_properties is not None:
if site_properties.hasProperty('default_language'):
default_lang = site_properties.getProperty('default_language')

lang_settings.default_language = default_lang

portal_languages = getToolByName(context, "portal_languages")
lang_settings.available_languages = portal_languages.supported_langs

lang_settings.use_combined_language_codes = portal_languages.use_combined_language_codes
lang_settings.display_flags = portal_languages.display_flags

lang_settings.use_path_negotiation = portal_languages.use_path_negotiation
lang_settings.use_content_negotiation = portal_languages.use_content_negotiation
lang_settings.use_cookie_negotiation = portal_languages.use_cookie_negotiation
lang_settings.set_cookie_always = portal_languages.set_cookie_everywhere
lang_settings.authenticated_users_only = portal_languages.authenticated_users_only
lang_settings.use_request_negotiation = portal_languages.use_request_negotiation
lang_settings.use_cctld_negotiation = portal_languages.use_cctld_negotiation
lang_settings.use_subdomain_negotiation = portal_languages.use_subdomain_negotiation
# portal_languages.force_language_urls = 1
# portal_languages.allow_content_language_fallback = 0
# start_neutral = 0

# Used by functional tests.
# always_show_selector = 0

# Remove the old tool
portal.manage_delObjects('portal_languages')


def upgrade_mail_controlpanel_settings(context):
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -68,7 +68,7 @@
'Products.DCWorkflow',
'Products.GenericSetup',
'Products.MimetypesRegistry',
'Products.PloneLanguageTool',
# 'Products.PloneLanguageTool',
'Products.PlonePAS',
'Products.PluggableAuthService',
'Products.PortalTransforms',
Expand Down

0 comments on commit f48ab56

Please sign in to comment.