summaryrefslogtreecommitdiffstats
path: root/ipalib/plugable.py
diff options
context:
space:
mode:
authorMartin Nagy <mnagy@redhat.com>2008-10-17 22:55:03 +0200
committerMartin Nagy <mnagy@redhat.com>2008-10-17 23:11:51 +0200
commit3a80297b04d6fbfd2367ec76c5651d20293adccc (patch)
tree8f10d8b3c490dec9b29077ffaa4052bb03c27fea /ipalib/plugable.py
parentae8370be44d95b9f6793ded46ef81126aebef3e0 (diff)
downloadfreeipa-3a80297b04d6fbfd2367ec76c5651d20293adccc.tar.gz
freeipa-3a80297b04d6fbfd2367ec76c5651d20293adccc.tar.xz
freeipa-3a80297b04d6fbfd2367ec76c5651d20293adccc.zip
Reworking Environment, moved it to config.py
Diffstat (limited to 'ipalib/plugable.py')
-rw-r--r--ipalib/plugable.py72
1 files changed, 1 insertions, 71 deletions
diff --git a/ipalib/plugable.py b/ipalib/plugable.py
index 4a2658a74..98aa41720 100644
--- a/ipalib/plugable.py
+++ b/ipalib/plugable.py
@@ -29,6 +29,7 @@ import re
import inspect
import errors
from errors import check_type, check_isinstance
+from config import Environment
class ReadOnly(object):
@@ -692,77 +693,6 @@ class Registrar(DictProxy):
self.__registered.add(klass)
-class Environment(object):
- """
- A mapping object used to store the environment variables.
- """
-
- def __init__(self):
- object.__setattr__(self, '_Environment__map', {})
-
- def __getattr__(self, name):
- """
- Return the attribute named ``name``.
- """
- return self[name]
-
- def __setattr__(self, name, value):
- """
- Set the attribute named ``name`` to ``value``.
- """
- self[name] = value
-
- def __delattr__(self, name):
- """
- Raise AttributeError (deletion is not allowed).
- """
- raise AttributeError('cannot del %s.%s' %
- (self.__class__.__name__, name)
- )
-
- def __getitem__(self, key):
- """
- Return the value corresponding to ``key``.
- """
- val = self.__map[key]
- if hasattr(val, 'get_value'):
- return val.get_value()
- else:
- return val
-
- def __setitem__(self, key, value):
- """
- Set the item at ``key`` to ``value``.
- """
- if key in self or hasattr(self, key):
- raise AttributeError('cannot overwrite %s.%s' %
- (self.__class__.__name__, key)
- )
- self.__map[key] = value
-
- def __contains__(self, key):
- """
- Return True if instance contains ``key``; otherwise return False.
- """
- return key in self.__map
-
- def __iter__(self):
- """
- Iterate through keys in ascending order.
- """
- for key in sorted(self.__map):
- yield key
-
- def update(self, new_vals, ignore_errors = False):
- assert type(new_vals) == dict
- for key, value in new_vals.iteritems():
- if key in self and ignore_errors:
- continue
- self[key] = value
-
- def get(self, name, default=None):
- return self.__map.get(name, default)
-
class API(DictProxy):
"""
Dynamic API object through which `Plugin` instances are accessed.