Zope-3.2.0: I have a MySQL database Utility installed that works fine via its Test tab, via an SQL Script, and with that script called from a page template. I want to to use a simple query from a class that supports a form in a context that has nothing to do with the database. The code I have tried looks like this:


from zope.app.rdb import queryForResults
from zope.app.rdb.interfaces import IZopeDatabaseAdapter

class EditRoles:
    """This class reads a form data and updates Permissions """

    def getPrincipals(self):
        try:
            connection = zapi.getUtility(IZopeDatabaseAdapter, 'mysql')
        except KeyError:
            raise AttributeError("The database connection '%s' cannot be "
                                 "found." % ('mysql'))
        query = "select * from z3users"
        result = queryForResults(connection, query)

And when I try to invoke the form I get this error

File "/usr/local/Zope320i/lib/python/cefsite/browser/editroles.py", line 47, in getPrincipals
    result = queryForResults(connection, query)
File "/home/ceford/temp/Zope-3.2.0/build/lib.linux-i686-2.4/zope/app/rdb/__init__.py", line 401, in queryForResults
    cursor = conn.cursor()
AttributeError: 'MySQLdbAdapter' object has no attribute 'cursor'

Can anyone suggest what I might be missing or suggest another way of accessing the database?

Cliff
_______________________________________________
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users

Reply via email to