Skip to content

Commit

Permalink
[fc] Repository: Products.CMFEditions
Browse files Browse the repository at this point in the history
Branch: refs/heads/master
Date: 2024-12-11T12:48:52-08:00
Author: David Glick (davisagli) <[email protected]>
Commit: plone/Products.CMFEditions@6ee7fb4

Fix handling of aq-wrapped objects in children modifiers

Files changed:
A news/26.bugfix
M Products/CMFEditions/StandardModifiers.py
Repository: Products.CMFEditions

Branch: refs/heads/master
Date: 2024-12-11T13:55:16-08:00
Author: David Glick (davisagli) <[email protected]>
Commit: plone/Products.CMFEditions@0627338

Merge pull request #117 from plone/26-aqbase

Fix handling of aq-wrapped objects in children modifiers

Files changed:
A news/26.bugfix
M Products/CMFEditions/StandardModifiers.py
  • Loading branch information
davisagli committed Dec 11, 2024
1 parent e05072d commit 92cd57e
Showing 1 changed file with 18 additions and 22 deletions.
40 changes: 18 additions & 22 deletions last_commit.txt
Original file line number Diff line number Diff line change
@@ -1,38 +1,34 @@
Repository: Products.validation
Repository: Products.CMFEditions


Branch: refs/heads/main
Date: 2024-12-10T13:58:27+01:00
Author: Maurits van Rees (mauritsvanrees) <[email protected]>
Commit: https://github.com/plone/Products.validation/commit/5747d5f8e6282321fa63e9139c7be5042d9a9ceb

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

``zope.i18n`` already supports recursive translation out of the box since 2008.
Branch: refs/heads/master
Date: 2024-12-11T12:48:52-08:00
Author: David Glick (davisagli) <[email protected]>
Commit: https://github.com/plone/Products.CMFEditions/commit/6ee7fb4e9d176f2e394bd2232c7271ba6f157aef

See https://github.com/plone/Products.validation/pull/14#discussion_r1878046252
Fix handling of aq-wrapped objects in children modifiers

Files changed:
A news/70.bugfix
M Products/validation/i18n.py
A news/26.bugfix
M Products/CMFEditions/StandardModifiers.py

b'diff --git a/Products/validation/i18n.py b/Products/validation/i18n.py\nindex 8e2f6a8..480179e 100644\n--- a/Products/validation/i18n.py\n+++ b/Products/validation/i18n.py\n@@ -1,5 +1,4 @@\n from zope.i18n import translate\n-from zope.i18nmessageid import Message\n from zope.i18nmessageid import MessageFactory\n \n \n@@ -12,15 +11,15 @@ def safe_unicode(value):\n \n def recursiveTranslate(message, **kwargs):\n """translates also the message mappings before translating the message.\n- if kwargs[\'REQUEST\'] is None, return the message untranslated\n- """\n \n- request = kwargs.get("REQUEST", None)\n+ if kwargs[\'REQUEST\'] is None, return the message untranslated\n \n- map = message.mapping\n- if map:\n- for key in map.keys():\n- if isinstance(map[key], Message):\n- map[key] = translate(map[key], context=request)\n+ Actually, recursive translation has been built into zope.i18n 3.5.0,\n+ which was already released in 2008. See\n+ https://github.com/zopefoundation/zope.i18n/blob/master/CHANGES.rst#350-2008-07-10\n \n+ So we can simply call the translate function.\n+ This avoids a TypeError in Zope 5.11+, as `map[key]` is immutable there.\n+ """\n+ request = kwargs.get("REQUEST", None)\n return translate(message, context=request)\ndiff --git a/news/70.bugfix b/news/70.bugfix\nnew file mode 100644\nindex 0000000..cbc3a55\n--- /dev/null\n+++ b/news/70.bugfix\n@@ -0,0 +1,3 @@\n+Remove unneeded code from ``recursiveTranslate`` that broke with latest Zope 5.11.\n+``zope.i18n`` already supports recursive translation out of the box since 2008.\n+[maurits]\n'
b'diff --git a/Products/CMFEditions/StandardModifiers.py b/Products/CMFEditions/StandardModifiers.py\nindex f32c25d5..50d03a08 100644\n--- a/Products/CMFEditions/StandardModifiers.py\n+++ b/Products/CMFEditions/StandardModifiers.py\n@@ -335,7 +335,7 @@ def persistent_id(obj):\n try:\n # return a non None value if it is one of the object\n # managers subobjects or raise an KeyError exception\n- return refs[id(obj)]\n+ return refs[id(aq_base(obj))]\n except KeyError:\n # signalize the pickler to just pickle the \'obj\' as\n # usual\ndiff --git a/news/26.bugfix b/news/26.bugfix\nnew file mode 100644\nindex 00000000..0a58eb0d\n--- /dev/null\n+++ b/news/26.bugfix\n@@ -0,0 +1,2 @@\n+Fix "Can\'t pickle objects in acquisition wrappers." error in\n+`OMOutsideChildrensModifier` and `OMInsideChildrensModifier`. @davisagli\n'

