Fixed a problem in the host plugin module; added not in TODO about using Param.query

This commit is contained in:
Jason Gerard DeRose 2009-01-14 22:59:44 -07:00
parent a10144be24
commit fdda31c50b
3 changed files with 44 additions and 40 deletions

3
TODO
View File

@ -58,6 +58,9 @@ CRUD base classes:
LDAPCreate, etc. Or other options it to have an LDAPObject base class and LDAPCreate, etc. Or other options it to have an LDAPObject base class and
have the crud Method plugins rely more on their corresponding Object plugin. have the crud Method plugins rely more on their corresponding Object plugin.
* Update the Retrieve, Update, Delete, and Search classes so that the utilize
the new Param.query kwarg (to turn off validation) when cloning params.
Existing plugins: Existing plugins:

View File

@ -206,14 +206,18 @@ api.register(host_mod)
class host_find(crud.Find): class host_find(crud.Find):
'Search the hosts.' 'Search the hosts.'
takes_options = ( takes_options = (
Flag('all', doc='Retrieve all attributes'), Flag('all', doc='Retrieve all attributes'),
) )
def get_args(self):
""" # FIXME: This should no longer be needed with the Param.query kwarg.
Override Find.get_args() so we can exclude the validation rules # def get_args(self):
""" # """
yield self.obj.primary_key.__clone__(rules=tuple()) # Override Find.get_args() so we can exclude the validation rules
# """
# yield self.obj.primary_key.__clone__(rules=tuple())
def execute(self, term, **kw): def execute(self, term, **kw):
ldap = self.api.Backend.ldap ldap = self.api.Backend.ldap

View File

@ -21,12 +21,9 @@
Frontend plugins for user (Identity). Frontend plugins for user (Identity).
""" """
from ipalib import frontend from ipalib import api, crud, errors
from ipalib import crud from ipalib import Object, Command # Plugin base classes
from ipalib.frontend import Param from ipalib import Str, Password, Flag, Int # Parameter types
from ipalib import api
from ipalib import errors
from ipalib import ipa_types
def display_user(user): def display_user(user):
@ -48,62 +45,62 @@ def display_user(user):
default_attributes = ['uid','givenname','sn','homeDirectory','loginshell'] default_attributes = ['uid','givenname','sn','homeDirectory','loginshell']
class user(frontend.Object): class user(Object):
""" """
User object. User object.
""" """
takes_params = ( takes_params = (
Param('givenname', Str('givenname',
cli_name='first', cli_name='first',
doc='User\'s first name', doc="User's first name",
), ),
Param('sn', Str('sn',
cli_name='last', cli_name='last',
doc='User\'s last name', doc="User's last name",
), ),
Param('uid', Str('uid',
cli_name='user', cli_name='user',
primary_key=True, primary_key=True,
default_from=lambda givenname, sn: givenname[0] + sn, default_from=lambda givenname, sn: givenname[0] + sn,
normalize=lambda value: value.lower(), normalizer=lambda value: value.lower(),
), ),
Param('gecos?', Str('gecos?',
doc='GECOS field', doc='GECOS field',
default_from=lambda uid: uid, default_from=lambda uid: uid,
), ),
Param('homedirectory?', Str('homedirectory?',
cli_name='home', cli_name='home',
doc='User\'s home directory', doc="User's home directory",
default_from=lambda uid: '/home/%s' % uid, default_from=lambda uid: '/home/%s' % uid,
), ),
Param('loginshell?', Str('loginshell?',
cli_name='shell', cli_name='shell',
default=u'/bin/sh', default=u'/bin/sh',
doc='User\'s Login shell', doc="User's Login shell",
), ),
Param('krbprincipalname?', cli_name='principal', Str('krbprincipalname?',
doc='User\'s Kerberos Principal name', cli_name='principal',
doc="User's Kerberos Principal name",
default_from=lambda uid: '%s@%s' % (uid, api.env.realm), default_from=lambda uid: '%s@%s' % (uid, api.env.realm),
), ),
Param('mailaddress?', Str('mailaddress?',
cli_name='mail', cli_name='email',
doc='User\'s e-mail address', doc="User's e-mail address",
), ),
Param('userpassword?', Password('userpassword?',
cli_name='password', cli_name='password',
doc="Set user's password", doc="Set user's password",
flags=['password'],
), ),
Param('groups?', Str('groups?',
doc='Add account to one or more groups (comma-separated)', doc='Add account to one or more groups (comma-separated)',
), ),
Param('uidnumber?', Int('uidnumber?',
cli_name='uid', cli_name='uid',
type=ipa_types.Int(),
doc='The uid to use for this user. If not included one is automatically set.', doc='The uid to use for this user. If not included one is automatically set.',
), ),
) )
api.register(user) api.register(user)
@ -254,7 +251,7 @@ api.register(user_mod)
class user_find(crud.Find): class user_find(crud.Find):
'Search the users.' 'Search the users.'
takes_options = ( takes_options = (
Param('all?', type=ipa_types.Bool(), doc='Retrieve all user attributes'), Flag('all', doc='Retrieve all user attributes'),
) )
def execute(self, term, **kw): def execute(self, term, **kw):
ldap = self.api.Backend.ldap ldap = self.api.Backend.ldap
@ -304,7 +301,7 @@ api.register(user_find)
class user_show(crud.Get): class user_show(crud.Get):
'Examine an existing user.' 'Examine an existing user.'
takes_options = ( takes_options = (
Param('all?', type=ipa_types.Bool(), doc='Retrieve all user attributes'), Flag('all', doc='Retrieve all user attributes'),
) )
def execute(self, uid, **kw): def execute(self, uid, **kw):
""" """
@ -332,11 +329,11 @@ class user_show(crud.Get):
api.register(user_show) api.register(user_show)
class user_lock(frontend.Command): class user_lock(Command):
'Lock a user account.' 'Lock a user account.'
takes_args = ( takes_args = (
Param('uid', primary_key=True), Str('uid', primary_key=True),
) )
def execute(self, uid, **kw): def execute(self, uid, **kw):
@ -351,11 +348,11 @@ class user_lock(frontend.Command):
api.register(user_lock) api.register(user_lock)
class user_unlock(frontend.Command): class user_unlock(Command):
'Unlock a user account.' 'Unlock a user account.'
takes_args = ( takes_args = (
Param('uid', primary_key=True), Str('uid', primary_key=True),
) )
def execute(self, uid, **kw): def execute(self, uid, **kw):