mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
Some PEP-257 and reStructuredText fixes in ipalib/aci.py, ipa_server/ipaldap.py
This commit is contained in:
@@ -38,12 +38,14 @@ from ipalib import errors
|
|||||||
sasl_auth = ldap.sasl.sasl({},'GSSAPI')
|
sasl_auth = ldap.sasl.sasl({},'GSSAPI')
|
||||||
|
|
||||||
class Entry:
|
class Entry:
|
||||||
"""This class represents an LDAP Entry object. An LDAP entry consists of
|
"""
|
||||||
a DN and a list of attributes. Each attribute consists of a name and
|
This class represents an LDAP Entry object. An LDAP entry consists of
|
||||||
a list of values. In python-ldap, entries are returned as a list of
|
a DN and a list of attributes. Each attribute consists of a name and
|
||||||
2-tuples. Instance variables:
|
a list of values. In python-ldap, entries are returned as a list of
|
||||||
dn - string - the string DN of the entry
|
2-tuples. Instance variables:
|
||||||
data - CIDict - case insensitive dict of the attributes and values
|
|
||||||
|
* dn - string - the string DN of the entry
|
||||||
|
* data - CIDict - case insensitive dict of the attributes and values
|
||||||
"""
|
"""
|
||||||
def __init__(self,entrydata):
|
def __init__(self,entrydata):
|
||||||
"""data is the raw data returned from the python-ldap result method, which is
|
"""data is the raw data returned from the python-ldap result method, which is
|
||||||
@@ -87,15 +89,21 @@ class Entry:
|
|||||||
"""Get the first value for the attribute named name"""
|
"""Get the first value for the attribute named name"""
|
||||||
return self.data.get(name,[None])[0]
|
return self.data.get(name,[None])[0]
|
||||||
|
|
||||||
def setValue(self,name,*value):
|
def setValue(self, name, *value):
|
||||||
"""Value passed in may be a single value, several values, or a single sequence.
|
"""
|
||||||
For example:
|
Set a value on this entry.
|
||||||
ent.setValue('name', 'value')
|
|
||||||
ent.setValue('name', 'value1', 'value2', ..., 'valueN')
|
The value passed in may be a single value, several values, or a
|
||||||
ent.setValue('name', ['value1', 'value2', ..., 'valueN'])
|
single sequence. For example:
|
||||||
ent.setValue('name', ('value1', 'value2', ..., 'valueN'))
|
|
||||||
Since *value is a tuple, we may have to extract a list or tuple from that
|
* ent.setValue('name', 'value')
|
||||||
tuple as in the last two examples above"""
|
* ent.setValue('name', 'value1', 'value2', ..., 'valueN')
|
||||||
|
* ent.setValue('name', ['value1', 'value2', ..., 'valueN'])
|
||||||
|
* ent.setValue('name', ('value1', 'value2', ..., 'valueN'))
|
||||||
|
|
||||||
|
Since value is a tuple, we may have to extract a list or tuple from
|
||||||
|
that tuple as in the last two examples above.
|
||||||
|
"""
|
||||||
if isinstance(value[0],list) or isinstance(value[0],tuple):
|
if isinstance(value[0],list) or isinstance(value[0],tuple):
|
||||||
self.data[name] = value[0]
|
self.data[name] = value[0]
|
||||||
else:
|
else:
|
||||||
@@ -285,7 +293,7 @@ class IPAdmin(SimpleLDAPObject):
|
|||||||
|
|
||||||
if not obj:
|
if not obj:
|
||||||
raise errors.NotFound, notfound(args)
|
raise errors.NotFound, notfound(args)
|
||||||
|
|
||||||
elif isinstance(obj,Entry):
|
elif isinstance(obj,Entry):
|
||||||
return obj
|
return obj
|
||||||
else: # assume list/tuple
|
else: # assume list/tuple
|
||||||
@@ -484,7 +492,7 @@ class IPAdmin(SimpleLDAPObject):
|
|||||||
|
|
||||||
def modifyPassword(self,dn,oldpass,newpass):
|
def modifyPassword(self,dn,oldpass,newpass):
|
||||||
"""Set the user password using RFC 3062, LDAP Password Modify Extended
|
"""Set the user password using RFC 3062, LDAP Password Modify Extended
|
||||||
Operation. This ends up calling the IPA password slapi plugin
|
Operation. This ends up calling the IPA password slapi plugin
|
||||||
handler so the Kerberos password gets set properly.
|
handler so the Kerberos password gets set properly.
|
||||||
|
|
||||||
oldpass is not mandatory
|
oldpass is not mandatory
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ class ACI:
|
|||||||
|
|
||||||
__actions = ["allow", "deny"]
|
__actions = ["allow", "deny"]
|
||||||
|
|
||||||
__permissions = ["read", "write", "add", "delete", "search", "compare",
|
__permissions = ["read", "write", "add", "delete", "search", "compare",
|
||||||
"selfwrite", "proxy", "all"]
|
"selfwrite", "proxy", "all"]
|
||||||
|
|
||||||
def __init__(self,acistr=None):
|
def __init__(self,acistr=None):
|
||||||
@@ -71,9 +71,14 @@ class ACI:
|
|||||||
return self.export_to_string()
|
return self.export_to_string()
|
||||||
|
|
||||||
def __getattr__(self, name):
|
def __getattr__(self, name):
|
||||||
"""Backwards compatibility for the old ACI class.
|
"""
|
||||||
The following extra attributes are available:
|
Backward compatibility for the old ACI class.
|
||||||
source_group, dest_group and attrs.
|
|
||||||
|
The following extra attributes are available:
|
||||||
|
|
||||||
|
- source_group
|
||||||
|
- dest_group
|
||||||
|
- attrs
|
||||||
"""
|
"""
|
||||||
if name == 'source_group':
|
if name == 'source_group':
|
||||||
group = ''
|
group = ''
|
||||||
@@ -96,9 +101,13 @@ class ACI:
|
|||||||
raise AttributeError, "object has no attribute '%s'" % name
|
raise AttributeError, "object has no attribute '%s'" % name
|
||||||
|
|
||||||
def __setattr__(self, name, value):
|
def __setattr__(self, name, value):
|
||||||
"""Backwards compatibility for the old ACI class.
|
"""
|
||||||
The following extra attributes are available:
|
Backward compatibility for the old ACI class.
|
||||||
source_group, dest_group and attrs.
|
|
||||||
|
The following extra attributes are available:
|
||||||
|
- source_group
|
||||||
|
- dest_group
|
||||||
|
- attrs
|
||||||
"""
|
"""
|
||||||
if name == 'source_group':
|
if name == 'source_group':
|
||||||
self.__dict__['bindrule'] = 'groupdn="ldap:///%s"' % value
|
self.__dict__['bindrule'] = 'groupdn="ldap:///%s"' % value
|
||||||
|
|||||||
Reference in New Issue
Block a user