[PEAK] firebird support for peak
darryl
developer at csrules.dyndns.org
Tue Dec 30 14:12:57 EST 2003
In case anyone's interested i've got firebird (and probably by extension
interbase) working with peak.
You would of course have to edit a little as the defaultFactory assumes
a particular location....
cheers,
-darryl
----------------------------------------------------------------------------
# Copyright (C) 2003 Darryl VanDorp
#
# 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; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
USA
from peak.api import *
from peak.storage.SQL import ValueBasedTypeConn, GenericSQL_URL
from peak.storage.interfaces import ISQLObjectLister
class FirebirdConnection(ValueBasedTypeConn):
protocols.advise(
instancesProvide=[ISQLObjectLister]
)
DRIVER = "kinterbasdb"
def _open(self):
a = self.address
return self.API.connect(
host = a.server, database = a.db, user = a.user, password =
a.passwd
)
def onJoinTxn(self, txnService):
self.connection.begin()
def txnTime(self,d,a):
self.joinedTxn
r = ~self("SELECT current_timestamp from rdb$database")
return r[0]
txnTime = binding.Make(txnTime)
supportedTypes = (
'DATETIME','NUMBER','STRING','ROWID','BINARY'
)
class FirebirdURL(GenericSQL_URL):
supportedSchemes = ('firebird',)
defaultFactory = 'rdm.database.firebird.connection.FirebirdConnection'
protocols.declareAdapter(
lambda url, proto: FirebirdConnection(address = url),
provides = [storage.ISQLConnection],
forTypes = [FirebirdURL],
)
More information about the PEAK
mailing list