]> xenbits.xensource.com Git - libvirt.git/commitdiff
python: Use a pure python implementation of 'vir*GetConnect'
authorCole Robinson <crobinso@redhat.com>
Wed, 23 Sep 2009 16:38:47 +0000 (12:38 -0400)
committerCole Robinson <crobinso@redhat.com>
Mon, 5 Oct 2009 17:31:38 +0000 (13:31 -0400)
The API docs explictly warn that we shouldn't use the C vir*GetConnect calls
in bindings: doing so can close the internal connection pointer and cause
things to get screwy. Implement these calls in python.

Signed-off-by: Cole Robinson <crobinso@redhat.com>
python/generator.py

index 437de0cb38e350839a84ba92d4ef866fc043585a..de5507e23ad50b92bdb4dd7729df56ba4d0a46b9 100755 (executable)
@@ -343,6 +343,16 @@ skip_function = (
     "virSecretRef",
     "virStoragePoolRef",
     "virStorageVolRef",
+
+    # This functions shouldn't be called via the bindings (and even the docs
+    # contain an explicit warning to that effect). The equivalent should be
+    # implemented in pure python for each class
+    "virDomainGetConnect",
+    "virInterfaceGetConnect",
+    "virNetworkGetConnect",
+    "virSecretGetConnect",
+    "virStoragePoolGetConnect",
+    "virStorageVolGetConnect",
 )
 
 
@@ -641,6 +651,11 @@ classes_destructors = {
     #"virStream": "virStreamFree",
 }
 
+class_skip_connect_impl = {
+    "virConnect" : True
+}
+
+
 functions_noexcept = {
     'virDomainGetID': True,
     'virDomainGetName': True,
@@ -1065,6 +1080,12 @@ def buildWrappers():
                              classes_destructors[classname]);
                classes.write("        self._o = None\n\n");
                destruct=classes_destructors[classname]
+
+            if not class_skip_connect_impl.has_key(classname):
+                # Build python safe 'connect' method
+                classes.write("    def connect(self):\n")
+                classes.write("        return self._conn\n\n")
+
            flist = function_classes[classname]
            flist.sort(functionCompare)
            oldfile = ""