jaraco.modb /

Filename Size Date modified Message
34 B
327 B
1.4 KB
700 B



jaraco.modb is a small, pure-Python library for persisting Python objects to MongoDB.

jaraco.modb is written by Jason R. Coombs. It is licensed under an MIT-style permissive license.

You can install it with easy_install jaraco.modb or grab the source code from the mercurial repository.


jaraco.modb facilitates using jsonpickle to produce MongoDB-friendly representations of pickleable Python objects for easy storage in a MongoDB database.

The jsonpickle module requires initialization to use the backends supplied by jaraco.modb, so the application must first call init():

import jaraco.modb

Thereafter, one can simply encode and decode Python objects to MongoDB BSON-friendly representations:

class MyObject(object):
    def __init__(self, val):
        self.val = val

import pymongo
mongo_collection = pymongo.Connection().mydb.mycollection
val = MyObject(3)
# save the object to the DB
id = mongo_collection.save(jaraco.modb.encode(val))
# retrieve the object from the DB
new_val = jaraco.modb.decode(mongo_collection.find_one(id))
assert isinstance(new_val, MyObject)
assert new_val.val == 3



  • Initial release
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.