##############################################################################
#
# Copyright (c) 2003 Santi Camps Taltavull <scamps@users.sourceforge.net>
# All Rights Reserved.
#
# This Library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public License as
# published by the Free Software Foundation; either version 2.1 of the
# License, or (at your option) any later version.
#
# This Library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this Library; see the file LICENSE. If not,
# write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA. or visit http://www.gnu.org
#
##############################################################################
from Globals import DTMLFile
from Products.ZMySQLDA.DA import Connection
from Products.ZMySQLDA.db import DB
from zetadb_mysql import ZetadbMysql, ZetadbMysqlDB
class ZetadbMysqldaDB(ZetadbMysqlDB, DB):
""" To make some conversions in SQL on-the-fly """
def query (self, *args, **kw):
""" Converts some SQL functions and execute query """
sentence = self.zetadb_db_convert_sql(args[0])
return apply(DB.query, (self, sentence) + args[1:], kw)
class ZetadbMysqlda(ZetadbMysql, Connection):
""" Support for ZMySQLDA database adapter """
def __init__(self, *args, **kw):
"Initialize an instance of the Object"
apply(Connection.__init__, (self, ) + args, **kw)
self.zetdb_db_remember_version()
def connect (self, *args, **kw):
""" Opens the connection, but also remember some information about our database """
result = apply(Connection.inheritedAttribute('connect'), (self, ) + args, **kw)
self.zetadb_db_load_catalog()
return result
def factory (self):
return ZetadbMysqldaDB
zetadb_mysqlda_add_form = DTMLFile('dtml/zetadb_mysqlda_add_form', globals())
def zetadb_mysqlda_add_action(self, id, title,
connection_string,
check=None, REQUEST=None):
"""Add a DB connection to a folder"""
from Products.zetadb.zetadb_mysqlda import ZetadbMysqlda
self._setObject(id, ZetadbMysqlda(id, title, connection_string, check))
if REQUEST is not None: return self.manage_main(self,REQUEST)