zopefoundation / Products.ZSQLMethods

SQL method support for Zope.
Other
3 stars 14 forks source link

Fix the error output of SQL Methods #33

Closed jan-jockusch closed 3 years ago

jan-jockusch commented 3 years ago

When errors occur, Zope usually formats the object in question with the physical path. This somehow fails for ZSQLMethod in Zope4.

The error output uses __repr__(), which in Zope2 was inherited from SimpleItem.Item, which in turn pulls in SimpleItem.PathReprProvider.

This inheritance pattern does not work in the same way in Python3, losing PathReprProvider in DA. Adding it there, at the very first position, yields the correct output.

Test this with:

>>> from Products.ZSQLMethods.SQL import SQL
>>> x = SQL('a', 'a', 'a', '', 'select * from data')
>>> repr(x)
'<SQL at a>'
jan-jockusch commented 3 years ago

I'd like to add the test into the project, to stabilize the code. This is not yet done, therefore the PR is "WIP".

jan-jockusch commented 3 years ago

Test included. Ready for review.

jan-jockusch commented 3 years ago

@dataflake Happy New Year! I have no idea if the request for review is the correct thing to do at this point. If I misbehaved by clicking on the request link, you're welcome to ignore me. I don't know the PR workflow on github yet, but it's good to hear there's a "draft" mode, that's clearer than the WIP prefix.

jan-jockusch commented 3 years ago

@icemac Thanks for reviewing!

CHANGES entry added. Shall I squash the commits or should they stay this way?

icemac commented 3 years ago

I'd prefer squashing the commits.

dataflake commented 3 years ago

I just released version 3.12 with the fix.