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

Add workaround for compatibility with zope.i18nmessageid 7.0 #14

Closed
wants to merge 1 commit into from

Conversation

mauritsvanrees
Copy link
Member

This is for Zope 5.11 which I want to add in Plone 6.0.

This would throw a TypeError in our recursiveTranslate function. For now work around it: leave the recursive parts untranslated.

Sample test failure:

Error in test test_isDecimal (Products.validation.tests.test_validation.TestValidation.test_isDecimal)
Traceback (most recent call last):
  File "/Users/maurits/.pyenv/versions/3.12.8/lib/python3.12/unittest/case.py", line 58, in testPartExecutor
    yield
  File "/Users/maurits/.pyenv/versions/3.12.8/lib/python3.12/unittest/case.py", line 634, in run
    self._callTestMethod(testMethod)
  File "/Users/maurits/.pyenv/versions/3.12.8/lib/python3.12/unittest/case.py", line 589, in _callTestMethod
    if method() is not None:
  File "/Users/maurits/community/plone-coredev/6.0/src/Products.validation/Products/validation/tests/test_validation.py", line 62, in test_isDecimal
    v("NaN"), "Validation failed(isDecimal): 'NaN' is not a decimal number."
  File "/Users/maurits/community/plone-coredev/6.0/src/Products.validation/Products/validation/validators/RegexValidator.py", line 74, in __call__
    return recursiveTranslate(msg, **kwargs)
  File "/Users/maurits/community/plone-coredev/6.0/src/Products.validation/Products/validation/i18n.py", line 24, in recursiveTranslate
    map[key] = translate(map[key], context=request)
TypeError: 'mappingproxy' object does not support item assignment

A proper fix would require further investigation, also into whether the affected function is actually still needed. But I currently don't want to do that in this old package. Core Plone does not use it. But in the coredev buildout on 6.0 its tests are still run. And this may affect collective.z3cform which uses it. I did not check.

….11).

This would throw a TypeError in our `recursiveTranslate` function.
For now work around it: leave the recursive parts untranslated.

Sample test failure:

```
Error in test test_isDecimal (Products.validation.tests.test_validation.TestValidation.test_isDecimal)
Traceback (most recent call last):
  File "/Users/maurits/.pyenv/versions/3.12.8/lib/python3.12/unittest/case.py", line 58, in testPartExecutor
    yield
  File "/Users/maurits/.pyenv/versions/3.12.8/lib/python3.12/unittest/case.py", line 634, in run
    self._callTestMethod(testMethod)
  File "/Users/maurits/.pyenv/versions/3.12.8/lib/python3.12/unittest/case.py", line 589, in _callTestMethod
    if method() is not None:
  File "/Users/maurits/community/plone-coredev/6.0/src/Products.validation/Products/validation/tests/test_validation.py", line 62, in test_isDecimal
    v("NaN"), "Validation failed(isDecimal): 'NaN' is not a decimal number."
  File "/Users/maurits/community/plone-coredev/6.0/src/Products.validation/Products/validation/validators/RegexValidator.py", line 74, in __call__
    return recursiveTranslate(msg, **kwargs)
  File "/Users/maurits/community/plone-coredev/6.0/src/Products.validation/Products/validation/i18n.py", line 24, in recursiveTranslate
    map[key] = translate(map[key], context=request)
TypeError: 'mappingproxy' object does not support item assignment

```
@mister-roboto
Copy link

@mauritsvanrees thanks for creating this Pull Request and helping to improve Plone!

TL;DR: Finish pushing changes, pass all other checks, then paste a comment:

@jenkins-plone-org please run jobs

To ensure that these changes do not break other parts of Plone, the Plone test suite matrix needs to pass, but it takes 30-60 min. Other CI checks are usually much faster and the Plone Jenkins resources are limited, so when done pushing changes and all other checks pass either start all Jenkins PR jobs yourself, or simply add the comment above in this PR to start all the jobs automatically.

