summaryrefslogtreecommitdiffstats
path: root/ipalib/request.py
diff options
context:
space:
mode:
authorJason Gerard DeRose <jderose@redhat.com>2009-01-23 18:02:32 -0700
committerRob Crittenden <rcritten@redhat.com>2009-02-03 15:29:03 -0500
commit66b6029e4058e1d29f35e4170423d127c2ebb2c4 (patch)
treefdc6655aee4267166166c512229402a2e17c3188 /ipalib/request.py
parent0a3ae60038c7b672d83f24678e2d791b3cad443e (diff)
downloadfreeipa-66b6029e4058e1d29f35e4170423d127c2ebb2c4.tar.gz
freeipa-66b6029e4058e1d29f35e4170423d127c2ebb2c4.tar.xz
freeipa-66b6029e4058e1d29f35e4170423d127c2ebb2c4.zip
Ported xmlclient to subclass from Connectible
Diffstat (limited to 'ipalib/request.py')
-rw-r--r--ipalib/request.py25
1 files changed, 9 insertions, 16 deletions
diff --git a/ipalib/request.py b/ipalib/request.py
index 812e526d6..d2c39c911 100644
--- a/ipalib/request.py
+++ b/ipalib/request.py
@@ -26,7 +26,7 @@ import threading
import locale
import gettext
from base import ReadOnly, lock
-from constants import OVERRIDE_ERROR
+from constants import OVERRIDE_ERROR, CALLABLE_ERROR
# Thread-local storage of most per-request information
@@ -38,22 +38,15 @@ class Connection(ReadOnly):
Base class for connection objects stored on `request.context`.
"""
- def __init__(self, *args, **kw):
- self.conn = self.create(*args, **kw)
+ def __init__(self, conn, disconnect):
+ self.conn = conn
+ if not callable(disconnect):
+ raise TypeError(
+ CALLABLE_ERROR % ('disconnect', disconnect, type(disconnect))
+ )
+ self.disconnect = disconnect
lock(self)
- def create(self, *args, **kw):
- """
- Create and return the connection (implement in subclass).
- """
- raise NotImplementedError('%s.create()' % self.__class__.__name__)
-
- def close(self):
- """
- Close the connection (implement in subclass).
- """
- raise NotImplementedError('%s.close()' % self.__class__.__name__)
-
def destroy_context():
"""
@@ -61,7 +54,7 @@ def destroy_context():
"""
for (name, value) in context.__dict__.items():
if isinstance(value, Connection):
- value.close()
+ value.disconnect()
delattr(context, name)