# -*- coding: iso-8859-1 -*-
#-----------------------------------------------------------------------------
# Modeling Framework: an Object-Relational Bridge for python
#
# Copyright (c) 2001-2004 Sbastien Bigaret <sbigaret@users.sourceforge.net>
# All rights reserved.
#
# This file is part of the Modeling Framework.
#
# This code is distributed under a "3-clause BSD"-style license;
# see the LICENSE file for details.
#-----------------------------------------------------------------------------
"""
AdaptorContext API
Notifications
AdaptorContextBeginTransactionNotification
object: the AdaptorContext which posted the notification
userInfo: /
AdaptorContextCommitTransactionNotification
object: the AdaptorContext which posted the notification
userInfo: /
AdaptorContextRollbackTransactionNotification
object: the AdaptorContext which posted the notification
userInfo: /
__TBD: AdaptorContext.Delegate
CVS information
$Id: AdaptorContext.py 932 2004-07-20 06:21:57Z sbigaret $
"""
__version__='$Revision: 932 $'[11:-2]
try:
from Interface import Base
except:
class Base:
pass
def defaultDelegate():
"""
"""
def setDefaultDelegate(aDelegate):
"""
"""
class IAdaptorContext(Base):
"""
Provided and shouldnt be overriden:
hasOpenTransaction
transactionDidBegin
transactionDidCommit
transactionDidRollback
Should be overriden:
beginTransaction
commitTransaction
createAdaptorChannel
rollbackTransaction
"""
def __init__(self, anAdaptor):
"""
Initializes the new AdaptorContext.
Concrete AdaptorContexts should have no need to override this method ; if
they do, this method should be called prior to any other code-statements.
"""
def adaptor(self):
"""
Returns the Adaptor to which this instance is bound
Concrete AdaptorContexts should not override this method.
"""
def adaptorChannelDidClose(self, aChannel):
"""
Called automatically by the AdaptorContext's channels. You should never
call this method except if you implement a concrete Adaptor Layer.
If the closed channel was the last one among the registered channels()
being opened, this method can choose to close its connection to the
database.
Concrete implementation should specify whether it takes particular actions
before closing the connection to the database server (such as committing
or rolling-back any begun transactions).
See also: AdaptorChannel.closeChannel()
"""
def __addChannel__(self, aChannel):
"""
Private method ; you should never call this method --except if you
are implementing a concrete AdaptorContext.
Concrete AdaptorContext should use this method to register the new
channels it creates in 'createAdaptorChannel()' ; it should not be
overriden.
"""
def beginTransaction(self):
"""
abstract
"""
def channels(self):
"""
Returns the channels created by and registered to the AdaptorContext
Concrete AdaptorContexts should not override this method.
"""
def commitTransaction(self):
"""
"""
def createAdaptorChannel(self):
"""
Implemented by concrete AdaptorContexts to Instanciate a new concrete
AdaptorChannel, adds it to the list of channels(), and returns that
AdaptorChannel.
Implementation should call the private method __addChannel__() to register
the newly created channel before returning it.
abstract
"""
def delegate(self):
"""
Returns the object's delegate
"""
def handleDroppedConnection(self):
"""
"""
def hasBusyChannels(self):
"""
Sends all its channels() a 'isFetchInProgress()' message ; if at least one
of them returned true, the method itself returns 1 (true), otherwise
returns 0 (false)
"""
def hasOpenChannels(self):
"""
Returns 0 (false) if none of its AdaptorChannels returned true to the
'isOpen()' message, 0 (false) otherwise
"""
def hasOpenTransaction(self):
"""
"""
def rollbackTransaction(self):
"""
"""
def setDelegate(self, aDelegate):
"""
Sets the object's delegate
"""
def transactionDidBegin(self):
"""
"""
def transactionDidCommit(self):
"""
"""
def transactionDidRollback(self):
"""
"""
|