diff options
Diffstat (limited to 'ipalib')
-rw-r--r-- | ipalib/constants.py | 1 | ||||
-rw-r--r-- | ipalib/frontend.py | 2 | ||||
-rw-r--r-- | ipalib/parameters.py | 20 | ||||
-rw-r--r-- | ipalib/plugins/baseldap.py | 82 | ||||
-rw-r--r-- | ipalib/plugins/whoami.py | 41 | ||||
-rw-r--r-- | ipalib/util.py | 9 |
6 files changed, 27 insertions, 128 deletions
diff --git a/ipalib/constants.py b/ipalib/constants.py index 65589f105..66f13f25c 100644 --- a/ipalib/constants.py +++ b/ipalib/constants.py @@ -114,7 +114,6 @@ DEFAULT_CONFIG = ( # WebUI stuff: ('webui_prod', True), ('webui_assets_dir', None), - ('webui_new_layout', False), # Debugging: ('verbose', 0), diff --git a/ipalib/frontend.py b/ipalib/frontend.py index db1cae4f2..d320f02e0 100644 --- a/ipalib/frontend.py +++ b/ipalib/frontend.py @@ -666,7 +666,7 @@ class Command(HasParam): performs is executed remotely. """ if self.api.env.in_server: - return self.execute(*args, **options) + return self.execute(*args, **options) return self.forward(*args, **options) def execute(self, *args, **kw): diff --git a/ipalib/parameters.py b/ipalib/parameters.py index a628b6f53..f97c42218 100644 --- a/ipalib/parameters.py +++ b/ipalib/parameters.py @@ -100,17 +100,15 @@ a more detailed description for clarity. """ import re -import csv -import json - from types import NoneType -from util import make_repr, json_serialize +from util import make_repr from request import ugettext from plugable import ReadOnly, lock, check_name from errors import ConversionError, RequirementError, ValidationError from errors import PasswordMismatch from constants import NULLS, TYPE_ERROR, CALLABLE_ERROR from text import Gettext, FixMe +import csv class DefaultFrom(ReadOnly): @@ -854,20 +852,6 @@ class Param(ReadOnly): pass return self.default - def __json__(self): - json_dict = {} - for (a, k, d) in self.kwargs: - if k in (callable, DefaultFrom): - continue - elif isinstance(getattr(self, a), frozenset): - json_dict[a] = [k for k in getattr(self, a, [])] - else: - json_dict[a] = getattr(self, a, '') - json_dict['class'] = self.__class__.__name__ - json_dict['name'] = self.name - json_dict['type'] = self.type.__name__ - return json_dict - class Bool(Param): """ diff --git a/ipalib/plugins/baseldap.py b/ipalib/plugins/baseldap.py index 4b8699744..2b0ff2d73 100644 --- a/ipalib/plugins/baseldap.py +++ b/ipalib/plugins/baseldap.py @@ -21,16 +21,14 @@ Base classes for LDAP plugins. """ import re -import json from ipalib import crud, errors, uuid from ipalib import Method, Object -from ipalib import Flag, Int, List, Str +from ipalib import Flag, List, Str from ipalib.base import NameSpace from ipalib.cli import to_cli, from_cli from ipalib import output from ipalib.text import _ -from ipalib.util import json_serialize def validate_add_attribute(ugettext, attr): @@ -48,12 +46,11 @@ def get_attributes(attrs): """ Given a list of values in the form name=value, return a list of name. """ - if not attrs: - return [] attrlist=[] for attr in attrs: m = re.match("\s*(.*?)\s*=\s*(.*?)\s*$", attr) attrlist.append(str(m.group(1)).lower()) + return attrlist @@ -115,6 +112,7 @@ class LDAPObject(Object): entry_attrs.setdefault(new_attr, []).append( ldap_obj.get_primary_key_from_dn(member) ) + del entry_attrs[attr] def handle_not_found(self, *keys): raise errors.NotFound( @@ -123,20 +121,6 @@ class LDAPObject(Object): } ) - json_friendly_attributes = ( - 'parent_object', 'container_dn', 'object_name', 'object_name_plural', - 'object_class', 'object_class_config', 'default_attributes', 'label', - 'hidden_attributes', 'uuid_attribute', 'attribute_members', 'name', - 'takes_params', - ) - def __json__(self): - json_dict = dict( - (a, getattr(self, a)) for a in self.json_friendly_attributes - ) - json_dict['primary_key'] = self.primary_key.name - json_dict['methods'] = [m for m in self.methods] - return json_dict - # Options used by create and update. _attr_options = ( @@ -401,6 +385,7 @@ class LDAPUpdate(LDAPQuery, crud.Update): """ Update an LDAP entry. """ + takes_options = _attr_options def execute(self, *keys, **options): @@ -438,26 +423,26 @@ class LDAPUpdate(LDAPQuery, crud.Update): set. """ if 'addattr' in options: - setset = set(get_attributes(options.get('setattr', []))) - addset = set(get_attributes(options['addattr'])) - difflist = list(addset.difference(setset)) - if difflist: + try: + (dn, old_entry) = ldap.get_entry( + dn, attrs_list, normalize=self.obj.normalize_dn + ) + except errors.ExecutionError, e: try: - (dn, old_entry) = ldap.get_entry( - dn, difflist, normalize=self.obj.normalize_dn + (dn, old_entry) = self._call_exc_callbacks( + keys, options, e, ldap.get_entry, dn, attrs_list, + normalize=self.obj.normalize_dn ) - except errors.ExecutionError, e: - try: - (dn, old_entry) = self._call_exc_callbacks( - keys, options, e, ldap.get_entry, dn, attrs_list, - normalize=self.obj.normalize_dn - ) - except errors.NotFound: - self.obj.handle_not_found(*keys) - for a in old_entry: - if not isinstance(entry_attrs[a], (list, tuple)): - entry_attrs[a] = [entry_attrs[a]] - entry_attrs[a] += old_entry[a] + except errors.NotFound: + self.obj.handle_not_found(*keys) + attrlist = get_attributes(options['addattr']) + for attr in attrlist: + if attr in old_entry: + if type(entry_attrs[attr]) in (tuple,list): + entry_attrs[attr] = old_entry[attr] + entry_attrs[attr] + else: + old_entry[attr].append(entry_attrs[attr]) + entry_attrs[attr] = old_entry[attr] try: ldap.update_entry(dn, entry_attrs, normalize=self.obj.normalize_dn) @@ -809,25 +794,6 @@ class LDAPSearch(CallbackInterface, crud.Search): """ Retrieve all LDAP entries matching the given criteria. """ - takes_options = ( - Int('timelimit', - label=_('Time Limit'), - doc=_('Time limit of search in seconds (default 1)'), - flags=['no_dispaly'], - minvalue=0, - default=1, - autofill=True, - ), - Int('sizelimit', - label=_('Size Limit'), - doc=_('Maximum number of entries returned (default 3000)'), - flags=['no_dispaly'], - minvalue=0, - default=3000, - autofill=True, - ), - ) - def get_args(self): for key in self.obj.get_ancestor_primary_keys(): yield key @@ -891,9 +857,7 @@ class LDAPSearch(CallbackInterface, crud.Search): try: (entries, truncated) = ldap.find_entries( - filter, attrs_list, base_dn, scope=ldap.SCOPE_ONELEVEL, - time_limit=options.get('timelimit', 1), - size_limit=options.get('sizelimit', 3000) + filter, attrs_list, base_dn, scope=ldap.SCOPE_ONELEVEL ) except errors.ExecutionError, e: try: diff --git a/ipalib/plugins/whoami.py b/ipalib/plugins/whoami.py deleted file mode 100644 index 4742eb0a8..000000000 --- a/ipalib/plugins/whoami.py +++ /dev/null @@ -1,41 +0,0 @@ -# Authors: -# Adam Young <ayoung@redhat.com> -# -# Copyright (C) 2010 Red Hat -# see file 'COPYING' for use and warranty information -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; version 2 only -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -""" -whoami plugin: tells you your current principal -""" - - -from ipalib import api, errors -from ipalib import Command, Str -from ipalib import output, util - - -class whoami(Command): - """ - Reflects user principal - """ - has_output = ( - output.summary, - ) - - def execute(self): - return dict(summary=util.get_current_principal()) - -api.register(whoami) - diff --git a/ipalib/util.py b/ipalib/util.py index f5f0c9641..76be9a6d7 100644 --- a/ipalib/util.py +++ b/ipalib/util.py @@ -1,8 +1,7 @@ # Authors: # Jason Gerard DeRose <jderose@redhat.com> -# Pavel Zuna <pzuna@redhat.com> # -# Copyright (C) 2010 Red Hat +# Copyright (C) 2008 Red Hat # see file 'COPYING' for use and warranty information # # This program is free software; you can redistribute it and/or @@ -31,12 +30,6 @@ import socket from ipalib import errors -def json_serialize(obj): - if not callable(getattr(obj, '__json__', None)): - # raise TypeError('%r is not JSON serializable') - return '' - return obj.__json__() - def get_current_principal(): try: return unicode(krbV.default_context().default_ccache().principal().name) |