Commit dca94882 authored by Jelte Jansen's avatar Jelte Jansen
Browse files

merge ticket #314 (better name for libdns_python)


git-svn-id: svn://bind10.isc.org/svn/bind10/trunk@2902 e5f2f494-b856-4b98-b285-d166d9295462
parents 63d71a11 ade3b2f4
......@@ -508,12 +508,12 @@ class TestXfrin(unittest.TestCase):
self.args)['result'][0], 1)
def test_command_handler_retransfer_nomodule(self):
dns_module = sys.modules['libdns_python'] # this must exist
del sys.modules['libdns_python']
dns_module = sys.modules['pydnspp'] # this must exist
del sys.modules['pydnspp']
self.assertEqual(self.xfr.command_handler("retransfer",
self.args)['result'][0], 1)
# sys.modules is global, so we must recover it
sys.modules['libdns_python'] = dns_module
sys.modules['pydnspp'] = dns_module
def test_command_handler_refresh(self):
# at this level, refresh is no different than retransfer.
......
......@@ -30,7 +30,7 @@ from optparse import OptionParser, OptionValueError
from isc.config.ccsession import *
from isc.notify import notify_out
try:
from libdns_python import *
from pydnspp import *
except ImportError as e:
# C++ loadable module may not be installed; even so the xfrin process
# must keep running, so we warn about it and move forward.
......@@ -522,8 +522,8 @@ class Xfrin:
def xfrin_start(self, zone_name, rrclass, db_file, master_addrinfo,
check_soa = True):
if "libdns_python" not in sys.modules:
return (1, "xfrin failed, can't load dns message python library: 'libdns_python'")
if "pydnspp" not in sys.modules:
return (1, "xfrin failed, can't load dns message python library: 'pydnspp'")
# check max_transfer_in, else return quota error
if self.recorder.count() >= self._max_transfers_in:
......
......@@ -19,7 +19,7 @@
import unittest
import os
from isc.cc.session import *
from libdns_python import *
from pydnspp import *
from xfrout import *
# our fake socket, where we can read and insert messages
......
......@@ -35,7 +35,7 @@ import errno
from optparse import OptionParser, OptionValueError
try:
from libxfr_python import *
from libdns_python import *
from pydnspp import *
except ImportError as e:
# C++ loadable module may not be installed; even so the xfrout process
# must keep running, so we warn about it and move forward.
......
......@@ -3,20 +3,14 @@ SUBDIRS = tests
AM_CPPFLAGS = -I$(top_srcdir)/src/lib -I$(top_builddir)/src/lib
AM_CXXFLAGS = $(B10_CXXFLAGS)
#lib_LTLIBRARIES = libdns_python_name.la libdns_python_rrset.la
#libdns_python_name_la_SOURCES = name_python.cc
#libdns_python_name_la_CPPFLAGS = $(AM_CPPFLAGS) $(PYTHON_INCLUDES)
#libdns_python_name_la_LDFLAGS = $(PYTHON_LDFLAGS)
#lib_LTLIBRARIES = libdns_python_name.la libdns_python_rrset.la
pyexec_LTLIBRARIES = libdns_python.la
libdns_python_la_SOURCES = libdns_python.cc libdns_python_common.cc
libdns_python_la_CPPFLAGS = $(AM_CPPFLAGS) $(PYTHON_INCLUDES)
libdns_python_la_LDFLAGS = $(PYTHON_LDFLAGS)
pyexec_LTLIBRARIES = pydnspp.la
pydnspp_la_SOURCES = pydnspp.cc pydnspp_common.cc
pydnspp_la_CPPFLAGS = $(AM_CPPFLAGS) $(PYTHON_INCLUDES)
pydnspp_la_LDFLAGS = $(PYTHON_LDFLAGS)
# directly included from source files, so these don't have their own
# rules
EXTRA_DIST = libdns_python_common.h
EXTRA_DIST = pydnspp_common.h
EXTRA_DIST += messagerenderer_python.cc
EXTRA_DIST += message_python.cc
EXTRA_DIST += rrclass_python.cc
......@@ -29,7 +23,7 @@ EXTRA_DIST += rrtype_python.cc
# Python prefers .so, while some OSes (specifically MacOS) use a different
# suffix for dynamic objects. -module is necessary to work this around.
libdns_python_la_LDFLAGS += -module
libdns_python_la_LIBADD = $(top_builddir)/src/lib/dns/libdns++.la
libdns_python_la_LIBADD += $(top_builddir)/src/lib/exceptions/libexceptions.la
libdns_python_la_LIBADD += $(PYTHON_LIB)
pydnspp_la_LDFLAGS += -module
pydnspp_la_LIBADD = $(top_builddir)/src/lib/dns/libdns++.la
pydnspp_la_LIBADD += $(top_builddir)/src/lib/exceptions/libexceptions.la
pydnspp_la_LIBADD += $(PYTHON_LIB)
This is an implementation of the python wrappers for isc::dns.
Currently, when compiled the module is called libdns_python. If we
When compiled the module is called pydnspp. If we
decide to always need it we can add a default import under
lib/python/isc.
To use it from the source tree, you must add src/lib/dns/python/.libs
to your PYTHONPATH environment variable. Within python you can then use
> import libdns_python
> rrc = libdns_python.RRClass("IN")
> import pydnspp
> rrc = pydnspp.RRClass("IN")
etc.
Notes:
......@@ -26,8 +26,8 @@ specific Rdata types.
If you have specific functionality you do need, please ask for it and we
will add it.
The 'main' module is defined in libdns_python.cc.
There is a libdns_python_common.[cc|h] for helper functions.
The 'main' module is defined in pydnspp.cc.
There is a pydnspp_common.[cc|h] for helper functions.
Implementation notes:
......@@ -87,7 +87,7 @@ This is repeated for every class we export.
Finally we define the function to add the class, constants, exceptions,
and enums to the module. This function is called from the init function
in libdns_python.cc, has the name
in pydnspp.cc, has the name
initModulePart_<c++ class name>, returns a boolean
(true on success, false on failure), and takes the module as a
PyObject*. There is a convenience function called addClassVariable to
......
......@@ -71,7 +71,7 @@ static PyMethodDef MessageFlag_methods[] = {
static PyTypeObject messageflag_type = {
PyVarObject_HEAD_INIT(NULL, 0)
"libdns_python.MessageFlag",
"pydnspp.MessageFlag",
sizeof(s_MessageFlag), // tp_basicsize
0, // tp_itemsize
(destructor)MessageFlag_destroy, // tp_dealloc
......@@ -248,7 +248,7 @@ static PyMethodDef Opcode_methods[] = {
static PyTypeObject opcode_type = {
PyVarObject_HEAD_INIT(NULL, 0)
"libdns_python.Opcode",
"pydnspp.Opcode",
sizeof(s_Opcode), // tp_basicsize
0, // tp_itemsize
(destructor)Opcode_destroy, // tp_dealloc
......@@ -532,7 +532,7 @@ static PyMethodDef Rcode_methods[] = {
static PyTypeObject rcode_type = {
PyVarObject_HEAD_INIT(NULL, 0)
"libdns_python.Rcode",
"pydnspp.Rcode",
sizeof(s_Rcode), // tp_basicsize
0, // tp_itemsize
(destructor)Rcode_destroy, // tp_dealloc
......@@ -802,7 +802,7 @@ static PyMethodDef Section_methods[] = {
static PyTypeObject section_type = {
PyVarObject_HEAD_INIT(NULL, 0)
"libdns_python.Section",
"pydnspp.Section",
sizeof(s_Section), // tp_basicsize
0, // tp_itemsize
(destructor)Section_destroy, // tp_dealloc
......@@ -1117,7 +1117,7 @@ static PyMethodDef Message_methods[] = {
// Most of the functions are not actually implemented and NULL here.
static PyTypeObject message_type = {
PyVarObject_HEAD_INIT(NULL, 0)
"libdns_python.Message",
"pydnspp.Message",
sizeof(s_Message), // tp_basicsize
0, // tp_itemsize
(destructor)Message_destroy, // tp_dealloc
......@@ -1627,15 +1627,15 @@ initModulePart_Message(PyObject* mod) {
addClassVariable(message_type, "DEFAULT_MAX_UDPSIZE", Py_BuildValue("I", Message::DEFAULT_MAX_UDPSIZE));
/* Class-specific exceptions */
po_MessageTooShort = PyErr_NewException("libdns_python.MessageTooShort", NULL, NULL);
po_MessageTooShort = PyErr_NewException("pydnspp.MessageTooShort", NULL, NULL);
PyModule_AddObject(mod, "MessageTooShort", po_MessageTooShort);
po_InvalidMessageSection = PyErr_NewException("libdns_python.InvalidMessageSection", NULL, NULL);
po_InvalidMessageSection = PyErr_NewException("pydnspp.InvalidMessageSection", NULL, NULL);
PyModule_AddObject(mod, "InvalidMessageSection", po_InvalidMessageSection);
po_InvalidMessageOperation = PyErr_NewException("libdns_python.InvalidMessageOperation", NULL, NULL);
po_InvalidMessageOperation = PyErr_NewException("pydnspp.InvalidMessageOperation", NULL, NULL);
PyModule_AddObject(mod, "InvalidMessageOperation", po_InvalidMessageOperation);
po_InvalidMessageUDPSize = PyErr_NewException("libdns_python.InvalidMessageUDPSize", NULL, NULL);
po_InvalidMessageUDPSize = PyErr_NewException("pydnspp.InvalidMessageUDPSize", NULL, NULL);
PyModule_AddObject(mod, "InvalidMessageUDPSize", po_InvalidMessageUDPSize);
po_DNSMessageBADVERS = PyErr_NewException("libdns_python.DNSMessageBADVERS", NULL, NULL);
po_DNSMessageBADVERS = PyErr_NewException("pydnspp.DNSMessageBADVERS", NULL, NULL);
PyModule_AddObject(mod, "DNSMessageBADVERS", po_DNSMessageBADVERS);
Py_INCREF(&message_type);
......
......@@ -62,7 +62,7 @@ static PyMethodDef MessageRenderer_methods[] = {
static PyTypeObject messagerenderer_type = {
PyVarObject_HEAD_INIT(NULL, 0)
"libdns_python.MessageRenderer",
"pydnspp.MessageRenderer",
sizeof(s_MessageRenderer), // tp_basicsize
0, // tp_itemsize
(destructor)MessageRenderer_destroy,// tp_dealloc
......
......@@ -68,7 +68,7 @@ static PyMethodDef NameComparisonResult_methods[] = {
static PyTypeObject name_comparison_result_type = {
PyVarObject_HEAD_INIT(NULL, 0)
"libdns_python.NameComparisonResult",
"pydnspp.NameComparisonResult",
sizeof(s_NameComparisonResult), // tp_basicsize
0, // tp_itemsize
(destructor)NameComparisonResult_destroy, // tp_dealloc
......@@ -222,7 +222,7 @@ static PyMethodDef Name_methods[] = {
static PyTypeObject name_type = {
PyVarObject_HEAD_INIT(NULL, 0)
"libdns_python.Name",
"pydnspp.Name",
sizeof(s_Name), // tp_basicsize
0, // tp_itemsize
(destructor)Name_destroy, // tp_dealloc
......@@ -651,30 +651,30 @@ initModulePart_Name(PyObject* mod) {
// Add the exceptions to the module
po_EmptyLabel = PyErr_NewException("libdns_python.EmptyLabel", NULL, NULL);
po_EmptyLabel = PyErr_NewException("pydnspp.EmptyLabel", NULL, NULL);
PyModule_AddObject(mod, "EmptyLabel", po_EmptyLabel);
po_TooLongName = PyErr_NewException("libdns_python.TooLongName", NULL, NULL);
po_TooLongName = PyErr_NewException("pydnspp.TooLongName", NULL, NULL);
PyModule_AddObject(mod, "TooLongName", po_TooLongName);
po_TooLongLabel = PyErr_NewException("libdns_python.TooLongLabel", NULL, NULL);
po_TooLongLabel = PyErr_NewException("pydnspp.TooLongLabel", NULL, NULL);
PyModule_AddObject(mod, "TooLongLabel", po_TooLongLabel);
po_BadLabelType = PyErr_NewException("libdns_python.BadLabelType", NULL, NULL);
po_BadLabelType = PyErr_NewException("pydnspp.BadLabelType", NULL, NULL);
PyModule_AddObject(mod, "BadLabelType", po_BadLabelType);
po_BadEscape = PyErr_NewException("libdns_python.BadEscape", NULL, NULL);
po_BadEscape = PyErr_NewException("pydnspp.BadEscape", NULL, NULL);
PyModule_AddObject(mod, "BadEscape", po_BadEscape);
po_IncompleteName = PyErr_NewException("libdns_python.IncompleteName", NULL, NULL);
po_IncompleteName = PyErr_NewException("pydnspp.IncompleteName", NULL, NULL);
PyModule_AddObject(mod, "IncompleteName", po_IncompleteName);
po_InvalidBufferPosition = PyErr_NewException("libdns_python.InvalidBufferPosition", NULL, NULL);
po_InvalidBufferPosition = PyErr_NewException("pydnspp.InvalidBufferPosition", NULL, NULL);
PyModule_AddObject(mod, "InvalidBufferPosition", po_InvalidBufferPosition);
// This one could have gone into the message_python.cc file, but is
// already needed here.
po_DNSMessageFORMERR = PyErr_NewException("libdns_python.DNSMessageFORMERR", NULL, NULL);
po_DNSMessageFORMERR = PyErr_NewException("pydnspp.DNSMessageFORMERR", NULL, NULL);
PyModule_AddObject(mod, "DNSMessageFORMERR", po_DNSMessageFORMERR);
return (true);
......
......@@ -38,7 +38,7 @@
#include <dns/name.h>
#include <dns/messagerenderer.h>
#include <dns/python/libdns_python_common.h>
#include <dns/python/pydnspp_common.h>
// For our 'general' isc::Exception
static PyObject* po_IscException;
......@@ -58,9 +58,9 @@ static PyObject* po_IscException;
//
// Definition of the module
//
static PyModuleDef libdns_python = {
static PyModuleDef pydnspp = {
{ PyObject_HEAD_INIT(NULL) NULL, 0, NULL},
"libdns_python",
"pydnspp",
"Python bindings for the classes in the isc::dns namespace.\n\n"
"These bindings match the original C++ API as closely as possible, "
"but are not complete. Some classes are unnecessary (InputBuffer "
......@@ -75,13 +75,13 @@ static PyModuleDef libdns_python = {
};
PyMODINIT_FUNC
PyInit_libdns_python(void) {
PyObject *mod = PyModule_Create(&libdns_python);
PyInit_pydnspp(void) {
PyObject *mod = PyModule_Create(&pydnspp);
if (mod == NULL) {
return (NULL);
}
po_IscException = PyErr_NewException("libdns_python.IscException", NULL, NULL);
po_IscException = PyErr_NewException("pydnspp.IscException", NULL, NULL);
PyModule_AddObject(mod, "IscException", po_IscException);
// for each part included above, we call its specific initializer
......
......@@ -15,7 +15,7 @@
// $Id$
#include <Python.h>
#include <libdns_python_common.h>
#include <pydnspp_common.h>
int
readDataFromSequence(uint8_t *data, size_t len, PyObject* sequence) {
......
......@@ -76,7 +76,7 @@ static PyMethodDef Question_methods[] = {
// Most of the functions are not actually implemented and NULL here.
static PyTypeObject question_type = {
PyVarObject_HEAD_INIT(NULL, 0)
"libdns_python.Question",
"pydnspp.Question",
sizeof(s_Question), // tp_basicsize
0, // tp_itemsize
(destructor)Question_destroy, // tp_dealloc
......
......@@ -92,7 +92,7 @@ static PyMethodDef Rdata_methods[] = {
// Most of the functions are not actually implemented and NULL here.
static PyTypeObject rdata_type = {
PyVarObject_HEAD_INIT(NULL, 0)
"libdns_python.Rdata",
"pydnspp.Rdata",
sizeof(s_Rdata), // tp_basicsize
0, // tp_itemsize
(destructor)Rdata_destroy, // tp_dealloc
......@@ -267,13 +267,13 @@ initModulePart_Rdata(PyObject* mod) {
reinterpret_cast<PyObject*>(&rdata_type));
// Add the exceptions to the class
po_InvalidRdataLength = PyErr_NewException("libdns_python.InvalidRdataLength", NULL, NULL);
po_InvalidRdataLength = PyErr_NewException("pydnspp.InvalidRdataLength", NULL, NULL);
PyModule_AddObject(mod, "InvalidRdataLength", po_InvalidRdataLength);
po_InvalidRdataText = PyErr_NewException("libdns_python.InvalidRdataText", NULL, NULL);
po_InvalidRdataText = PyErr_NewException("pydnspp.InvalidRdataText", NULL, NULL);
PyModule_AddObject(mod, "InvalidRdataText", po_InvalidRdataText);
po_CharStringTooLong = PyErr_NewException("libdns_python.CharStringTooLong", NULL, NULL);
po_CharStringTooLong = PyErr_NewException("pydnspp.CharStringTooLong", NULL, NULL);
PyModule_AddObject(mod, "CharStringTooLong", po_CharStringTooLong);
......
......@@ -100,7 +100,7 @@ static PyMethodDef RRClass_methods[] = {
// Most of the functions are not actually implemented and NULL here.
static PyTypeObject rrclass_type = {
PyVarObject_HEAD_INIT(NULL, 0)
"libdns_python.RRClass",
"pydnspp.RRClass",
sizeof(s_RRClass), // tp_basicsize
0, // tp_itemsize
(destructor)RRClass_destroy, // tp_dealloc
......@@ -332,10 +332,10 @@ static PyObject* RRClass_ANY(s_RRClass *self UNUSED_PARAM) {
bool
initModulePart_RRClass(PyObject* mod) {
// Add the exceptions to the module
po_InvalidRRClass = PyErr_NewException("libdns_python.InvalidRRClass", NULL, NULL);
po_InvalidRRClass = PyErr_NewException("pydnspp.InvalidRRClass", NULL, NULL);
Py_INCREF(po_InvalidRRClass);
PyModule_AddObject(mod, "InvalidRRClass", po_InvalidRRClass);
po_IncompleteRRClass = PyErr_NewException("libdns_python.IncompleteRRClass", NULL, NULL);
po_IncompleteRRClass = PyErr_NewException("pydnspp.IncompleteRRClass", NULL, NULL);
Py_INCREF(po_IncompleteRRClass);
PyModule_AddObject(mod, "IncompleteRRClass", po_IncompleteRRClass);
......
......@@ -94,7 +94,7 @@ static PyMethodDef RRset_methods[] = {
static PyTypeObject rrset_type = {
PyVarObject_HEAD_INIT(NULL, 0)
"libdns_python.RRset",
"pydnspp.RRset",
sizeof(s_RRset), // tp_basicsize
0, // tp_itemsize
(destructor)RRset_destroy, // tp_dealloc
......@@ -379,7 +379,7 @@ RRset_getRdata(s_RRset* self) {
bool
initModulePart_RRset(PyObject* mod) {
// Add the exceptions to the module
po_EmptyRRset = PyErr_NewException("libdns_python.EmptyRRset", NULL, NULL);
po_EmptyRRset = PyErr_NewException("pydnspp.EmptyRRset", NULL, NULL);
PyModule_AddObject(mod, "EmptyRRset", po_EmptyRRset);
// Add the enums to the module
......
......@@ -91,7 +91,7 @@ static PyMethodDef RRTTL_methods[] = {
// Most of the functions are not actually implemented and NULL here.
static PyTypeObject rrttl_type = {
PyVarObject_HEAD_INIT(NULL, 0)
"libdns_python.RRTTL",
"pydnspp.RRTTL",
sizeof(s_RRTTL), // tp_basicsize
0, // tp_itemsize
(destructor)RRTTL_destroy, // tp_dealloc
......@@ -296,9 +296,9 @@ RRTTL_richcmp(s_RRTTL* self, s_RRTTL* other, int op) {
bool
initModulePart_RRTTL(PyObject* mod) {
// Add the exceptions to the module
po_InvalidRRTTL = PyErr_NewException("libdns_python.InvalidRRTTL", NULL, NULL);
po_InvalidRRTTL = PyErr_NewException("pydnspp.InvalidRRTTL", NULL, NULL);
PyModule_AddObject(mod, "InvalidRRTTL", po_InvalidRRTTL);
po_IncompleteRRTTL = PyErr_NewException("libdns_python.IncompleteRRTTL", NULL, NULL);
po_IncompleteRRTTL = PyErr_NewException("pydnspp.IncompleteRRTTL", NULL, NULL);
PyModule_AddObject(mod, "IncompleteRRTTL", po_IncompleteRRTTL);
// We initialize the static description object with PyType_Ready(),
......
......@@ -130,7 +130,7 @@ static PyMethodDef RRType_methods[] = {
// Most of the functions are not actually implemented and NULL here.
static PyTypeObject rrtype_type = {
PyVarObject_HEAD_INIT(NULL, 0)
"libdns_python.RRType",
"pydnspp.RRType",
sizeof(s_RRType), // tp_basicsize
0, // tp_itemsize
(destructor)RRType_destroy, // tp_dealloc
......@@ -446,9 +446,9 @@ RRType_ANY(s_RRType *self UNUSED_PARAM) {
bool
initModulePart_RRType(PyObject* mod) {
// Add the exceptions to the module
po_InvalidRRType = PyErr_NewException("libdns_python.InvalidRRType", NULL, NULL);
po_InvalidRRType = PyErr_NewException("pydnspp.InvalidRRType", NULL, NULL);
PyModule_AddObject(mod, "InvalidRRType", po_InvalidRRType);
po_IncompleteRRType = PyErr_NewException("libdns_python.IncompleteRRType", NULL, NULL);
po_IncompleteRRType = PyErr_NewException("pydnspp.IncompleteRRType", NULL, NULL);
PyModule_AddObject(mod, "IncompleteRRType", po_IncompleteRRType);
// We initialize the static description object with PyType_Ready(),
......
......@@ -14,12 +14,12 @@
# WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#
# Tests for the message part of the libdns_python module
# Tests for the message part of the pydnspp module
#
import unittest
import os
from libdns_python import *
from pydnspp import *
class MessageFlagTest(unittest.TestCase):
......
......@@ -14,12 +14,12 @@
# WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#
# Tests for the messagerenderer part of the libdns_python module
# Tests for the messagerenderer part of the pydnspp module
#
import unittest
import os
from libdns_python import *
from pydnspp import *
class MessageRendererTest(unittest.TestCase):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment