Boost logo

Boost Users :

Subject: [Boost-users] Boost::python readonly access to nonconstant class members
From: Ralf Goertz (R_Goertz_at_[hidden])
Date: 2010-12-21 09:47:38


Hi,

is it possible to have python have readonly access to class members
that are non constant?

typedef map<string,string> Links;

class DataSet {
        Links links;
}

BOOST_PYTHON_MODULE(_boosttest) {
    class_<Links>("Links")
        .def(map_indexing_suite<Links>());

    class_<DataSet>("DataSet")
        .def_readonly("links",&DataSet::links);
}

Although DataSet.links is defined readonly I can change it from within
python. What can I do to prevent python from overwriting links?

Thanks,

Ralf


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net