David Johnson wrote:

In regards to persistence, are we saying this problem occurs when the
connection is an attribute of a persistent object? In our case the
connection resides in a persistent object but is called and used in a
non-persistent one.

It doesn't matter if the 'caller' of the connection is persistent or not, but that the connector is itself a persistent, local utility stored in the site manager folder.

> Specifically, we're using the connection in a
non-persistent shopping cart object.  Upon initialization the cart object
retrieves the connection from a persistent parent in the context in which
the cart is initialized. In this way, different shopping cart items can be
stored in different databases depending upon the container.  The parent is
essentially a copy of ISQLScript.

I copied SQLScript as well. Be sure that on each SQL operation you re-fetch the connection object using the connection name. Do not hold on to the connection object itself, as it may change during system re-configuration.

Here is my calling method:

    def invoke_SQL(self, query):

        cache = getCacheForObject(self)
        location = getLocationForCache(self)
        if cache and location:
            _marker = object()
            result = cache.query(location, {'query': query}, default=_marker)
            if result is not _marker:
                return result

            connection = zapi.getUtility(IZopeDatabaseAdapter,
        except KeyError:
            raise AttributeError, (
                "The database connection '%s' cannot be found." % (

        result = queryForResults(connection, query)
        if cache and location:
            cache.set(result, location, {'query': query})
        return result

Notice the zapi.getUtility() call to re-fetch each time.

Zope3-dev mailing list
Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com

Reply via email to