Question

In my Zope website I have customized the standard_error_message as a Python script. This script differentiates between error-types and handles redirects for NotFound-errors. For this, it accesses some ZSQLMethods without problems.

Now I wanted to log the NotFound-errors into a mySQL database (yes I know they are logged in Z2.log) and added another ZSQLMethod for this purpose.

Strangely this ZSQLMethod does not work when called from the standard_error_message script. It works (writes into the database) when called from another python script, also when this other script is called per http-request from an anonymous user. If called from standard_error_message, it throws an error if not called correctly but otherwise just does not write into the database (no error logged).

I'm really lost with this issue...

Était-ce utile?

La solution

You are running into transaction issues.

Zope wraps all requests in a transaction, and all external database interactions are tied into that transaction too.

This transaction is committed when a request is handled successfully, and no exceptions were raised, and aborted when there was an exception.

The standard_error_message is displayed when there were exceptions; and because there was an exception, your SQL INSERT is rolled back as the transaction aborts.

You'll have to explicitly commit just the SQL transaction; add a COMMIT statement to your SQL method.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top