Happy hacking!

@mauritsvanrees
Copy link
Member Author

@jenkins-plone-org please run jobs

mauritsvanrees added a commit to plone/buildout.coredev that referenced this pull request Dec 6, 2024
Python 3.8 is out of security support, so I will officially drop it from Plone 6.0 soon.  As we say in the [release schedule](https://plone.org/download/release-schedule): "Plone 6.0 works on Python 3.8, but this Python version reaches end of life in October 2024. At that point, Plone 6 will drop support for Python 3.8."  See also plone/jenkins.plone.org#377

We also need to stop testing on macos-12 as it may fail soon.  See #967
Updated to macos-13 for now.

Updated pip, setuptools, buildout.
For the moment I kept setuptools at the highest version that still supports Python 3.8, but I want to increase that.  It would break Jenkins currently without the other PR I mentioned.

Update Zope to latest 5.11.1.

I will make this a draft PR, as the `Products.validation` tests fail due to an updated `zope.i18nmessageid`.  I am preparing a workaround for that:
plone/Products.validation#14
# if this is properly fixable or even if recursiveTranslate
# is no longer needed. For now work around it:
# leave this part untranslated.
break
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mauritsvanrees Zope messageids were always supposed to be immutable, so this change sounds like a bugfix. Probably what we should do here is construct a new mapping with all the translations, and then construct a new messageid to pass to translate.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had a chance to try it out for real now, with easyform. This made me see that the recursive translation in here is not needed: it is already done in the translate function that we call from zope.i18n.

In fact, this has already been there since 2008. :-)
See changelog of 3.5.0.

I will close this PR and open a new one.

mauritsvanrees added a commit that referenced this pull request Dec 10, 2024
…st Zope 5.11.

``zope.i18n`` already supports recursive translation out of the box since 2008.

See #14 (comment)
@mauritsvanrees mauritsvanrees deleted the maurits-mappingproxy-workaround branch December 10, 2024 13:03
mister-roboto pushed a commit to plone/buildout.coredev that referenced this pull request Dec 10, 2024
Branch: refs/heads/main
Date: 2024-12-10T13:58:27+01:00
Author: Maurits van Rees (mauritsvanrees) <maurits@vanrees.org>
Commit: plone/Products.validation@5747d5f

Remove unneeded code from ``recursiveTranslate`` that broke with latest Zope 5.11.

``zope.i18n`` already supports recursive translation out of the box since 2008.

See plone/Products.validation#14 (comment)

Files changed:
A news/70.bugfix
M Products/validation/i18n.py
Repository: Products.validation

Branch: refs/heads/main
Date: 2024-12-10T09:45:17-08:00
Author: David Glick (davisagli) <david@glicksoftware.com>
Commit: plone/Products.validation@494d29a

Merge pull request #15 from plone/maurits-recursive-translate-simplify

Remove unneeded code from recursiveTranslate

Files changed:
A news/70.bugfix
M Products/validation/i18n.py
mauritsvanrees added a commit to plone/buildout.coredev that referenced this pull request Dec 10, 2024
Python 3.8 is out of security support, so I will officially drop it from Plone 6.0 soon.  As we say in the [release schedule](https://plone.org/download/release-schedule): "Plone 6.0 works on Python 3.8, but this Python version reaches end of life in October 2024. At that point, Plone 6 will drop support for Python 3.8."  See also plone/jenkins.plone.org#377

We also need to stop testing on macos-12 as it may fail soon.  See #967
Updated to macos-13 for now.

Updated pip, setuptools, buildout.
For the moment I kept setuptools at the highest version that still supports Python 3.8, but I want to increase that.  It would break Jenkins currently without the other PR I mentioned.

Update Zope to latest 5.11.1.

I will make this a draft PR, as the `Products.validation` tests fail due to an updated `zope.i18nmessageid`.  I am preparing a workaround for that:
plone/Products.validation#14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants