Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better exception if multiple translations for same language are found #377

Open
adrianschulz opened this issue Aug 20, 2020 · 0 comments
Open

Comments

@adrianschulz
Copy link

I noticed some weird behavior for some of my translated pages:

  • No translation is shown in "Manage Translations"
  • But adding a translation is not possible (error in Backend).

Also, I had problems with rejecting working copies (from plone.app.iterate).

In the logs there was the following error message:

instance8e.log-Traceback (innermost last):
instance8e.log-  Module ZPublisher.WSGIPublisher, line 156, in transaction_pubevents
instance8e.log-  Module ZPublisher.WSGIPublisher, line 338, in publish_module
instance8e.log-  Module ZPublisher.WSGIPublisher, line 256, in publish
instance8e.log-  Module ZPublisher.mapply, line 85, in mapply
instance8e.log-  Module ZPublisher.WSGIPublisher, line 62, in call_object
instance8e.log-  Module plone.z3cform.layout, line 63, in __call__
instance8e.log-  Module plone.z3cform.layout, line 47, in update
instance8e.log-  Module plone.dexterity.browser.edit, line 58, in update
instance8e.log-  Module plone.z3cform.fieldsets.extensible, line 65, in update
instance8e.log-  Module plone.z3cform.patch, line 30, in GroupForm_update
instance8e.log-  Module z3c.form.group, line 145, in update
instance8e.log-  Module plone.app.z3cform.csrf, line 22, in execute
instance8e.log-  Module z3c.form.action, line 98, in execute
instance8e.log-  Module z3c.form.button, line 315, in __call__
instance8e.log-  Module z3c.form.button, line 170, in __call__
instance8e.log-  Module plone.dexterity.browser.edit, line 30, in handleApply
instance8e.log-  Module z3c.form.group, line 126, in applyChanges
instance8e.log-  Module zope.event, line 32, in notify
instance8e.log-  Module zope.component.event, line 27, in dispatch
instance8e.log-  Module zope.component._api, line 124, in subscribers
instance8e.log-  Module zope.interface.registry, line 442, in subscribers
instance8e.log-  Module zope.interface.adapter, line 607, in subscribers
instance8e.log-  Module zope.component.event, line 36, in objectEventNotify
instance8e.log-  Module zope.component._api, line 124, in subscribers
instance8e.log-  Module zope.interface.registry, line 442, in subscribers
instance8e.log-  Module zope.interface.adapter, line 607, in subscribers
instance8e.log-  Module plone.app.multilingual.dx.subscriber, line 49, in __call__
instance8e.log-  Module plone.app.multilingual.dx.subscriber, line 87, in handle_modified
instance8e.log-  Module plone.app.multilingual.dx.cloner, line 63, in copy_fields
instance8e.log:AttributeError: 'NoneType' object has no attribute 'get_language'

I investigated further (with debug-mode) and noticed that the page had two English translations. I don't know how this happened but as you see in the debug-output, this is the current state.

>>> from plone.app.multilingual.interfaces import ITranslationManager
>>> from Products.CMFCore.utils import getToolByName
>>> from plone.app.multilingual.dx.subscriber import LanguageIndependentModifier
>>> reg_org = app.Plone.de.studium.wirtschaft.reglemente
>>> site = app.Plone
>>> tm  = ITranslationManager(reg_org)
>>> cat = getToolByName(site, 'portal_catalog')
>>> lim = LanguageIndependentModifier()
>>> tm.get_translations()
{'en': <Folder at /Plone/en/degree-programmes/business/regulations/media>, 'de': <FolderishDocument at /Plone/de/studium/wirtschaft/reglemente>}
>>> tm.get_translation('en')
>>> lim.get_all_translations(reg_org)
['en']
>>> brains = cat.searchResults(TranslationGroup=tm.tg, Language='en')
>>> ['%s - %s' % (brain.Language, brain.getPath()) for brain in brains]
['en - /Plone/en/degree-programmes/business/regulations', 'en - /Plone/en/degree-programmes/business/regulations/media']

It's definitely not normal to have two translations for the same language. But what I wished for was a better error message.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants