svn commit: samba r25621 - in branches/4.0-python: . source/lib/ldb source/lib/ldb/swig source/lib/ldb/tests/python

jelmer at samba.org jelmer at samba.org
Fri Oct 12 01:25:57 GMT 2007


Author: jelmer
Date: 2007-10-12 01:25:52 +0000 (Fri, 12 Oct 2007)
New Revision: 25621

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=25621

Log:
Use somewhat more OO interface.
Modified:
   branches/4.0-python/
   branches/4.0-python/source/lib/ldb/setup.py
   branches/4.0-python/source/lib/ldb/swig/ldb.i
   branches/4.0-python/source/lib/ldb/tests/python/ldb.py


Changeset:

Property changes on: branches/4.0-python
___________________________________________________________________
Name: bzr:revision-info
...skipped...
Name: bzr:file-ids
...skipped...
Name: bzr:revision-id:v3-trunk0
...skipped...

Modified: branches/4.0-python/source/lib/ldb/setup.py
===================================================================
--- branches/4.0-python/source/lib/ldb/setup.py	2007-10-12 00:07:39 UTC (rev 25620)
+++ branches/4.0-python/source/lib/ldb/setup.py	2007-10-12 01:25:52 UTC (rev 25621)
@@ -4,5 +4,5 @@
 setup(name='ldb',
       version='1.0',
       ext_modules=[Extension('_ldb', ['swig/ldb.i'], include_dirs=['include'],
-                             libraries=['ldb','ldap'])],
+      libraries=['ldb','ldap'])],
       )

Modified: branches/4.0-python/source/lib/ldb/swig/ldb.i
===================================================================
--- branches/4.0-python/source/lib/ldb/swig/ldb.i	2007-10-12 00:07:39 UTC (rev 25620)
+++ branches/4.0-python/source/lib/ldb/swig/ldb.i	2007-10-12 01:25:52 UTC (rev 25621)
@@ -40,10 +40,14 @@
 #include "talloc.h"
 #include "ldb.h"
 
+typedef struct ldb_message ldb_msg;
+typedef struct ldb_message_element ldb_msg_element;
+
 %}
 
 %include "carrays.i"
 %include "exception.i"
+%include "typemaps.i"
 
 /*
  * Constants
@@ -162,12 +166,12 @@
 
 %array_functions(struct ldb_val, ldb_val_array);
 
-struct ldb_message_element {
+typedef struct ldb_message_element {
 	unsigned int flags;
 	const char *name;
 	unsigned int num_values;
 	struct ldb_val *values;
-};
+} ldb_msg_element;
 
 /*
  * Wrap struct ldb_message
@@ -175,11 +179,16 @@
 
 %array_functions(struct ldb_message_element, ldb_message_element_array);
 
-struct ldb_message {
+typedef struct ldb_message {
 	struct ldb_dn *dn;
 	unsigned int num_elements;
 	struct ldb_message_element *elements;
-};
+    %extend {
+        int add_value(const char *attr_name, const struct ldb_val *val, ldb_msg_element **return_el);
+        ldb_msg_element *find_element(const char *attr_name);
+        void remove_attr(const char *attr); 
+    }
+} ldb_msg;
 
 /*
  * Wrap struct ldb_result
@@ -189,7 +198,7 @@
 
 struct ldb_result {
 	unsigned int count;
-	struct ldb_message **msgs;
+	ldb_msg **msgs;
 	char **refs;
 	struct ldb_control **controls;
 };
@@ -218,18 +227,12 @@
 
 int ldb_rename(struct ldb_context *ldb, struct ldb_dn *olddn, struct ldb_dn *newdn);
 
-int ldb_add(struct ldb_context *ldb, const struct ldb_message *message);
+int ldb_add(struct ldb_context *ldb, ldb_msg *message);
 
 /* Ldb message operations */
 
-struct ldb_message *ldb_msg_new(void *mem_ctx);
+ldb_msg *ldb_msg_new(void *mem_ctx);
 
-struct ldb_message_element *ldb_msg_find_element(const struct ldb_message *msg, const char *attr_name);
-
-int ldb_msg_add_value(struct ldb_message *msg, const char *attr_name, const struct ldb_val *val, struct ldb_message_element **return_el);
-
-void ldb_msg_remove_attr(struct ldb_message *msg, const char *attr);
-
 int ldb_msg_sanity_check(struct ldb_context *ldb, const struct ldb_message *msg);
 
 /* DN operations */
@@ -238,4 +241,7 @@
 
 /* char *ldb_dn_linearize(void *mem_ctx, const struct ldb_dn *dn); */
 
+%apply ldb_msg_element **OUTPUT { ldb_msg_element **return_el };
+%nodefault ldb_message;
+%newobject ldb_msg_new;
 %rename(ldb_context) Ldb;

Modified: branches/4.0-python/source/lib/ldb/tests/python/ldb.py
===================================================================
--- branches/4.0-python/source/lib/ldb/tests/python/ldb.py	2007-10-12 00:07:39 UTC (rev 25620)
+++ branches/4.0-python/source/lib/ldb/tests/python/ldb.py	2007-10-12 01:25:52 UTC (rev 25621)
@@ -6,7 +6,7 @@
 #  Copyright (C) Jelmer Vernooij 2007
 #
 
-import ldb
+from ldb import Ldb
 import os, sys
 
 if len(sys.argv) != 2:



More information about the samba-cvs mailing list