summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCole Robinson <crobinso@redhat.com>2009-09-23 12:38:47 -0400
committerCole Robinson <crobinso@redhat.com>2009-10-05 13:31:38 -0400
commit4659775fd18ffb4264fb4e225996f800319c3613 (patch)
tree3c00f9915f82d7eab476ae62ae37d84f8686f0f1
parent62a5096001b788532434a2b6b770c75af174a5d6 (diff)
downloadlibvirt-python-split-4659775fd18ffb4264fb4e225996f800319c3613.tar.gz
libvirt-python-split-4659775fd18ffb4264fb4e225996f800319c3613.tar.xz
libvirt-python-split-4659775fd18ffb4264fb4e225996f800319c3613.zip
python: Use a pure python implementation of 'vir*GetConnect'
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>
-rwxr-xr-xgenerator.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/generator.py b/generator.py
index 437de0c..de5507e 100755
--- a/generator.py
+++ b/generator.py
@@ -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 = ""