On 09/22/2011 09:43 AM, Wichert Akkerman wrote:
I am struggling to expose a map to python code. What I am doing is
pretty simple: I have a map from an enum type to Glib::ustring, with a
convertors registered to convert Python str and unicode instances to an
ustring, and ustring to Python unicode. I've put the relevant code below.
What I am running into is that the conversion from python to C++ types
is failing with a "No Python class registered for C++ class
Glib::ustring" error. This looks very similar to the FAQ entry "Why is
my automatic to-python conversion not being found?"
(http://www.boost.org/doc/libs/1_47_0/libs/python/doc/v2/faq.html#topythonconversionfailed
), and the workaround suggested there indeed works fine for class
properties. I can't seem to find a similar trick for map values though.
Is there a trick to get this working?
I think the easiest solution would be to try to switch to indexing suite
v2 (I think the newest version is found in the Py++ sources, although
you don't have to use Py++ to make use of it). With that, you can set
the call policies for returning elements from your container.
There are ways to do this with indexing suite v1 (the version that comes
with Boost.Python), but it'd be a lot harder, and I'm not certain what
approach to recommend that you try first in that case.
Jim
_______________________________________________
Cplusplus-sig mailing list
Cplusplus-sig@python.org
http://mail.python.org/mailman/listinfo/cplusplus-sig