diff options
author | Jason Gerard DeRose <jderose@redhat.com> | 2008-09-04 03:34:16 +0000 |
---|---|---|
committer | Jason Gerard DeRose <jderose@redhat.com> | 2008-09-04 03:34:16 +0000 |
commit | e1f8619d4adbc15415e2959496640c0f707c54fe (patch) | |
tree | c8a982d0d3e173b7fdcdef1af006ba6a8150f08c /ipalib/public.py | |
parent | a5c6bf179bed52602222b76cf2dcd09f7d461dea (diff) | |
download | freeipa.git-e1f8619d4adbc15415e2959496640c0f707c54fe.tar.gz freeipa.git-e1f8619d4adbc15415e2959496640c0f707c54fe.tar.xz freeipa.git-e1f8619d4adbc15415e2959496640c0f707c54fe.zip |
254: Added public.Application base class; added corresponding unit tests
Diffstat (limited to 'ipalib/public.py')
-rw-r--r-- | ipalib/public.py | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/ipalib/public.py b/ipalib/public.py index c2c3a449..c6611ab7 100644 --- a/ipalib/public.py +++ b/ipalib/public.py @@ -380,3 +380,42 @@ class Property(Attribute): attr = getattr(self, name) if is_rule(attr): yield attr + + +class Application(Command): + """ + Base class for commands register by an external application. + + Special commands that only apply to a particular application built atop + `ipalib` should subclass from ``Application``. + + Because ``Application`` subclasses from `Command', plugins that subclass + from ``Application`` with be available in both the ``api.Command`` and + ``api.Application`` namespaces. + """ + + __public__ = frozenset(( + 'application', + )).union(Command.__public__) + __application = None + + def __get_application(self): + """ + Returns external ``application`` object. + """ + return self.__application + def __set_application(self, application): + """ + Sets the external application object to ``application``. + """ + if self.__application is not None: + raise AttributeError( + '%s.application can only be set once' % self.name + ) + if application is None: + raise TypeError( + '%s.application cannot be None' % self.name + ) + object.__setattr__(self, '_Application__application', application) + assert self.application is application + application = property(__get_application, __set_application) |