summaryrefslogtreecommitdiffstats
path: root/ipalib
diff options
context:
space:
mode:
authorJason Gerard DeRose <jderose@redhat.com>2010-02-08 05:03:28 -0700
committerRob Crittenden <rcritten@redhat.com>2010-02-12 17:07:37 -0500
commit069763c5c616221fd0bcea813cad93ae3f7c072d (patch)
tree3c7944836ca68119671482e3ee2f9365032fa640 /ipalib
parent338578d10ac0978a00948971a17a89dc95435954 (diff)
downloadfreeipa-069763c5c616221fd0bcea813cad93ae3f7c072d.tar.gz
freeipa-069763c5c616221fd0bcea813cad93ae3f7c072d.tar.xz
freeipa-069763c5c616221fd0bcea813cad93ae3f7c072d.zip
Add Object.label class attribute, enable in webUI
Diffstat (limited to 'ipalib')
-rw-r--r--ipalib/frontend.py3
-rw-r--r--ipalib/plugable.py17
-rw-r--r--ipalib/plugins/aci.py3
-rw-r--r--ipalib/plugins/automount.py6
-rw-r--r--ipalib/plugins/dns.py4
-rw-r--r--ipalib/plugins/group.py2
-rw-r--r--ipalib/plugins/hbac.py3
-rw-r--r--ipalib/plugins/host.py2
-rw-r--r--ipalib/plugins/hostgroup.py2
-rw-r--r--ipalib/plugins/netgroup.py4
-rw-r--r--ipalib/plugins/rolegroup.py2
-rw-r--r--ipalib/plugins/service.py2
-rw-r--r--ipalib/plugins/taskgroup.py2
-rw-r--r--ipalib/plugins/user.py2
-rw-r--r--ipalib/text.py20
15 files changed, 68 insertions, 6 deletions
diff --git a/ipalib/frontend.py b/ipalib/frontend.py
index 0abb35be..ae7ec945 100644
--- a/ipalib/frontend.py
+++ b/ipalib/frontend.py
@@ -1110,6 +1110,9 @@ class Property(Attribute):
def __init__(self):
super(Property, self).__init__()
+ # FIXME: This is a hack till Param.label is updated to require a
+ # LazyText instance:
+ self.label = None
self.rules = tuple(
sorted(self.__rules_iter(), key=lambda f: getattr(f, '__name__'))
)
diff --git a/ipalib/plugable.py b/ipalib/plugable.py
index 4473409e..ded762d1 100644
--- a/ipalib/plugable.py
+++ b/ipalib/plugable.py
@@ -37,9 +37,13 @@ import optparse
import errors
from config import Env
import util
+import text
from base import ReadOnly, NameSpace, lock, islocked, check_name
from constants import DEFAULT_CONFIG, FORMAT_STDERR, FORMAT_FILE
+# FIXME: Updated constants.TYPE_ERROR to use this clearer format from wehjit:
+TYPE_ERROR = '%s: need a %r; got a %r: %r'
+
class SetProxy(ReadOnly):
"""
@@ -155,6 +159,8 @@ class Plugin(ReadOnly):
Base class for all plugins.
"""
+ label = None
+
def __init__(self):
self.__api = None
cls = self.__class__
@@ -177,6 +183,17 @@ class Plugin(ReadOnly):
self.name, name, getattr(self, name))
)
setattr(self, name, getattr(log, name))
+ if self.label is None:
+ self.label = text.FixMe(self.name + '.label')
+ if not isinstance(self.label, text.LazyText):
+ raise TypeError(
+ TYPE_ERROR % (
+ self.fullname + '.label',
+ text.LazyText,
+ type(self.label),
+ self.label
+ )
+ )
def __get_api(self):
"""
diff --git a/ipalib/plugins/aci.py b/ipalib/plugins/aci.py
index ea5b3e46..a722d761 100644
--- a/ipalib/plugins/aci.py
+++ b/ipalib/plugins/aci.py
@@ -197,6 +197,9 @@ class aci(Object):
"""
ACI object.
"""
+
+ label = _('ACIs')
+
takes_params = (
Str('aciname',
cli_name='name',
diff --git a/ipalib/plugins/automount.py b/ipalib/plugins/automount.py
index 85b13293..8037b9aa 100644
--- a/ipalib/plugins/automount.py
+++ b/ipalib/plugins/automount.py
@@ -88,6 +88,7 @@ from ipalib import api, errors
from ipalib import Object, Command
from ipalib import Flag, Str
from ipalib.plugins.baseldap import *
+from ipalib import _, ngettext
class automountlocation(LDAPObject):
@@ -227,6 +228,8 @@ class automountmap(LDAPObject):
),
)
+ label = _('Automount Maps')
+
api.register(automountmap)
@@ -315,6 +318,8 @@ class automountkey(LDAPObject):
),
)
+ label = _('Automount Keys')
+
api.register(automountkey)
@@ -384,4 +389,3 @@ class automountkey_show(LDAPRetrieve):
"""
api.register(automountkey_show)
-
diff --git a/ipalib/plugins/dns.py b/ipalib/plugins/dns.py
index b31ded66..49d073e8 100644
--- a/ipalib/plugins/dns.py
+++ b/ipalib/plugins/dns.py
@@ -66,6 +66,7 @@ import time
from ipalib import api, crud, errors, output
from ipalib import Object, Command
from ipalib import Flag, Int, Str, StrEnum
+from ipalib import _, ngettext
# parent DN
_zone_container_dn = api.env.container_dns
@@ -110,6 +111,8 @@ def _get_record_dn(ldap, zone, idnsname):
class dns(Object):
"""DNS zone/SOA record object."""
+ label = _('DNS')
+
takes_params = (
Str('idnsname',
cli_name='name',
@@ -857,4 +860,3 @@ class dns_show_rr(Command):
textui.print_entry(entry_attrs)
api.register(dns_show_rr)
-
diff --git a/ipalib/plugins/group.py b/ipalib/plugins/group.py
index 5fea4129..0cc42a7a 100644
--- a/ipalib/plugins/group.py
+++ b/ipalib/plugins/group.py
@@ -55,6 +55,8 @@ class group(LDAPObject):
'memberof': ['group', 'netgroup', 'rolegroup', 'taskgroup'],
}
+ label = _('User Groups')
+
takes_params = (
Str('cn',
cli_name='name',
diff --git a/ipalib/plugins/hbac.py b/ipalib/plugins/hbac.py
index ac944591..29567cff 100644
--- a/ipalib/plugins/hbac.py
+++ b/ipalib/plugins/hbac.py
@@ -23,6 +23,7 @@ Host based access control
from ipalib import api, errors
from ipalib import AccessTime, Password, Str, StrEnum
from ipalib.plugins.baseldap import *
+from ipalib import _, ngettext
class hbac(LDAPObject):
"""
@@ -58,6 +59,8 @@ class hbac(LDAPObject):
'sourcehost': ['host', 'hostgroup'],
}
+ label = _('HBAC')
+
takes_params = (
Str('cn',
cli_name='name',
diff --git a/ipalib/plugins/host.py b/ipalib/plugins/host.py
index 6368b8bc..7e9dd90b 100644
--- a/ipalib/plugins/host.py
+++ b/ipalib/plugins/host.py
@@ -79,6 +79,8 @@ class host(LDAPObject):
'memberof': ['hostgroup', 'netgroup', 'rolegroup'],
}
+ label = _('Hosts')
+
takes_params = (
Str('fqdn', validate_host,
cli_name='hostname',
diff --git a/ipalib/plugins/hostgroup.py b/ipalib/plugins/hostgroup.py
index 2376b437..7accca62 100644
--- a/ipalib/plugins/hostgroup.py
+++ b/ipalib/plugins/hostgroup.py
@@ -46,6 +46,8 @@ class hostgroup(LDAPObject):
'memberof': ['hostgroup'],
}
+ label = _('Host Groups')
+
takes_params = (
Str('cn',
cli_name='name',
diff --git a/ipalib/plugins/netgroup.py b/ipalib/plugins/netgroup.py
index 66508b69..094a6d87 100644
--- a/ipalib/plugins/netgroup.py
+++ b/ipalib/plugins/netgroup.py
@@ -23,6 +23,7 @@ Netgroups
from ipalib import api, errors
from ipalib.plugins.baseldap import *
+from ipalib import _, ngettext
class netgroup(LDAPObject):
@@ -51,6 +52,8 @@ class netgroup(LDAPObject):
'externalhost': [],
}
+ label = _('Net Groups')
+
takes_params = (
Str('cn',
cli_name='name',
@@ -200,4 +203,3 @@ class netgroup_remove_member(LDAPRemoveMember):
return (completed + completed_external, dn)
api.register(netgroup_remove_member)
-
diff --git a/ipalib/plugins/rolegroup.py b/ipalib/plugins/rolegroup.py
index d0ed0f0a..ea89aa51 100644
--- a/ipalib/plugins/rolegroup.py
+++ b/ipalib/plugins/rolegroup.py
@@ -47,6 +47,8 @@ class rolegroup(LDAPObject):
'memberof': ['taskgroup'],
}
+ label = _('Role Groups')
+
takes_params = (
Str('cn',
cli_name='name',
diff --git a/ipalib/plugins/service.py b/ipalib/plugins/service.py
index a477de9a..a5de17b3 100644
--- a/ipalib/plugins/service.py
+++ b/ipalib/plugins/service.py
@@ -119,6 +119,8 @@ class service(LDAPObject):
'managedby': ['host'],
}
+ label = _('Services')
+
takes_params = (
Str('krbprincipalname', validate_principal,
cli_name='principal',
diff --git a/ipalib/plugins/taskgroup.py b/ipalib/plugins/taskgroup.py
index 575db488..a39f5c00 100644
--- a/ipalib/plugins/taskgroup.py
+++ b/ipalib/plugins/taskgroup.py
@@ -47,6 +47,8 @@ class taskgroup(LDAPObject):
# FIXME: taskgroup can be member of ???
}
+ label = _('Task Groups')
+
takes_params = (
Str('cn',
cli_name='name',
diff --git a/ipalib/plugins/user.py b/ipalib/plugins/user.py
index 1686d678..c06a9280 100644
--- a/ipalib/plugins/user.py
+++ b/ipalib/plugins/user.py
@@ -68,6 +68,8 @@ class user(LDAPObject):
'memberof': ['group', 'netgroup', 'rolegroup', 'taskgroup'],
}
+ label = _('Users')
+
takes_params = (
Str('uid',
cli_name='login',
diff --git a/ipalib/text.py b/ipalib/text.py
index 0c868402..07f1b21d 100644
--- a/ipalib/text.py
+++ b/ipalib/text.py
@@ -26,10 +26,25 @@ placeholders for the rest of the code.
class LazyText(object):
- def __init__(self, domain, localedir):
+ def __init__(self, domain=None, localedir=None):
self.domain = domain
self.localedir = localedir
+ def __mod__(self, kw):
+ return self.__unicode__() % kw
+
+
+class FixMe(LazyText):
+ def __init__(self, msg):
+ self.msg = msg
+ super(FixMe, self).__init__()
+
+ def __repr__(self):
+ return '%s(%r)' % (self.__class__.__name__, self.msg)
+
+ def __unicode__(self):
+ return u'<%s>' % self.msg
+
class Gettext(LazyText):
def __init__(self, msg, domain, localedir):
@@ -39,8 +54,7 @@ class Gettext(LazyText):
def __unicode__(self):
return self.msg.decode('utf-8')
- def __mod__(self, value):
- return self.__unicode__() % value
+
class NGettext(LazyText):