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

Update to Zope 4.0b7 #2590

Closed
3 tasks done
pbauer opened this issue Oct 11, 2018 · 23 comments
Closed
3 tasks done

Update to Zope 4.0b7 #2590

pbauer opened this issue Oct 11, 2018 · 23 comments

Comments

@pbauer
Copy link
Member

pbauer commented Oct 11, 2018

Zope 4.0b6 is out (https://community.plone.org/t/zope-4-0b6-released/7345/1). Updating the extends to the new version-pinns fails in multiple ways (in 5.2 coredev but also in py3 and py3_on_py2).

Here we collect issues that need to be adressed/fixed:

@icemac
Copy link

icemac commented Oct 16, 2018

There will be a 4.0b7 in the near feature containing some bug fixes for 4.0b6.

@thet
Copy link
Member

thet commented Oct 16, 2018

For #2547 there might be a simple solution which is discussed in the ticket.

@pbauer
Copy link
Member Author

pbauer commented Oct 18, 2018

With plone/buildout.coredev#537 I combined the update to 4.0b6 with the fixed ZODB and fixes for #2591. The jenkins-jobs results will show all cases where __repr__ breaks the tests:

@pbauer
Copy link
Member Author

pbauer commented Oct 18, 2018

All failing tests are all caused to the change of __repr__. Once zopefoundation/Zope#379 is done we can safely update to 4.0b6 without touching all the failing doctests:

Products.CMFPlone.tests.test_safe_formatter.TestSafeFormatter.test_cook_zope2_page_templates_good_format_attr_str
Products.CMFPlone.tests.test_safe_formatter.TestSafeFormatter.test_cook_zope2_page_templates_good_format_attr_unicode
Products.CMFPlone.tests.test_safe_formatter.TestSafeFormatter.test_cook_zope2_page_templates_good_str
Products.CMFPlone.tests.test_safe_formatter.TestSafeFormatter.test_cook_zope2_page_templates_good_unicode
Products.CMFPlone.tests.test_safe_formatter.TestSafeFormatter.test_cook_zope3_page_templates_normal
Products.CMFPlone.tests.test_safe_formatter.TestSafeFormatter.test_cook_zope3_page_templates_using_format
Products.ATContentTypes.tests.events.txt
Products.Archetypes.tests.events.txt
Products.CMFPlacefulWorkflow.tests.exportimport.txt
Products.CMFQuickInstallerTool.tests.actions.txt
Products.CMFQuickInstallerTool.tests.install.txt
Products.CMFQuickInstallerTool.tests.profiles.txt
five.intid.README.rst
plone.app.contentlisting.tests.integration.rst
plone.app.versioningbehavior.tests.doctest_behavior.txt
plone.app.viewletmanager.tests.storage.rst
plone.registry.field.rst
plone.registry.registry.rst
src.plone.app.blob.README.txt
src.plone.app.imaging.tests.traversal.txt
src.plone.app.testing.layers.rst
plone.app.contentrules.tests.test_action_logger.TestLoggerAction.testProcessedMessage

@pbauer
Copy link
Member Author

pbauer commented Oct 24, 2018

I did a new testrun with the newest versions from https://raw.githubusercontent.com/zopefoundation/Zope/master/versions.cfg and the branch zopefoundation/Zope#387 which restores the old __repr__ in OFS. There may be exciting new failures.

One failure is already adressed in zopefoundation/Products.GenericSetup#75

@icemac
Copy link

icemac commented Oct 25, 2018

  • Products.CMFQuickInstallerTool.tests.actions.txt: CMFQuickInstallerTool seems to need the new OFS.SimpleItem.PathReprProvider as first base class, so its __repr__ is in the MRO before persistent.Persistent.
  • plone.app.contentlisting.tests.integration.rst: Same here for plone.app.contenttypes.content.Folder
  • plone.app.versioningbehavior.tests.doctest_behavior.txt: Same here for plone.dexterity.content.Container.
  • plone.contentrules.README.rst: <builtins.MoveToFolderAction object at is current for persistent >= 4.4.3.
  • Products.Archetypes.tests.translate.txt is broken because of the changes in zope.i18n 4.6 (aka plurals support)

@pbauer
Copy link
Member Author

pbauer commented Oct 25, 2018

I don't understand where the __repr__ of persistent.Persistent takes precedence over the one from OFS.SimpleItem. Here is the chain as I understand it:

plone.app.contenttypes.content.Folder(Container)
plone.dexterity.content.Container(OFSContainer, CMFCatalogAware, PortalFolderBase, PortalContent, DefaultDublinCoreImpl, Contained)
Products.CMFCore.PortalFolder.PortalFolderBase(DynamicType, OpaqueItemManager, Folder)
OFS.Folder.Folder(PathReprProvider,...)
OFS.SimpleItem.PathReprProvider

Can you give me a hint?

@icemac
Copy link

icemac commented Oct 25, 2018

persistent.Persistent is implemented in C. This fact seems to change the MRO so it always comes before the classes implemented in Python. See pylint-dev/pylint#2188 where I got to know about this fact.

@pbauer
Copy link
Member Author

pbauer commented Oct 25, 2018

🤦‍♂️

@pbauer
Copy link
Member Author

pbauer commented Oct 25, 2018

I see that changing the first base-class of plone.dexterity.content.Container to PathReprProvider fixes the reprs for folderish dexterity content. It feels super-ugly though. Having a completely different repr for Item and Container is a no-go though, so I'll probably add that.

Are we planning to add the physical path like in PathReprProvider to the __repr__ of persistent.Persistent at some point? I can see value in having the oid and connection-info on top the full-python path and the physical path.

Also: That base-classes implemented in C ruin the MRO is just very terrible.

@jamadden
Copy link

Are we planning to add the physical path like in PathReprProvider to the repr of persistent.Persistent at some point?

"path" is not a concept that Persistent has.

pbauer added a commit to plone/Products.Archetypes that referenced this issue Oct 26, 2018
@pbauer pbauer changed the title Update to Zope 4.0b6 Update to Zope 4.0b7 Oct 26, 2018
@pbauer
Copy link
Member Author

pbauer commented Oct 26, 2018

@jamadden
Copy link

Because Persistent's __repr__ first tries to delegate to a _p_repr, if present, I wonder if this could be solved without manually changing all those other classes' MRO by having PathReprProvider also set _p_repr (_p_repr = __repr__). That way, when the weird C MRO comes into play and finds Persistent's __repr__, Persistent can still find a correct _p_repr.

@pbauer
Copy link
Member Author

pbauer commented Oct 27, 2018

@jamadden Thanks for the tip, I'll test that.

@pbauer
Copy link
Member Author

pbauer commented Oct 27, 2018

Looks good. I'll wait for comments. Not requiring to add a new base-class that is only available in the newest Zope (even to deprecated Code such as Archetypes) would be much better.

@pbauer
Copy link
Member Author

pbauer commented Oct 27, 2018

@jamadden there are surprising test-errors in zopefoundation/Zope#392:

File "/home/travis/build/zopefoundation/Zope/src/Products/Five/browser/tests/pages.txt", line 291, in pages.txt
Failed example:
    aq_parent(aq_inner(context))
Expected:
    <Folder at /test_folder_1_> 
Got:
    <Folder at test_folder_1_>

Could it be that the C-implementation of returning _p_repr swallows the leading slash? My C-fu is non-existent.

@pbauer
Copy link
Member Author

pbauer commented Oct 27, 2018

Weird: The issue is actually in PathReprProvider.

When calling the same method as obj.__repr__() the output of '/'.join(self.getPhysicalPath()) is '/test_folder_1_' (correct).

But when calling the same method as as obj._p_repr() the output of the same same code '/'.join(self.getPhysicalPath()) is 'test_folder_1_' (without the leading /). I need to go watch Disney on Ice now but I'll continue investigating later today.

@pbauer
Copy link
Member Author

pbauer commented Oct 27, 2018

This can be reproduced in the test test_cook_zope3_page_templates_using_format:

aq_parent(aq_inner(self)) returns None when using __repr__, but when using _p_repr is returns <Application at >. So in the first case self seems to be not properly aq-wrapped. I re-added PathReprProvider to OFS.Folder.Folder in zopefoundation/Zope@b52bdd9 to work around that.

mister-roboto pushed a commit to plone/buildout.coredev that referenced this issue Oct 28, 2018
Branch: refs/heads/master
Date: 2018-10-25T09:05:20+02:00
Author: Philip Bauer (pbauer) <[email protected]>
Commit: plone/Products.CMFQuickInstallerTool@c67fab5

fix test with changed repr (see plone/Products.CMFPlone#2590 (comment))

Files changed:
M Products/CMFQuickInstallerTool/tests/actions.txt
M Products/CMFQuickInstallerTool/tests/install.txt
M Products/CMFQuickInstallerTool/tests/profiles.txt
Repository: Products.CMFQuickInstallerTool

Branch: refs/heads/master
Date: 2018-10-28T11:33:19+01:00
Author: Philip Bauer (pbauer) <[email protected]>
Commit: plone/Products.CMFQuickInstallerTool@81696c5

Merge pull request #21 from plone/fix_repr_change

fix test with changed repr

Files changed:
M Products/CMFQuickInstallerTool/tests/actions.txt
M Products/CMFQuickInstallerTool/tests/install.txt
M Products/CMFQuickInstallerTool/tests/profiles.txt
@pbauer
Copy link
Member Author

pbauer commented Oct 28, 2018

My fix in zopefoundation/Zope#392 passes in Zope itself but fails in Plone in several tests (https://jenkins.plone.org/job/pull-request-5.2-3.6/34/testReport/) with similar issue as above:

(Pdb++) repr(self.folder)
'<Folder at f1>'

instead of

(Pdb++) repr(self.folder)
'<Folder at /plone/f1>'

What now happens is that __repr__ of persistent.Persistent delegates to _p_repr of OFS.SimpleItem which again calls __repr__ of OFS.SimpleItem. Somewhere in that mess the object loses the ability to access its parent with aq_parent. I did not really find where that happens. Unless someone else can find the issue here I suggest to drop zopefoundation/Zope#392 and instead add the additional base-classes as prepared in

My main reason (except for not being able to fix it) would is that debugging this issue is not obvious and would probably trip others up who encounter related issues in the future.

@pbauer
Copy link
Member Author

pbauer commented Oct 29, 2018

We'll not use _p_repr in Zope for now since I could not figure out where exactly acquisition got lost and how to fix that. Instead I'll add PathReprProvider to Dexterity and Archetypes (i.e. the pull-requests mentioned above).
Since the coredev builds are currently broken because of a dependency-bump in Zope and Zope 4.0b7 will be released tomorrow, I'll also let coredev depend on https://raw.githubusercontent.com/zopefoundation/Zope/master/versions.cfg for a day to fix the tests.

@pbauer
Copy link
Member Author

pbauer commented Nov 1, 2018

All merged. The issue with _p_repr is continued in zopefoundation/persistent#101

@jimfulton
Copy link

Coming into this late because Philip asked me to look at it. :) I'm probably missing something...

I wonder if a better fix would have been to try to address why Persistent was showing up too early in the MRO. For example, by swapping the order of the base classes in LocalSiteManager.

Persistent is kinda like object in that it seems to want to be at the end of the MRO. Otherwise, maybe it shouldn't be overriding something so basic as __repr__.

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

5 participants