On Fri, Oct 02, 2009 at 01:46:51PM -0400, Cole Robinson wrote: > 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@xxxxxxxxxx> > --- > python/generator.py | 21 +++++++++++++++++++++ > 1 files changed, 21 insertions(+), 0 deletions(-) > > diff --git a/python/generator.py b/python/generator.py > index 437de0c..de5507e 100755 > --- a/python/generator.py > +++ b/python/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 = "" ACK Daniel -- |: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :| -- Libvir-list mailing list Libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list