Removed the depreciated Context and LazyContext classes

This commit is contained in:
Jason Gerard DeRose
2009-01-23 15:53:45 -07:00
committed by Rob Crittenden
parent f7375bb609
commit 0cfb0e191a
5 changed files with 3 additions and 72 deletions

View File

@@ -871,7 +871,7 @@ freeIPA.org:
''' '''
import plugable import plugable
from backend import Backend, Context from backend import Backend
from frontend import Command, LocalOrRemote, Application from frontend import Command, LocalOrRemote, Application
from frontend import Object, Method, Property from frontend import Object, Method, Property
from crud import Create, Retrieve, Update, Delete, Search from crud import Create, Retrieve, Update, Delete, Search
@@ -902,12 +902,9 @@ def create_api(mode='dummy'):
- `frontend.Application` - `frontend.Application`
- `backend.Backend` - `backend.Backend`
- `backend.Context`
""" """
api = plugable.API( api = plugable.API(
Command, Object, Method, Property, Application, Command, Object, Method, Property, Application, Backend
Backend, Context,
) )
if mode is not None: if mode is not None:
api.env.mode = mode api.env.mode = mode

View File

@@ -95,17 +95,3 @@ class Executioner(Backend):
return result return result
assert isinstance(error, PublicError) assert isinstance(error, PublicError)
raise error raise error
class Context(plugable.Plugin):
"""
Base class for plugable context components.
"""
__proxy__ = False # Backend plugins are not wrapped in a PluginProxy
def get_value(self):
raise NotImplementedError(
'%s.get_value()' % self.__class__.__name__
)

View File

@@ -506,28 +506,6 @@ class Registrar(DictProxy):
self.__registered.add(klass) self.__registered.add(klass)
class LazyContext(object):
"""
On-demand creation of thread-local context attributes.
"""
def __init__(self, api):
self.__api = api
self.__context = threading.local()
def __getattr__(self, name):
if name not in self.__context.__dict__:
if name not in self.__api.Context:
raise AttributeError('no Context plugin for %r' % name)
value = self.__api.Context[name].get_value()
self.__context.__dict__[name] = value
return self.__context.__dict__[name]
def __getitem__(self, key):
return self.__getattr__(key)
class API(DictProxy): class API(DictProxy):
""" """
Dynamic API object through which `Plugin` instances are accessed. Dynamic API object through which `Plugin` instances are accessed.
@@ -538,7 +516,6 @@ class API(DictProxy):
self.__done = set() self.__done = set()
self.register = Registrar(*allowed) self.register = Registrar(*allowed)
self.env = Env() self.env = Env()
self.context = LazyContext(self)
super(API, self).__init__(self.__d) super(API, self).__init__(self.__d)
def __doing(self, name): def __doing(self, name):

View File

@@ -25,24 +25,13 @@ This wraps the python-ldap bindings.
""" """
import ldap as _ldap import ldap as _ldap
from ipalib import api, Context from ipalib import api
from ipalib import errors from ipalib import errors
from ipalib.crud import CrudBackend from ipalib.crud import CrudBackend
from ipaserver import servercore from ipaserver import servercore
from ipaserver import ipaldap from ipaserver import ipaldap
class conn(Context):
"""
Thread-local LDAP connection.
"""
def get_value(self):
return 'it worked'
api.register(conn)
class ldap(CrudBackend): class ldap(CrudBackend):
""" """
LDAP backend plugin. LDAP backend plugin.

View File

@@ -210,21 +210,3 @@ class test_Executioner(ClassChecker):
e = raises(errors2.InternalError, o.execute, 'bad') e = raises(errors2.InternalError, o.execute, 'bad')
assert conn.closed is True # Make sure destroy_context() was called assert conn.closed is True # Make sure destroy_context() was called
assert context.__dict__.keys() == [] assert context.__dict__.keys() == []
class test_Context(ClassChecker):
"""
Test the `ipalib.backend.Context` class.
"""
_cls = backend.Context
def test_get_value(self):
"""
Test the `ipalib.backend.Context.get_value` method.
"""
class Subclass(self.cls):
pass
o = Subclass()
e = raises(NotImplementedError, o.get_value)
assert str(e) == 'Subclass.get_value()'