Jason R. Coombs avatar Jason R. Coombs committed c92bf7d

It is no longer necessary to call jaraco.modb.init; modb bypasses the JSONPluginMgr altogether and uses the Pickler and Unpickler objects directly.

Comments (0)

Files changed (2)


-import jsonpickle
+import jsonpickle.pickler
+import jsonpickle.unpickler
 import pymongo.binary
 import jaraco.util.dictlib
 from jaraco.util.string import is_binary
 	return json
 def init():
-	# remove all other backends so only this one is used
-	orig_backends = list(jsonpickle.json._backend_names)
-	map(jsonpickle.remove_backend, orig_backends)
-	jsonpickle.load_backend(__name__, 'to_bson', 'from_bson', ValueError)
-	jsonpickle.set_preferred_backend(__name__)
+	warnings.warn("It is no longer necessary to call jaraco.modb.init",
+		DeprecationWarning)
-encode = jsonpickle.encode
-decode = jsonpickle.decode
+def encode(value):
+	return to_bson(jsonpickle.pickler.Pickler().flatten(value))
+def decode(value):
+	return jsonpickle.unpickler.Unpickler().restore(from_bson(value))


 import pymongo.binary
 import jaraco.modb
-def setup_module(module):
-	jaraco.modb.init()
 def test_to_bson():
 	sample = dict(
 		a = u'a string',
 	assert 'MyDict' in str(encoded)
 	decoded = jaraco.modb.decode(encoded)
 	assert isinstance(decoded, MyDict)
-def test_init():
-	"If init works correctly, jaraco.modb will be the only backend."
-	assert jaraco.modb.jsonpickle.json._backend_names == ['jaraco.modb']
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.