From 9451c9f3312520ed0439d6a2189c7ad8071e124a Mon Sep 17 00:00:00 2001 From: Ross Lawley Date: Mon, 5 Mar 2012 13:14:36 +0000 Subject: [PATCH 1/8] Updated Readme - points to readthedocs --- README.rst | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/README.rst b/README.rst index f6866e3e..a8588c8c 100644 --- a/README.rst +++ b/README.rst @@ -3,20 +3,21 @@ MongoEngine =========== :Info: MongoEngine is an ORM-like layer on top of PyMongo. :Author: Harry Marr (http://github.com/hmarr) +:Maintainer: Ross Lawley (http://github.com/rozza) About ===== -MongoEngine is a Python Object-Document Mapper for working with MongoDB. -Documentation available at http://hmarr.com/mongoengine/ - there is currently -a `tutorial `_, a `user guide -`_ and an `API reference -`_. +MongoEngine is a Python Object-Document Mapper for working with MongoDB. +Documentation available at http://mongoengine-odm.rtfd.org - there is currently +a `tutorial `_, a `user guide +`_ and an `API reference +`_. Installation ============ If you have `setuptools `_ you can use ``easy_install -U mongoengine``. Otherwise, you can download the -source from `GitHub `_ and run ``python +source from `GitHub `_ and run ``python setup.py install``. Dependencies @@ -84,14 +85,14 @@ the standard port, and run ``python setup.py test``. Community ========= -- `MongoEngine Users mailing list +- `MongoEngine Users mailing list `_ -- `MongoEngine Developers mailing list +- `MongoEngine Developers mailing list `_ - `#mongoengine IRC channel `_ Contributing ============ -The source is available on `GitHub `_ - to +The source is available on `GitHub `_ - to contribute to the project, fork it on GitHub and send a pull request, all contributions and suggestions are welcome! From 82446d641e83ea8d3497474c19e0302c8ab678d3 Mon Sep 17 00:00:00 2001 From: Ross Lawley Date: Mon, 5 Mar 2012 14:28:33 +0000 Subject: [PATCH 2/8] Updated the spec --- python-mongoengine.spec | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/python-mongoengine.spec b/python-mongoengine.spec index d528d7a2..d0940820 100644 --- a/python-mongoengine.spec +++ b/python-mongoengine.spec @@ -5,13 +5,13 @@ %define srcname mongoengine Name: python-%{srcname} -Version: 0.5.3 +Version: 0.6 Release: 1%{?dist} Summary: A Python Document-Object Mapper for working with MongoDB Group: Development/Libraries License: MIT -URL: https://github.com/namlook/mongoengine +URL: https://github.com/MongoEngine/mongoengine Source0: %{srcname}-%{version}.tar.bz2 BuildRequires: python-devel @@ -51,6 +51,8 @@ rm -rf $RPM_BUILD_ROOT # %{python_sitearch}/* %changelog +* Mon Mar 05 2012 Ross Lawley 0.6 +- 0.6 released * Thu Oct 27 2011 Pau Aliagas 0.5.3-1 - Update to latest dev version - Add PIL dependency for ImageField From c34e79fad993946855232eb36f3491ac63e4eeb3 Mon Sep 17 00:00:00 2001 From: Ross Lawley Date: Mon, 5 Mar 2012 16:15:06 +0000 Subject: [PATCH 3/8] Fix replicaset connection --- mongoengine/connection.py | 1 + 1 file changed, 1 insertion(+) diff --git a/mongoengine/connection.py b/mongoengine/connection.py index dbde9e67..3efb7d30 100644 --- a/mongoengine/connection.py +++ b/mongoengine/connection.py @@ -109,6 +109,7 @@ def get_connection(alias=DEFAULT_CONNECTION_NAME, reconnect=False): connection_class = Connection if 'replicaSet' in conn_settings: + conn_settings['hosts_or_uri'] = conn_settings.pop('host', None) connection_class = ReplicaSetConnection try: _connections[alias] = connection_class(**conn_settings) From 859e9b3cc4ffa749a1dd45db7e11a7840482811f Mon Sep 17 00:00:00 2001 From: Ross Lawley Date: Mon, 5 Mar 2012 16:16:37 +0000 Subject: [PATCH 4/8] Version bump --- docs/changelog.rst | 4 ++-- mongoengine/__init__.py | 2 +- python-mongoengine.spec | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index f0a95d80..73748849 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -2,8 +2,8 @@ Changelog ========= -Changes in 0.6 -============== +Changes in 0.6.x +================ - Added FutureWarning to inherited classes not declaring 'allow_inheritance' as the default will change in 0.7 - Added support for covered indexes when inheritance is off diff --git a/mongoengine/__init__.py b/mongoengine/__init__.py index decfbb34..7b767940 100644 --- a/mongoengine/__init__.py +++ b/mongoengine/__init__.py @@ -12,7 +12,7 @@ from signals import * __all__ = (document.__all__ + fields.__all__ + connection.__all__ + queryset.__all__ + signals.__all__) -VERSION = (0, 6, 0) +VERSION = (0, 6, 1) def get_version(): diff --git a/python-mongoengine.spec b/python-mongoengine.spec index d0940820..8ce3ff60 100644 --- a/python-mongoengine.spec +++ b/python-mongoengine.spec @@ -5,7 +5,7 @@ %define srcname mongoengine Name: python-%{srcname} -Version: 0.6 +Version: 0.6.1 Release: 1%{?dist} Summary: A Python Document-Object Mapper for working with MongoDB From ed2cc2a60bf50e5694066fc03ae177cd2a85d955 Mon Sep 17 00:00:00 2001 From: Ross Lawley Date: Mon, 5 Mar 2012 16:20:37 +0000 Subject: [PATCH 5/8] Adding Jacob Peddicord to Authors --- AUTHORS | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS b/AUTHORS index 41d9c662..a5705eef 100644 --- a/AUTHORS +++ b/AUTHORS @@ -97,3 +97,4 @@ that much better: * Shalabh Aggarwal * Chris Williams * Robert Kajic + * Jacob Peddicord From 4c67cbb4b765cbbbcccaaad3a2f6512a1cb79c1f Mon Sep 17 00:00:00 2001 From: Ross Lawley Date: Tue, 6 Mar 2012 12:31:14 +0000 Subject: [PATCH 6/8] Updated upgrade docs. Reported issues with older pymongo and sharding --- docs/upgrade.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/upgrade.rst b/docs/upgrade.rst index 1609bb80..d6eabfe6 100644 --- a/docs/upgrade.rst +++ b/docs/upgrade.rst @@ -18,6 +18,8 @@ Document.objects.with_id - now raises an InvalidQueryError if used with a filter FutureWarning - A future warning has been added to all inherited classes that don't define `allow_inheritance` in their meta. +You may need to update pyMongo to 2.0 for use with Sharding. + 0.4 to 0.5 =========== From 737cbf5f6096b6ee397ed8d3e38f36f3406e7d2e Mon Sep 17 00:00:00 2001 From: Ross Lawley Date: Thu, 8 Mar 2012 12:39:25 +0000 Subject: [PATCH 7/8] Updated docs and added fix for _types and positional operator Bumped version to 0.6.2 --- docs/changelog.rst | 11 ++++++++++- docs/guide/connecting.rst | 5 +++++ mongoengine/queryset.py | 18 ++++++++++++++++-- python-mongoengine.spec | 2 +- tests/queryset.py | 6 +++--- 5 files changed, 35 insertions(+), 7 deletions(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index 73748849..e4c61321 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -2,7 +2,16 @@ Changelog ========= -Changes in 0.6.x +Changes in 0.6.2 +================ +- Updated documentation for ReplicaSet connections +- Hack round _types issue with SERVER-5247 - querying other arrays may also cause problems. + +Changes in 0.6.1 +================ +- Fix for replicaSet connections + +Changes in 0.6 ================ - Added FutureWarning to inherited classes not declaring 'allow_inheritance' as the default will change in 0.7 diff --git a/docs/guide/connecting.rst b/docs/guide/connecting.rst index 50eb2703..bc45dbfe 100644 --- a/docs/guide/connecting.rst +++ b/docs/guide/connecting.rst @@ -26,7 +26,12 @@ name - just supply the uri as the :attr:`host` to connect('project1', host='mongodb://localhost/database_name') +ReplicaSets +=========== +MongoEngine now supports :func:`~pymongo.replica_set_connection.ReplicaSetConnection` +to use them please use a URI style connection and provide the `replicaSet` name in the +connection kwargs. Multiple Databases ================== diff --git a/mongoengine/queryset.py b/mongoengine/queryset.py index 85a5152a..6d1c9c13 100644 --- a/mongoengine/queryset.py +++ b/mongoengine/queryset.py @@ -1371,8 +1371,15 @@ class QuerySet(object): write_options = {} update = QuerySet._transform_update(self._document, **update) + query = self._query + + # SERVER-5247 hack + remove_types = "_types" in query and ".$." in unicode(update) + if remove_types: + del query["_types"] + try: - ret = self._collection.update(self._query, update, multi=multi, + ret = self._collection.update(query, update, multi=multi, upsert=upsert, safe=safe_update, **write_options) if ret is not None and 'n' in ret: @@ -1400,10 +1407,17 @@ class QuerySet(object): if not write_options: write_options = {} update = QuerySet._transform_update(self._document, **update) + query = self._query + + # SERVER-5247 hack + remove_types = "_types" in query and ".$." in unicode(update) + if remove_types: + del query["_types"] + try: # Explicitly provide 'multi=False' to newer versions of PyMongo # as the default may change to 'True' - ret = self._collection.update(self._query, update, multi=False, + ret = self._collection.update(query, update, multi=False, upsert=upsert, safe=safe_update, **write_options) diff --git a/python-mongoengine.spec b/python-mongoengine.spec index 8ce3ff60..106243a4 100644 --- a/python-mongoengine.spec +++ b/python-mongoengine.spec @@ -5,7 +5,7 @@ %define srcname mongoengine Name: python-%{srcname} -Version: 0.6.1 +Version: 0.6.2 Release: 1%{?dist} Summary: A Python Document-Object Mapper for working with MongoDB diff --git a/tests/queryset.py b/tests/queryset.py index 97048953..ee3ab935 100644 --- a/tests/queryset.py +++ b/tests/queryset.py @@ -329,11 +329,11 @@ class QuerySetTest(unittest.TestCase): BlogPost(title="ABC", comments=[c1, c2]).save() - BlogPost.objects(comments__by="joe").update(inc__comments__S__votes=1) + BlogPost.objects(comments__by="jane").update(inc__comments__S__votes=1) post = BlogPost.objects.first() - self.assertEquals(post.comments[0].by, 'joe') - self.assertEquals(post.comments[0].votes, 4) + self.assertEquals(post.comments[1].by, 'jane') + self.assertEquals(post.comments[1].votes, 8) # Currently the $ operator only applies to the first matched item in # the query From 65591c772794dcc8782bb21e14fa8d44817780aa Mon Sep 17 00:00:00 2001 From: Ross Lawley Date: Thu, 8 Mar 2012 12:40:07 +0000 Subject: [PATCH 8/8] Version Bump --- mongoengine/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mongoengine/__init__.py b/mongoengine/__init__.py index 7b767940..0cc74a42 100644 --- a/mongoengine/__init__.py +++ b/mongoengine/__init__.py @@ -12,7 +12,7 @@ from signals import * __all__ = (document.__all__ + fields.__all__ + connection.__all__ + queryset.__all__ + signals.__all__) -VERSION = (0, 6, 1) +VERSION = (0, 6, 2) def get_version():