Info: | See the mongodb site for more information. See github for the latest source. |
---|---|
Author: | Mike Dirolf <mike@10gen.com> |
The MongoDB AppEngine Connector provides a drop-in replacement for App Engine's datastore API, using MongoDB as a backend.
Questions about the MongoDB AppEngine Connector should be directed to the mongodb-user group at Google Groups.
http://groups.google.com/group/mongodb-user
In order to use the adapter, you must patch the AppEngine source distribution. Google AE source can be found at Google Code :
http://code.google.com/p/googleappengine/
and to check out a read-only copy of the svn repository :
$ svn checkout http://googleappengine.googlecode.com/svn/trunk/ googleappengine-read-only
Patches are found in the gae_patches/ directory and are stored by svn revision number. To find the revision number of the respository that you checked out, go into the root of the repository and type :
$ svn info
This adapter has been tested against revision 41 from Google AppEngine's svn repository. The following patch (generated by svn diff) shows how to modify the AppEngine code in order to use MongoDB:
Index: dev_appserver.py =================================================================== --- dev_appserver.py (revision 41) +++ dev_appserver.py (working copy) @@ -37,6 +37,7 @@ SCRIPT_DIR = os.path.join(DIR_PATH, 'google', 'appengine', 'tools') EXTRA_PATHS = [ + "PATH/TO/MONGO-APPENGINE-CONNECTOR/DIRECTORY", DIR_PATH, os.path.join(DIR_PATH, 'lib', 'antlr3'), os.path.join(DIR_PATH, 'lib', 'django'), Index: google/appengine/tools/dev_appserver.py =================================================================== --- google/appengine/tools/dev_appserver.py (revision 41) +++ google/appengine/tools/dev_appserver.py (working copy) @@ -75,7 +75,7 @@ from google.appengine.api import apiproxy_stub_map from google.appengine.api import appinfo from google.appengine.api import datastore_admin -from google.appengine.api import datastore_file_stub +import datastore_mongo_stub from google.appengine.api import mail_stub from google.appengine.api import urlfetch_stub from google.appengine.api import user_service_stub @@ -3001,7 +3001,7 @@ apiproxy_stub_map.apiproxy = apiproxy_stub_map.APIProxyStubMap() - datastore = datastore_file_stub.DatastoreFileStub( + datastore = datastore_mongo_stub.DatastoreMongoStub( app_id, datastore_path, history_path, require_indexes=require_indexes) apiproxy_stub_map.apiproxy.RegisterStub('datastore_v3', datastore)
The path added to dev_appserver.py should be replaced with the path where this directory is located on your machine. This patch should then be applied against a clean version of the AppEngine svn repository.
To apply the patch, just do the following from a command line, assuming that you've checked out the source as a read-only repo :
$ cd googleappengine-read-only $ patch -p0 < gae_patch_r41.txt
you should see output similar to
patching file dev_appserver.py patching file google/appengine/tools/dev_appserver.py
If you see no error messages, your patching was successful.
- You must have a copy of the PyMongo distribution installed in order to use the AppEngine Connector.
- Right now, the Connection cannot be configured. It attempts to connect to a standalone MongoDB instance on localhost:27017.
- Transactions are unsupported. When any operation requiring transactions is performed a warning will be logged and the operation will be performed transaction-less.
- DateTime values get rounded to the nearest millisecond when saved to MongoDB. This is a limitation of MongoDB's date representation, and is not specific to this adaptor.
- In order to actually create indexes the dev_appserver must be run with the --require-indexes option. Running with this option will probably add significant overhead, since each time the dev_appserver checks to see if it should create an index a query is performed.
- Index creation ignores the "Ancestor" option. This option would just create an index on '_id', which (soon) MongoDB creates automatically anyway.