BIND 10 trac2853, updated. d340d8278228a062664eda13926f5af3daef8b35 [2853] Add Python wrappers around ZoneWriter methods
BIND 10 source code commits
bind10-changes at lists.isc.org
Wed Jun 5 11:51:32 UTC 2013
The branch, trac2853 has been updated
via d340d8278228a062664eda13926f5af3daef8b35 (commit)
from f26eae2533b0b2c6591ad6aa9116dc9ba00c462a (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit d340d8278228a062664eda13926f5af3daef8b35
Author: Mukund Sivaraman <muks at isc.org>
Date: Wed Jun 5 17:21:18 2013 +0530
[2853] Add Python wrappers around ZoneWriter methods
-----------------------------------------------------------------------
Summary of changes:
src/lib/python/isc/datasrc/zonewriter_python.cc | 70 +++++++++++++++++++++++
1 file changed, 70 insertions(+)
-----------------------------------------------------------------------
diff --git a/src/lib/python/isc/datasrc/zonewriter_python.cc b/src/lib/python/isc/datasrc/zonewriter_python.cc
index 93e0fe0..2f56808 100644
--- a/src/lib/python/isc/datasrc/zonewriter_python.cc
+++ b/src/lib/python/isc/datasrc/zonewriter_python.cc
@@ -28,11 +28,13 @@
#include <datasrc/memory/zone_writer.h>
#include "zonewriter_python.h"
+#include "datasrc.h"
using namespace std;
using namespace isc::util::python;
using namespace isc::datasrc;
using namespace isc::datasrc::memory;
+using namespace isc::datasrc::python;
using namespace isc::datasrc::memory::python;
//
@@ -79,6 +81,51 @@ ZoneWriter_destroy(PyObject* po_self) {
Py_TYPE(self)->tp_free(self);
}
+PyObject*
+ZoneWriter_load(PyObject* po_self, PyObject*) {
+ s_ZoneWriter* self = static_cast<s_ZoneWriter*>(po_self);
+ try {
+ self->cppobj->load();
+ } catch (const std::exception& exc) {
+ PyErr_SetString(getDataSourceException("Error"), exc.what());
+ return (NULL);
+ } catch (...) {
+ PyErr_SetString(getDataSourceException("Error"),
+ "Unknown C++ exception");
+ return (NULL);
+ }
+}
+
+PyObject*
+ZoneWriter_install(PyObject* po_self, PyObject*) {
+ s_ZoneWriter* self = static_cast<s_ZoneWriter*>(po_self);
+ try {
+ self->cppobj->install();
+ } catch (const std::exception& exc) {
+ PyErr_SetString(getDataSourceException("Error"), exc.what());
+ return (NULL);
+ } catch (...) {
+ PyErr_SetString(getDataSourceException("Error"),
+ "Unknown C++ exception");
+ return (NULL);
+ }
+}
+
+PyObject*
+ZoneWriter_cleanup(PyObject* po_self, PyObject*) {
+ s_ZoneWriter* self = static_cast<s_ZoneWriter*>(po_self);
+ try {
+ self->cppobj->cleanup();
+ } catch (const std::exception& exc) {
+ PyErr_SetString(getDataSourceException("Error"), exc.what());
+ return (NULL);
+ } catch (...) {
+ PyErr_SetString(getDataSourceException("Error"),
+ "Unknown C++ exception");
+ return (NULL);
+ }
+}
+
// This list contains the actual set of functions we have in
// python. Each entry has
// 1. Python method name
@@ -86,6 +133,29 @@ ZoneWriter_destroy(PyObject* po_self) {
// 3. Argument type
// 4. Documentation
PyMethodDef ZoneWriter_methods[] = {
+ { "load", ZoneWriter_load, METH_NOARGS,
+ "load() -> None\n\
+\n\
+Get the zone data into memory.\n\
+\n\
+This is the part that does the time-consuming loading into the memory.\n\
+This can be run in a separate thread, for example. It has no effect on\n\
+the data actually served, it only prepares them for future use." },
+ { "install", ZoneWriter_install, METH_NOARGS,
+ "install() -> None\n\
+\n\
+Put the changes to effect.\n\
+\n\
+This replaces the old version of zone with the one previously prepared\n\
+by load(). It takes ownership of the old zone data, if any." },
+ { "cleanup", ZoneWriter_cleanup, METH_NOARGS,
+ "cleanup() -> None\n\
+\n\
+Clean up resources.\n\
+\n\
+This releases all resources held by owned zone data. That means the\n\
+one loaded by load() in case install() was not called or was not\n\
+successful, or the one replaced in install()." },
{ NULL, NULL, 0, NULL }
};
More information about the bind10-changes
mailing list