Repository: Products.validation
Repository: Products.CMFEditions


Branch: refs/heads/main
Date: 2024-12-10T09:45:17-08:00
Branch: refs/heads/master
Date: 2024-12-11T13:55:16-08:00
Author: David Glick (davisagli) <[email protected]>
Commit: https://github.com/plone/Products.validation/commit/494d29a1eceff4aa6de9ce4078f7380816880327
Commit: https://github.com/plone/Products.CMFEditions/commit/0627338eb36817ad3a5a96232425842fc861468c

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

Remove unneeded code from recursiveTranslate
Fix handling of aq-wrapped objects in children modifiers

Files changed:
A news/70.bugfix
M Products/validation/i18n.py
A news/26.bugfix
M Products/CMFEditions/StandardModifiers.py

b'diff --git a/Products/validation/i18n.py b/Products/validation/i18n.py\nindex 8e2f6a8..480179e 100644\n--- a/Products/validation/i18n.py\n+++ b/Products/validation/i18n.py\n@@ -1,5 +1,4 @@\n from zope.i18n import translate\n-from zope.i18nmessageid import Message\n from zope.i18nmessageid import MessageFactory\n \n \n@@ -12,15 +11,15 @@ def safe_unicode(value):\n \n def recursiveTranslate(message, **kwargs):\n """translates also the message mappings before translating the message.\n- if kwargs[\'REQUEST\'] is None, return the message untranslated\n- """\n \n- request = kwargs.get("REQUEST", None)\n+ if kwargs[\'REQUEST\'] is None, return the message untranslated\n \n- map = message.mapping\n- if map:\n- for key in map.keys():\n- if isinstance(map[key], Message):\n- map[key] = translate(map[key], context=request)\n+ Actually, recursive translation has been built into zope.i18n 3.5.0,\n+ which was already released in 2008. See\n+ https://github.com/zopefoundation/zope.i18n/blob/master/CHANGES.rst#350-2008-07-10\n \n+ So we can simply call the translate function.\n+ This avoids a TypeError in Zope 5.11+, as `map[key]` is immutable there.\n+ """\n+ request = kwargs.get("REQUEST", None)\n return translate(message, context=request)\ndiff --git a/news/70.bugfix b/news/70.bugfix\nnew file mode 100644\nindex 0000000..cbc3a55\n--- /dev/null\n+++ b/news/70.bugfix\n@@ -0,0 +1,3 @@\n+Remove unneeded code from ``recursiveTranslate`` that broke with latest Zope 5.11.\n+``zope.i18n`` already supports recursive translation out of the box since 2008.\n+[maurits]\n'
b'diff --git a/Products/CMFEditions/StandardModifiers.py b/Products/CMFEditions/StandardModifiers.py\nindex f32c25d5..50d03a08 100644\n--- a/Products/CMFEditions/StandardModifiers.py\n+++ b/Products/CMFEditions/StandardModifiers.py\n@@ -335,7 +335,7 @@ def persistent_id(obj):\n try:\n # return a non None value if it is one of the object\n # managers subobjects or raise an KeyError exception\n- return refs[id(obj)]\n+ return refs[id(aq_base(obj))]\n except KeyError:\n # signalize the pickler to just pickle the \'obj\' as\n # usual\ndiff --git a/news/26.bugfix b/news/26.bugfix\nnew file mode 100644\nindex 00000000..0a58eb0d\n--- /dev/null\n+++ b/news/26.bugfix\n@@ -0,0 +1,2 @@\n+Fix "Can\'t pickle objects in acquisition wrappers." error in\n+`OMOutsideChildrensModifier` and `OMInsideChildrensModifier`. @davisagli\n'

0 comments on commit 92cd57e

Please sign in to comment.