zopefoundation / Products.ZSQLMethods

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

impossible to add a new ZSQL method #18

Closed anotine10 closed 4 years ago

anotine10 commented 5 years ago

Hello, i can create a connection to a Mysql Database, i can do some queries with the Test connection. However, i can not create a Z SQL method: Neither add, add end edit, add and Test works. It fails with some weird insuficient privileges. afterwards, the listing of the object in the zope administration interface shows that the zsql method is broken.

Is the zsql method working for zope 4.1, plone 5.3, python3.6?

I add the stack trace and the information on the system below.

Thanks for the help!

stack trace:

019-10-06 10:38:08,052 ERROR   [Zope.SiteErrorLog:251][waitress] 1570351088.05237980.47088826335173173 http://localhost:8080/Plone2/portal_skins/custom/ppp/manage_main
Traceback (innermost last):
  Module ZPublisher.WSGIPublisher, line 155, in transaction_pubevents
  Module ZPublisher.WSGIPublisher, line 337, in publish_module
  Module ZPublisher.WSGIPublisher, line 255, in publish
  Module ZPublisher.mapply, line 85, in mapply
  Module ZPublisher.WSGIPublisher, line 61, in call_object
  Module Shared.DC.Scripts.Bindings, line 335, in __call__
  Module Shared.DC.Scripts.Bindings, line 372, in _bindAndExec
  Module App.special_dtml, line 214, in _exec
  Module DocumentTemplate._DocumentTemplate, line 145, in render_blocks
  Module DocumentTemplate._DocumentTemplate, line 167, in render_blocks_
  Module DocumentTemplate._DocumentTemplate, line 376, in __getitem__
  Module DocumentTemplate._DocumentTemplate, line 400, in getitem
  Module App.Management, line 182, in manage_page_header
  Module Shared.DC.Scripts.Bindings, line 335, in __call__
  Module Shared.DC.Scripts.Bindings, line 372, in _bindAndExec
  Module App.special_dtml, line 214, in _exec
  Module DocumentTemplate._DocumentTemplate, line 145, in render_blocks
  Module DocumentTemplate._DocumentTemplate, line 237, in render_blocks_
  Module DocumentTemplate._DocumentTemplate, line 215, in render_blocks_
  Module DocumentTemplate._DocumentTemplate, line 376, in __getitem__
  Module DocumentTemplate._DocumentTemplate, line 388, in getitem
  Module DocumentTemplate._DocumentTemplate, line 306, in __getitem__
  Module Shared.DC.Scripts.Bindings, line 203, in __getattr__
zExceptions.unauthorized.Unauthorized: You are not allowed to access 'title_or_id' in this context

system information: Plone 5.2.0 (5207) CMF 2.4.0 Zope 4.1.1 Python 3.6.9 |Anaconda, Inc.| (default, Jul 30 2019, 13:42:17) [GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)] PIL 6.1.0 (Pillow) WSGI: On Server: waitress 1.3.0

Zope Version (4.1.1, python 3.6.9, darwin)
3.6.9 |Anaconda, Inc.| (default, Jul 30 2019, 13:42:17) [GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)]

darwin

d-maurer commented 5 years ago

As for the analysis of any Unauthorized problem, you could activate verbose-security. It gives more detailed information about the cause of the Unauthorized.

To activate verbose-security, you add to your Zope configuration file (in a typical Plone setup, this is parts/{instance|client1}/etc/zope.conf):

security-policy-implementation python
verbose-security on

This will not solve the problem, just give more information about it.

Note that manual modifications to the Zope configuration file are lost when you next call buildout (which is likely a good thing in this special case).

icemac commented 5 years ago

@anotine10 I was not able to reproduce this problem. Here is what I did:

$ python3.7 -m venv z
$ cd z
$ bin/pip install Zope Paste  # I know this is not the documented way but currently it works.
$ bin/pip install Products.ZSQLMethods
$ bin/mkwsgiinstance -d .

I struggled a bit to find a DA which is Python 3 compatible until I found this one:

$ bin/pip install -e git+https://github.com/perfact/ZPsycopgDA.git#egg=ZPsycopgDA
$ bin/pip install psycopg2-binary
$ bin/runwsgi etc/zope.ini

No I was able to create a Z Psycopg 2 Database Connection and afterwards a Z SQL Method which could even select from the database.

So in general: Products.ZSQLMethods works with Zope 4 and Python 3. (If Plone is part go the problem: I cannot tell.) So you might try out what @d-maurer suggested an report back your findings.

dataflake commented 5 years ago

https://pypi.org/project/Products.ZMySQLDA/ is fully Python 3 compatible. And everything works on Zope 4.x. I cannot reproduce the issue, either.

dataflake commented 4 years ago

As there has not been any further followup and this cannot be reproduced I will close this issue. If you still see problems please provide more information, such as from the added output produced by the verbose-security setting Dieter suggested.