summaryrefslogtreecommitdiffstats
path: root/ipalib/plugable.py
diff options
context:
space:
mode:
authorJason Gerard DeRose <jderose@redhat.com>2008-08-06 02:00:18 +0000
committerJason Gerard DeRose <jderose@redhat.com>2008-08-06 02:00:18 +0000
commitc6f69e1c66b86f8f375a3c561922a42fdc0b1afb (patch)
treee4e3ea28fb18234a4ec5d841913a8eb38f7eb7c2 /ipalib/plugable.py
parentf31f7813febf0665a072d474166ea883bc7365dc (diff)
downloadfreeipa-c6f69e1c66b86f8f375a3c561922a42fdc0b1afb.tar.gz
freeipa-c6f69e1c66b86f8f375a3c561922a42fdc0b1afb.tar.xz
freeipa-c6f69e1c66b86f8f375a3c561922a42fdc0b1afb.zip
54: Added plugable.Proxy._clone() method; fleshed out public.obj; updated unit tests; port ipa script
Diffstat (limited to 'ipalib/plugable.py')
-rw-r--r--ipalib/plugable.py26
1 files changed, 24 insertions, 2 deletions
diff --git a/ipalib/plugable.py b/ipalib/plugable.py
index a8996cf2..6e6c6973 100644
--- a/ipalib/plugable.py
+++ b/ipalib/plugable.py
@@ -145,8 +145,8 @@ class Proxy(ReadOnly):
assert isinstance(proxy_name, str)
object.__setattr__(self, '_Proxy__obj', obj)
object.__setattr__(self, 'name', proxy_name)
- for name in self.__slots__:
- object.__setattr__(self, name, getattr(obj, name))
+ #for name in self.__slots__:
+ # object.__setattr__(self, name, getattr(obj, name))
def __repr__(self):
return '%s(%r)' % (self.__class__.__name__, self.__obj)
@@ -154,6 +154,18 @@ class Proxy(ReadOnly):
def __str__(self):
return to_cli(self.name)
+ def _clone(self, new_name):
+ return self.__class__(self.__obj, proxy_name=new_name)
+
+ def __getattr__(self, name):
+ if name in self.__slots__:
+ return getattr(self.__obj, name)
+ raise AttributeError('attribute %r not in %s.__slots__' % (
+ name,
+ self.__class__.__name__
+ )
+ )
+
class NameSpace(ReadOnly):
"""
@@ -161,6 +173,8 @@ class NameSpace(ReadOnly):
both as instance attributes and as dictionary items.
"""
+ __max_len = None
+
def __init__(self, items):
"""
`items` should be an iterable providing the members of this
@@ -214,6 +228,14 @@ class NameSpace(ReadOnly):
return self.__hname[key]
raise KeyError('NameSpace has no item for key %r' % key)
+ def __call__(self):
+ if self.__max_len is None:
+ ml = max(len(k) for k in self.__pname)
+ object.__setattr__(self, '_NameSpace__max_len', ml)
+ return self.__max_len
+
+
+
class Registrar(object):
def __init__(self, *allowed):