X-Git-Url: http://git.samba.org/?p=samba.git;a=blobdiff_plain;f=source%2Flib%2Fldb%2Fswig%2FLdb.py;h=8cc7663cc3641b535f29bdfd80f2a423899ac3ce;hp=e78d56efdae23e25026686490223466a49b29e76;hb=76c6bfdeb51b5673bbabe0ca3d8bff3b74a327ee;hpb=7e30e8ba57efe37314ebca02f964420f56b9eb52 diff --git a/source/lib/ldb/swig/Ldb.py b/source/lib/ldb/swig/Ldb.py index e78d56efdae..8cc7663cc36 100644 --- a/source/lib/ldb/swig/Ldb.py +++ b/source/lib/ldb/swig/Ldb.py @@ -7,7 +7,7 @@ # # 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; either version 2 of the License, or +# the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, @@ -20,6 +20,15 @@ # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # +# +# Interface notes: +# +# - should an empty dn be represented as None, or an empty string? +# +# - should single-valued attributes be a string, or a list with one +# element? +# + from ldb import * # Global initialisation @@ -62,6 +71,9 @@ class LdbMessage: def __setattr__(self, attr, value): if attr == 'dn': self.msg.dn = ldb_dn_explode(self.msg, value) + if self.msg.dn == None: + err = LDB_ERR_INVALID_DN_SYNTAX + raise LdbError(err, ldb_strerror(err)) return self.__dict__[attr] = value @@ -78,6 +90,7 @@ class LdbMessage: for i in range(elt.num_values)] def __setitem__(self, key, value): + ldb_msg_remove_attr(self.msg, key) if type(value) in (list, tuple): [ldb_msg_add_value(self.msg, key, v) for v in value] else: @@ -99,6 +112,11 @@ class LdbMessage: def items(self): return [(k, self[k]) for k in self.keys()] + # Misc stuff + + def sanity_check(self): + return ldb_msg_sanity_check(self.msg) + class Ldb: """A class representing a binding to a ldb file."""