------------------------------------------------------------ revno: 2140 fixes bug(s): https://launchpad.net/bugs/539562 committer: Václav Šmilauer <[email protected]> branch nick: trunk timestamp: Wed 2010-04-14 09:39:41 +0200 message: 1. Fix https://bugs.launchpad.net/yade/+bug/539562 (thanks, Luc) 2. Fix import warning in yade.remote modified: lib/serialization/Serializable.hpp py/remote.py
-- lp:yade https://code.launchpad.net/~yade-dev/yade/trunk Your team Yade developers is subscribed to branch lp:yade. To unsubscribe from this branch go to https://code.launchpad.net/~yade-dev/yade/trunk/+edit-subscription
=== modified file 'lib/serialization/Serializable.hpp' --- lib/serialization/Serializable.hpp 2010-04-01 06:53:09 +0000 +++ lib/serialization/Serializable.hpp 2010-04-14 07:39:41 +0000 @@ -35,8 +35,6 @@ #include"Archive.hpp" - - using namespace boost; using namespace std; using namespace ArchiveTypes; @@ -83,7 +81,14 @@ #define _PYKEYS_ATTR(x,y,z) ret.append(BOOST_PP_STRINGIZE(z)); #define _PYHASKEY_ATTR(x,y,z) if(key==BOOST_PP_STRINGIZE(z)) return true; #define _PYDICT_ATTR(x,y,z) ret[BOOST_PP_STRINGIZE(z)]=boost::python::object(z); -#define _PYATTR_DEF(x,thisClass,z) .def_readwrite(BOOST_PP_STRINGIZE(BOOST_PP_TUPLE_ELEM(2,0,z)),&thisClass::BOOST_PP_TUPLE_ELEM(2,0,z),BOOST_PP_TUPLE_ELEM(2,1,z)) +// see: +// https://bugs.launchpad.net/yade/+bug/539562 +// http://www.boost.org/doc/libs/1_42_0/libs/python/doc/v2/faq.html#topythonconversionfailed +// for reason why the original def_readwrite will not work: +// #define _PYATTR_DEF(x,thisClass,z) .def_readwrite(BOOST_PP_STRINGIZE(BOOST_PP_TUPLE_ELEM(2,0,z)),&thisClass::BOOST_PP_TUPLE_ELEM(2,0,z),BOOST_PP_TUPLE_ELEM(2,1,z)) +#define _PYATTR_DEF(x,thisClass,z) .DEF_READWRITE_CUSTOM(thisClass,BOOST_PP_TUPLE_ELEM(2,0,z),BOOST_PP_TUPLE_ELEM(2,1,z)) +#define DEF_READWRITE_CUSTOM(thisClass,attr,doc) add_property(/*attr name*/BOOST_PP_STRINGIZE(attr),/*read access*/boost::python::make_getter(&thisClass::attr,boost::python::return_value_policy<boost::python::return_by_value>()),/*write access*/boost::python::make_setter(&thisClass::attr,boost::python::return_value_policy<boost::python::return_by_value>()),/*docstring*/doc) + // macros for deprecated attribute access // gcc<=4.3 is not able to compile this code; we will just not generate any code for deprecated attributes in such case @@ -139,7 +144,7 @@ thisClass() BOOST_PP_IF(BOOST_PP_SEQ_SIZE(inits attrDecls),:,) BOOST_PP_SEQ_FOR_EACH_I(_ATTR_INI,BOOST_PP_DEC(BOOST_PP_SEQ_SIZE(inits attrDecls)), inits BOOST_PP_SEQ_FOR_EACH(_DECLINI4,~,attrDecls)) { ctor ; } /* ctor, with initialization of defaults */ \ _YADE_CLASS_BASE_DOC_ATTRS_DEPREC_PY(thisClass,baseClass,docString,BOOST_PP_SEQ_FOR_EACH(_STRIPDECL4,~,attrDecls),deprec,extras) -#define _STATATTR_PY(x,thisClass,z) .def_readwrite(BOOST_PP_STRINGIZE(BOOST_PP_TUPLE_ELEM(4,1,z)), &thisClass::BOOST_PP_TUPLE_ELEM(4,1,z), "|ystatic| :ydefault:`" BOOST_PP_STRINGIZE(BOOST_PP_TUPLE_ELEM(4,2,z)) "` " BOOST_PP_TUPLE_ELEM(4,3,z)) +#define _STATATTR_PY(x,thisClass,z) .DEF_READWRITE_CUSTOM(thisClass,BOOST_PP_TUPLE_ELEM(4,1,z),/*docstring*/ "|ystatic| :ydefault:`" BOOST_PP_STRINGIZE(BOOST_PP_TUPLE_ELEM(4,2,z)) "` " BOOST_PP_TUPLE_ELEM(4,3,z)) #define _STATATTR_DECL(x,y,z) static BOOST_PP_TUPLE_ELEM(4,0,z) BOOST_PP_TUPLE_ELEM(4,1,z); #define _STRIP_TYPE_DEFAULT_DOC(x,y,z) (BOOST_PP_TUPLE_ELEM(4,1,z)) === modified file 'py/remote.py' --- py/remote.py 2010-04-13 21:09:57 +0000 +++ py/remote.py 2010-04-14 07:39:41 +0000 @@ -9,14 +9,13 @@ import SocketServer import sys,time -from yade.wrapper import * +from yade import * class InfoSocketProvider(SocketServer.BaseRequestHandler): """Class providing dictionary of important simulation information, without authenticating the access.""" def handle(self): import pickle, os - O=Omega() ret=dict(iter=O.iter,dt=O.dt,stopAtIter=O.stopAtIter,realtime=O.realtime,time=O.time,id=O.tags['id'] if O.tags.has_key('id') else None,threads=os.environ['OMP_NUM_THREADS'] if os.environ.has_key('OMP_NUM_THREADS') else '0',numBodies=len(O.bodies),numIntrs=len(O.interactions)) self.request.send(pickle.dumps(ret)) @@ -27,7 +26,6 @@ The connection is authenticated by requiring a cookie. Only connections from localhost (127.0.0.*) are allowed. """ - from yade import * def setup(self): if not self.client_address[0].startswith('127.0.0'): print "TCP Connection from non-127.0.0.* address %s rejected"%self.client_address[0]
_______________________________________________ Mailing list: https://launchpad.net/~yade-dev Post to : [email protected] Unsubscribe : https://launchpad.net/~yade-dev More help : https://help.launchpad.net/ListHelp

