{"comment":{"created_at":"2011-10-11T15:05:29Z","body":"[springmeyer] Ah, so a simple `copy()` of a map object without a background color fails as well.\r\n\r\nThis error clarifies that the Color object needs a __setstate__ method:\r\n\r\n{{{\r\n>>> m = Map(45,45)\r\n>>> from copy import copy\r\n# /System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/copy.pyc matches /System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/copy.py\r\nimport copy # precompiled from /System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/copy.pyc\r\n>>> copy(m)\r\nTraceback (most recent call last):\r\n  File \"<stdin>\", line 1, in <module>\r\n  File \"/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/copy.py\", line 95, in copy\r\n    return _reconstruct(x, rv, 0)\r\n  File \"/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/copy.py\", line 339, in _reconstruct\r\n    y.__setstate__(state)\r\nTypeError: No registered converter was able to produce a C++ rvalue of type mapnik::color from this Python object of type NoneType\r\n>>> m.background = Color('white')\r\nTraceback (most recent call last):\r\n  File \"<stdin>\", line 1, in <module>\r\nNameError: name 'Color' is not defined\r\n>>> from mapnik import *\r\n>>> m.background = Color('white')\r\n>>> copy(m)\r\n<mapnik._mapnik.Map object at 0x84d20>\r\n}}}","updated_at":"2011-10-11T15:05:29Z","url":"https://api.github.com/repos/artemp/tickets2issues/issues/comments/2363169","id":2363169,"user":{"avatar_url":"https://secure.gravatar.com/avatar/941f68386168a8a6b60f2529a7830af7?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","url":"https://api.github.com/users/artemp","id":59056,"login":"artemp"}},"action":"created","issue":{"number":251,"created_at":"2011-10-11T15:05:24Z","pull_request":{"diff_url":null,"patch_url":null,"html_url":null},"body":"It appears that the Color class is not properly pickle-able, despite having a `color_pickle_suite` defined in source:trunk/bindings/python/mapnik_color.cpp#L32\r\n\r\n{{{\r\n>>> import pickle\r\n>>> import mapnik\r\n>>> output = open('map.pkl', 'wb')\r\n>>> m = mapnik.Map(45,45)\r\n>>> m.background = mapnik.Color(0,0,0)\r\n>>> pickle.dump(m, output)\r\nTraceback (most recent call last):\r\n  File \"<stdin>\", line 1, in <module>\r\n  File \"/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/pickle.py\", line 1362, in dump\r\n    Pickler(file, protocol).dump(obj)\r\n  File \"/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/pickle.py\", line 224, in dump\r\n    self.save(obj)\r\n  File \"/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/pickle.py\", line 331, in save\r\n    self.save_reduce(obj=obj, *rv)\r\n  File \"/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/pickle.py\", line 419, in save_reduce\r\n    save(state)\r\n  File \"/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/pickle.py\", line 286, in save\r\n    f(self, obj) # Call unbound method with explicit self\r\n  File \"/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/pickle.py\", line 562, in save_tuple\r\n    save(element)\r\n  File \"/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/pickle.py\", line 331, in save\r\n    self.save_reduce(obj=obj, *rv)\r\n  File \"/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/pickle.py\", line 400, in save_reduce\r\n    save(func)\r\n  File \"/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/pickle.py\", line 295, in save\r\n    self.save_global(obj)\r\n  File \"/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/pickle.py\", line 753, in save_global\r\n    (obj, module, name))\r\npickle.PicklingError: Can't pickle <class 'mapnik._mapnik.Color'>: it's not the same object as mapnik._mapnik.Color\r\n}}}\r\n\r\nalso, without explicitly setting a background color, error upon loading the pickled map:\r\n\r\n{{{\r\n>>> import pickle\r\n>>> import mapnik\r\n>>> output = open('map.pkl', 'wb')\r\n>>> m = mapnik.Map(45,45)\r\n>>> pickle.dump(m, output)\r\n>>> output.close()\r\n>>> reader = pickle.load(open('map.pkl', 'rb'))\r\nTraceback (most recent call last):\r\n  File \"<stdin>\", line 1, in <module>\r\n  File \"/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/pickle.py\", line 1370, in load\r\n    return Unpickler(file).load()\r\n  File \"/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/pickle.py\", line 858, in load\r\n    dispatch[key](self)\r\n  File \"/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/pickle.py\", line 1217, in load_build\r\n    setstate(state)\r\nTypeError: No registered converter was able to produce a C++ rvalue of type mapnik::Color from this Python object of type NoneType\r\n}}}","comments":8,"title":"Map pickling failure due to mapnik.Color object","updated_at":"2011-10-11T15:05:29Z","url":"https://api.github.com/repos/artemp/tickets2issues/issues/251","id":1875965,"assignee":null,"milestone":{"number":6,"created_at":"2011-10-11T14:50:00Z","due_on":"1970-01-01T09:20:38Z","title":"0.6.0","creator":{"avatar_url":"https://secure.gravatar.com/avatar/941f68386168a8a6b60f2529a7830af7?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","url":"https://api.github.com/users/artemp","id":59056,"login":"artemp"},"url":"https://api.github.com/repos/artemp/tickets2issues/milestones/6","open_issues":1,"closed_issues":68,"description":"=== Summary ===\r\n\r\nThis release offers a great advancement in usability and features such as several new plugins, advanced symbolization, and ICU unicode support.\r\n\r\nOver 140 tickets were closed against this milestone, and builds across both linux, mac and windows should be working better than ever.\r\n\r\nWe also now have a fresh set of [http://svn.mapnik.org/trunk/docs/api_docs/python/index.html Python API Docs (Epydocs)].\r\n\r\nEnjoy,\r\n\r\nDane\r\n\r\n\r\n=== Highlights ===\r\n\r\n * New ICU unicode support via Artem's genius\r\n\r\n * [http://trac.mapnik.org/wiki/MapnikRenderers#Cairographics Cairo] rendering backend - thanks Tom!\r\n\r\n * XML [http://svn.mapnik.org/trunk/docs/api_docs/python/mapnik-module.html#load_map_from_string from a string] - wicked nice Jonb\r\n \r\n * Support for [http://trac.mapnik.org/wiki/RasterSymbolizer raster composing modes] targeted at hillshading - Nice Marcin!\r\n\r\n * Tons of [PluginArchitecture new plugins] - OSM (nick), Oracle, OGR, SQlite (kunitoki)\r\n\r\n * Big improvements to [UsingScons SCons] - experience it for yourself and build it :) (Thanks jbronn for the boost help)\r\n\r\n * In memory [http://trac.mapnik.org/ticket/192 PointDatasource ] for dynamically drawing geometries - lwu rocks!\r\n\r\n * Love for the OgcServer - thanks xcacou, tmcw, and theo - it works with OSM xml, WMS 1.3.0, and a whole lot more.\r\n\r\n * We've got FontSet support (fallback fonts) from Beau- nice stuff\r\n \r\n * [http://trac.mapnik.org/ticket/117 ProjTransform] exposed by Artem in python. Now you can transform bbox's between projected systems.\r\n\r\n * Mapnik is faster (#156) with projections and PostGIS (#139,#140,#141) thanks to the genius of Rcoup\r\n\r\n * Map buffers to avoid cut labels - thanks Artem!\r\n\r\n * Transparent Point Symbolizers - good stuff Brian!\r\n\r\nFor a full list of major changes see the 0.6.0 Changelog wiki:Release0.6.0\r\n\r\n","state":"open"},"closed_at":null,"user":{"avatar_url":"https://secure.gravatar.com/avatar/941f68386168a8a6b60f2529a7830af7?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","url":"https://api.github.com/users/artemp","id":59056,"login":"artemp"},"html_url":"https://github.com/artemp/tickets2issues/issues/251","labels":[{"name":"Boost_Python_Binding","url":"https://api.github.com/repos/artemp/tickets2issues/labels/Boost_Python_Binding","color":"FFFFFF"}],"state":"open"},"legacy":{"issue_id":1875965,"comment_id":2363169}}