Boost logo

Boost :

From: David Abrahams (david.abrahams_at_[hidden])
Date: 2001-06-24 15:34:25


Karl,

This is supposed to work for Python 1.5.2. What is your target platform? On
some platforms, dynamically-linked objects all share the same namespace. If
that is the case for your platform, I'm guessing that the issue has to do
with the way Python 1.5.2 loads modules, as contrasted with 2.0. If that's
the case, it's a Python issue and not much can be done from our end. What
happens if you call the C++ function something other than "category" in one
of the modules (call the Python function wrapper "category" in both,
though)?

-Dave

----- Original Message -----
From: "Karl MacMillan" <karlmac_at_[hidden]>
To: <boost_at_[hidden]>
Sent: Sunday, June 24, 2001 3:13 PM
Subject: [boost] Python module namespace problems

> We're developing a interactive system involving a number of separate
> boost::python "plugins". Each plugin contains a function "category()"
> at the module level that returns a string defining the menu that the
> plugin should be added to at run-time.
>
> string category() { return "MyCategory"; }
> ...
> ====
> python::module_builder mPlugin("plugin");
> mPlugin.def(category, "category");
> ====
>
> This approach works great when compiling for Python 2.0, but with Python
> 1.5.2, the category function is the same for all plugins that get imported
> (it's the category function from the first module that is imported.)
>
> ==== (Python session)
> >>> import plugina
> >>> plugina.category()
> 'CategoryA'
> >>> import pluginb
> >>> pluginb.category()
> 'CategoryA'
> ==== (New python session)
> >>> import pluginb
> >>> pluginb.category()
> 'CategoryB'
> >>> import plugina
> >>> plugina.category()
> 'CategoryB'
> ====
>
> My apologies if this is a known issue. I was unable to find reference to
> this on the mailing list. It's one of our design requirements that this
> works for Python1.5.2 and 2.x. We would prefer not to resort to naming
> functions like plugina_category(), but if that's the only way... It
> just doesn't seem to fit with how Python namespaces generally work. Any
> suggestions/workarounds? I have tried embedding the function in a small
> class, and it doesn't work.
>
> Thanks!
>
> Karl
>
> _____________________________________________________
> | Karl W. MacMillan |
> | Computer Music Department |
> | Peabody Institute of the Johns Hopkins University |
> | karlmac_at_[hidden] |
> | mambo.peabody.jhu.edu/~karlmac |
> -----------------------------------------------------
>
>
> Info: http://www.boost.org Unsubscribe:
<mailto:boost-unsubscribe_at_[hidden]>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
>
>


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk