Commit 7819ba75 authored by JINMEI Tatuya's avatar JINMEI Tatuya
Browse files

[trac983] moved LoaderError to a separate (sub) module

parent cf5ed0e7
......@@ -4,16 +4,26 @@ AM_CPPFLAGS = -I$(top_srcdir)/src/lib -I$(top_builddir)/src/lib
AM_CPPFLAGS += $(BOOST_INCLUDES)
AM_CXXFLAGS = $(B10_CXXFLAGS)
pyexec_LTLIBRARIES = dns.la
pyexec_LTLIBRARIES = acl.la dns.la
acl_la_SOURCES = acl.cc
acl_la_CPPFLAGS = $(AM_CPPFLAGS) $(PYTHON_INCLUDES)
acl_la_LDFLAGS = $(PYTHON_LDFLAGS)
acl_la_CXXFLAGS = $(AM_CXXFLAGS) $(PYTHON_CXXFLAGS)
dns_la_SOURCES = dns.cc dns_requestacl_python.h dns_requestacl_python.cc
dns_la_CPPFLAGS = $(AM_CPPFLAGS) $(PYTHON_INCLUDES)
dns_la_LDFLAGS = $(PYTHON_LDFLAGS)
# Note: PYTHON_CXXFLAGS may have some -Wno... workaround, which must be
# placed after -Wextra defined in AM_CXXFLAGS
acl_la_CXXFLAGS = $(AM_CXXFLAGS) $(PYTHON_CXXFLAGS)
dns_la_CXXFLAGS = $(AM_CXXFLAGS) $(PYTHON_CXXFLAGS)
# Python prefers .so, while some OSes (specifically MacOS) use a different
# suffix for dynamic objects. -module is necessary to work this around.
acl_la_LDFLAGS += -module
acl_la_LIBADD = $(top_builddir)/src/lib/acl/libdnsacl.la
acl_la_LIBADD += $(PYTHON_LIB)
dns_la_LDFLAGS += -module
dns_la_LIBADD = $(top_builddir)/src/lib/acl/libdnsacl.la
dns_la_LIBADD += $(PYTHON_LIB)
"""
Here are function and classes for manipulating access control lists.
"""
# Other ACL modules highly depends on the main acl sub module, so it's
# explicitly imported here.
import isc.acl.acl
// Copyright (C) 2011 Internet Systems Consortium, Inc. ("ISC")
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
// AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
// PERFORMANCE OF THIS SOFTWARE.
#include <Python.h>
#include <util/python/pycppwrapper_util.h>
#include "acl.h"
using namespace isc::util::python;
using namespace isc::acl::python;
namespace isc {
namespace acl {
namespace python {
PyObject* po_LoaderError;
}
}
}
namespace {
PyModuleDef acl = {
{ PyObject_HEAD_INIT(NULL) NULL, 0, NULL},
"isc.acl",
"This module provides Python bindings for the C++ classes in the "
"isc::acl namespace",
-1,
NULL,
NULL,
NULL,
NULL,
NULL
};
} // end of unnamed namespace
PyMODINIT_FUNC
PyInit_acl(void) {
PyObject* mod = PyModule_Create(&acl);
if (mod == NULL) {
return (NULL);
}
try {
po_LoaderError = PyErr_NewException("isc.acl.LoaderError", NULL, NULL);
PyObjectContainer(po_LoaderError).installToModule(mod, "LoaderError");
} catch (...) {
Py_DECREF(mod);
return (NULL);
}
return (mod);
}
// Copyright (C) 2011 Internet Systems Consortium, Inc. ("ISC")
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
// AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
// PERFORMANCE OF THIS SOFTWARE.
#ifndef __PYTHON_ACL_H
#define __PYTHON_ACL_H 1
#include <Python.h>
namespace isc {
namespace acl {
namespace python {
extern PyObject* po_LoaderError;
} // namespace python
} // namespace acl
} // namespace isc
#endif // __PYTHON_ACL_H
// Local Variables:
// mode: c++
// End:
# Copyright (C) 2011 Internet Systems Consortium.
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SYSTEMS CONSORTIUM
# DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
# INTERNET SYSTEMS CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
# FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
# NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
# WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
# This file is not installed. The log.so is installed into the right place.
# It is only to find it in the .libs directory when we run as a test or
# from the build directory.
# But as nobody gives us the builddir explicitly (and we can't use generation
# from .in file, as it would put us into the builddir and we wouldn't be found)
# we guess from current directory. Any idea for something better? This should
# be enough for the tests, but would it work for B10_FROM_SOURCE as well?
# Should we look there? Or define something in bind10_config?
import os
import sys
for base in sys.path[:]:
bindingdir = os.path.join(base, 'isc/acl/.libs')
if os.path.exists(bindingdir):
sys.path.insert(0, bindingdir)
from acl import *
......@@ -24,6 +24,7 @@
#include <acl/acl.h>
#include <acl/dns.h>
#include "acl.h"
#include "dns_requestacl_python.h"
using namespace std;
......@@ -34,8 +35,6 @@ using namespace isc::acl::dns;
using namespace isc::acl::dns::python;
namespace {
PyObject* po_dns_LoaderError;
PyObject*
loadRequestACL(PyObject*, PyObject* args) {
const char* acl_config;
......@@ -51,7 +50,7 @@ loadRequestACL(PyObject*, PyObject* args) {
}
return (py_acl);
} catch (const exception& ex) {
PyErr_SetString(po_dns_LoaderError, ex.what());
PyErr_SetString(isc::acl::python::po_LoaderError, ex.what());
return (NULL);
} catch (...) {
PyErr_SetString(PyExc_SystemError, "Unexpected C++ exception");
......@@ -91,16 +90,6 @@ PyInit_dns(void) {
return (NULL);
}
try {
po_dns_LoaderError = PyErr_NewException("isc.acl.dns.LoaderError",
NULL, NULL);
PyObjectContainer(po_dns_LoaderError).installToModule(mod,
"LoaderError");
} catch (...) {
Py_DECREF(mod);
return (NULL);
}
if (!initModulePart_RequestACL(mod)) {
Py_DECREF(mod);
return (NULL);
......
......@@ -14,6 +14,7 @@
# WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
import unittest
from isc.acl.acl import LoaderError
from isc.acl.dns import *
class RequestACLTest(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