[bind10-dev] python bindings
Francis Dupont
fdupont at isc.org
Wed Dec 16 16:03:43 UTC 2009
A first version of Python Bindings for BIND10 is in my home dir
on farside in pb4b10.tbz. Some comments:
- it was with jinmei-dnsmessageapi/src/lib/dns/cpp of yesterday
- C++ has to be compiled with -fPIC (add it in CXXFLAGS in ./configure)
- Python version must be >= 3.1 (mine is:
Python 3.1.1 (r311:74480, Dec 11 2009, 00:09:48) )
- I modified name.h to make the default constructor of Name public (1)
- I exported Name, MessageRenderer and a part of NameComparisonResult
from C++ to Python
- I encapsulated Name and MessageRenderer into Python subclass (2)
- I kept a flag naming, of course it should be isc.dns.* with
__init__.py 'package' files in place of the current cb
- I ported the interesting part of unittest files to Python
- there are many things to finish, for instance get a hash function
or marking types has not hashabled (__hash__ = None)
- if you put it in the svn, please add a copyright, a $Id$ (with
the svn property or it will stay $Id$), etc.
Regards
Francis Dupont <fdupont at isc.org>
PS (1): in Python there is only one __init__ method which initializes
instances so it doesn't match well with overloaded C++ constructors.
It is possible to write a factory function in C++ but its result will
stay in the built-in type. Another option is to use indirect inheritance
but all methods have to be redeclared... Perhaps an expert can help?
PPS (2): a builtin-type cannot be modified, i.e., if you tried to add
a method foo in Python by:
>>> cb.cName.foo = foo
you get:
TypeError: can't set attributes of built-in/extension type 'cb.cName'
This is the main reason (there are some others like the control on naming)
I encapsulated them.
More information about the bind10-dev
mailing list