diff --git a/bindings/python/mapnik_feature.cpp b/bindings/python/mapnik_feature.cpp index de7595ff1..57cdec88c 100644 --- a/bindings/python/mapnik_feature.cpp +++ b/bindings/python/mapnik_feature.cpp @@ -94,9 +94,11 @@ namespace boost { namespace python { template static void - extension_def(Class& /*cl*/) + extension_def(Class& cl) { - + cl + .def("get", &get) + ; } static data_type& @@ -105,13 +107,25 @@ namespace boost { namespace python { typename Container::iterator i = container.props().find(i_); if (i == container.end()) { - PyErr_SetString(PyExc_KeyError, "Invalid key"); + PyErr_SetString(PyExc_KeyError, i_.c_str()); throw_error_already_set(); } // will be auto-converted to proper python type by `mapnik_value_to_python` return i->second; } + static data_type + get(Container& container, index_type i_) + { + typename Container::iterator i = container.props().find(i_); + if (i != container.end()) + { + // will be auto-converted to proper python type by `mapnik_value_to_python` + return i->second; + } + return mapnik::value_null(); + } + static void set_item(Container& container, index_type i, data_type const& v) {