[Zope] ZnolkSQLWizard 0.1.9 errors w/ PoPy_db.py

eric.n.dunn@bankofamerica.com eric.n.dunn@bankofamerica.com
Mon, 10 Jun 2002 10:06:02 -0400


Using Zope 2.5, Debian, Postgresql, ZnolkSQLWizard 0.1.9, ZPoPyDA

Insert and Browse forms work... but...

UpdateForm gives me the following error

Traceback (innermost last):
  File /local/zope-2.5/lib/python/ZPublisher/Publish.py, line 150, in
publish_module
  File /local/zope-2.5/lib/python/ZPublisher/Publish.py, line 114, in
publish
  File /local/zope-2.5/lib/python/Zope/__init__.py, line 158, in
zpublisher_exception_hook
    (Object: DB)
  File /local/zope-2.5/lib/python/ZPublisher/Publish.py, line 98, in publish
  File /local/zope-2.5/lib/python/ZPublisher/mapply.py, line 88, in mapply
    (Object: UserinfoUpdateForm)
  File /local/zope-2.5/lib/python/ZPublisher/Publish.py, line 39, in
call_object
    (Object: UserinfoUpdateForm)
  File /local/zope-2.5/lib/python/OFS/DTMLDocument.py, line 127, in __call__
    (Object: UserinfoUpdateForm)
  File /local/zope-2.5/lib/python/DocumentTemplate/DT_String.py, line 473,
in __call__
    (Object: UserinfoUpdateForm)
  File /local/zope-2.5/lib/python/DocumentTemplate/DT_In.py, line 617, in
renderwob
    (Object: UserinfoPkSelectMethod)
  File /local/zope-2.5/lib/python/Shared/DC/ZRDB/DA.py, line 421, in
__call__
    (Object: UserinfoPkSelectMethod)
  File /local/zope-2.5/lib/python/Products/ZPoPyDA/PoPy_db.py, line 84, in
query
ProgrammingError: ERROR:  parser: parse error at or near ""


Code from " PoPy_db.py"


import string
database_type='PoPy'

"""%s Database Connection""" % database_type

from PoPy_db import DB
from Shared.DC.ZRDB.Connection import *
from PoPy_browser import *

addPoPyConnectionForm=DTMLFile(
    'dtml/PoPyconnectionAdd',
    globals(),
    default_id='%s_database_connection' % database_type,
    default_title='Z %s Database Connection' % database_type,
    database_type=database_type,
    )

def addPoPyConnection(self, id, title, connection_string,
connected=None,attempts=10,seconds=5,REQUEST=None):
    """Add a Z PoPy DB connection to a folder"""

    if not connected is None:
        connected = 1
    self._setObject(id, PoPyConnection(id,
                                   title,
                                   connection_string,
                                   connected,
                                   attempts,
                                   seconds))
    if REQUEST is not None:
        return self.manage_main(self,REQUEST)

class PoPyConnection(Connection):
    """A database connection object"""
    database_type=database_type
    id='%s_database_connection' % database_type
    meta_type=title='Z %s Database Connection' % database_type
    icon='misc_/Z%sDA/conn' % database_type
    _isAnSQLConnection=1

    def __init__(self, id, title, connection_string, connected=None,
                 attempts=10,seconds=5):
        Connection.__init__(self,id,title,connection_string,connected)
        self.attempts = attempts
        self.seconds = seconds

        if self._v_connected:
            self._v_database_connection.setAttempts(attempts,seconds)

    def manage_attempts (self, attempts,seconds,REQUEST):
        " "
        self.attempts = attempts
        self.seconds = seconds
        self._v_database_connection.setAttempts(attempts,seconds)
        return self.manage_main(self,REQUEST)

    manage_main=DTMLFile('dtml/PoPyconnectionStatus', globals())

    manage_properties=DTMLFile('dtml/PoPyconnectionEdit', globals())

    def manage_edit(self, title, connection_string, connected=None,
attempts=10,seconds=5,REQUEST=None):
        """Change connection"""

        self.attempts = attempts
        self.seconds = seconds
        if self._v_connected:
         self._v_database_connection.setAttempts(attempts,seconds)

        Connection.manage_edit(self,title,connection_string,connected)

    manage_testForm = DTMLFile('dtml/PoPyconnectionTestForm', globals())

    def factory(self): return DB

    def sql_quote__(self, v, escapes={
        '\\': '\\\\',
        '\"': '\\\"',
        '\'': '\\\'',
        '\0': '\\0',
        '\n': '\\n',
        '\t': '\\t',
        '\r': '\\r',
        '\b': '\\n',
        }):
        find=string.find
        for c in "\\\"\'\0\n\t\r\b":
            if find(v,c) > -1:
                v=string.join(string.split(v,c),escapes[c])
        return "'%s'" % v