Skip to content

Commit 7fb1c9d

Browse files
author
erdenezul
authored
Merge branch 'master' into master
2 parents 9f02f71 + 0fffacc commit 7fb1c9d

34 files changed

+1484
-215
lines changed

.install_mongodb_on_travis.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#!/bin/bash
22

3+
sudo apt-get remove mongodb-org-server
34
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10
45

56
if [ "$MONGODB" = "2.4" ]; then
@@ -13,11 +14,14 @@ elif [ "$MONGODB" = "2.6" ]; then
1314
sudo apt-get install mongodb-org-server=2.6.12
1415
# service should be started automatically
1516
elif [ "$MONGODB" = "3.0" ]; then
16-
echo "deb http://repo.mongodb.org/apt/ubuntu precise/mongodb-org/3.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb.list
17+
echo "deb http://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/3.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb.list
1718
sudo apt-get update
1819
sudo apt-get install mongodb-org-server=3.0.14
1920
# service should be started automatically
2021
else
2122
echo "Invalid MongoDB version, expected 2.4, 2.6, or 3.0."
2223
exit 1
2324
fi;
25+
26+
mkdir db
27+
1>db/logs mongod --dbpath=db &

.travis.yml

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,33 +15,34 @@ language: python
1515
python:
1616
- 2.7
1717
- 3.5
18+
- 3.6
1819
- pypy
1920

2021
env:
21-
- MONGODB=2.6 PYMONGO=2.7
22-
- MONGODB=2.6 PYMONGO=2.8
23-
- MONGODB=2.6 PYMONGO=3.0
22+
- MONGODB=2.6 PYMONGO=3.x
2423

2524
matrix:
2625
# Finish the build as soon as one job fails
2726
fast_finish: true
2827

2928
include:
3029
- python: 2.7
31-
env: MONGODB=2.4 PYMONGO=2.7
30+
env: MONGODB=2.4 PYMONGO=3.5
3231
- python: 2.7
33-
env: MONGODB=2.4 PYMONGO=3.0
34-
- python: 2.7
35-
env: MONGODB=3.0 PYMONGO=3.0
36-
- python: 3.5
37-
env: MONGODB=2.4 PYMONGO=2.7
32+
env: MONGODB=3.0 PYMONGO=3.x
3833
- python: 3.5
39-
env: MONGODB=2.4 PYMONGO=3.0
34+
env: MONGODB=2.4 PYMONGO=3.5
4035
- python: 3.5
41-
env: MONGODB=3.0 PYMONGO=3.0
36+
env: MONGODB=3.0 PYMONGO=3.x
37+
- python: 3.6
38+
env: MONGODB=2.4 PYMONGO=3.5
39+
- python: 3.6
40+
env: MONGODB=3.0 PYMONGO=3.x
4241

4342
before_install:
4443
- bash .install_mongodb_on_travis.sh
44+
- sleep 15 # https://docs.travis-ci.com/user/database-setup/#MongoDB-does-not-immediately-accept-connections
45+
- mongo --eval 'db.version();'
4546

4647
install:
4748
- sudo apt-get install python-dev python3-dev libopenjpeg-dev zlib1g-dev libjpeg-turbo8-dev
@@ -90,7 +91,7 @@ deploy:
9091
distributions: "sdist bdist_wheel"
9192

9293
# only deploy on tagged commits (aka GitHub releases) and only for the
93-
# parent repo's builds running Python 2.7 along with dev PyMongo (we run
94+
# parent repo's builds running Python 2.7 along with PyMongo v3.0 (we run
9495
# Travis against many different Python and PyMongo versions and we don't
9596
# want the deploy to occur multiple times).
9697
on:

AUTHORS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,3 +243,6 @@ that much better:
243243
* Victor Varvaryuk
244244
* Stanislav Kaledin (https://github.com/sallyruthstruik)
245245
* Dmitry Yantsen (https://github.com/mrTable)
246+
* Renjianxin (https://github.com/Davidrjx)
247+
* Erdenezul Batmunkh (https://github.com/erdenezul)
248+
* Andy Yankovsky (https://github.com/werat)

docs/apireference.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,9 @@ Fields
8787
.. autoclass:: mongoengine.fields.DictField
8888
.. autoclass:: mongoengine.fields.MapField
8989
.. autoclass:: mongoengine.fields.ReferenceField
90+
.. autoclass:: mongoengine.fields.LazyReferenceField
9091
.. autoclass:: mongoengine.fields.GenericReferenceField
92+
.. autoclass:: mongoengine.fields.GenericLazyReferenceField
9193
.. autoclass:: mongoengine.fields.CachedReferenceField
9294
.. autoclass:: mongoengine.fields.BinaryField
9395
.. autoclass:: mongoengine.fields.FileField

docs/changelog.rst

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,30 @@
22
Changelog
33
=========
44

5-
Development
6-
===========
7-
- (Fill this out as you fix issues and develop your features).
5+
dev
6+
===
7+
- Subfield resolve error in generic_emdedded_document query #1651 #1652
8+
- use each modifier only with $position #1673 #1675
9+
- Improve LazyReferenceField and GenericLazyReferenceField with nested fields #1704
10+
- Fix validation error instance in GenericEmbeddedDocumentField #1067
11+
- Update cached fields when fields argument is given #1712
12+
- Add a db parameter to register_connection for compatibility with connect
13+
- Use insert_one, insert_many in Document.insert #1491
14+
- Use new update_one, update_many on document/queryset update #1491
15+
- Use insert_one, insert_many in Document.insert #1491
16+
- Fix reload(fields) affect changed fields #1371
17+
18+
Changes in 0.15.0
19+
=================
20+
- Add LazyReferenceField and GenericLazyReferenceField to address #1230
21+
22+
Changes in 0.14.1
23+
=================
24+
- Removed SemiStrictDict and started using a regular dict for `BaseDocument._data` #1630
25+
- Added support for the `$position` param in the `$push` operator #1566
26+
- Fixed `DateTimeField` interpreting an empty string as today #1533
27+
- Added a missing `__ne__` method to the `GridFSProxy` class #1632
28+
- Fixed `BaseQuerySet._fields_to_db_fields` #1553
829

930
Changes in 0.14.0
1031
=================

docs/guide/defining-documents.rst

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ objects** as class attributes to the document class::
2222

2323
class Page(Document):
2424
title = StringField(max_length=200, required=True)
25-
date_modified = DateTimeField(default=datetime.datetime.now)
25+
date_modified = DateTimeField(default=datetime.datetime.utcnow)
2626

2727
As BSON (the binary format for storing data in mongodb) is order dependent,
2828
documents are serialized based on their field order.
@@ -80,13 +80,15 @@ are as follows:
8080
* :class:`~mongoengine.fields.FloatField`
8181
* :class:`~mongoengine.fields.GenericEmbeddedDocumentField`
8282
* :class:`~mongoengine.fields.GenericReferenceField`
83+
* :class:`~mongoengine.fields.GenericLazyReferenceField`
8384
* :class:`~mongoengine.fields.GeoPointField`
8485
* :class:`~mongoengine.fields.ImageField`
8586
* :class:`~mongoengine.fields.IntField`
8687
* :class:`~mongoengine.fields.ListField`
8788
* :class:`~mongoengine.fields.MapField`
8889
* :class:`~mongoengine.fields.ObjectIdField`
8990
* :class:`~mongoengine.fields.ReferenceField`
91+
* :class:`~mongoengine.fields.LazyReferenceField`
9092
* :class:`~mongoengine.fields.SequenceField`
9193
* :class:`~mongoengine.fields.SortedListField`
9294
* :class:`~mongoengine.fields.StringField`
@@ -224,7 +226,7 @@ store; in this situation a :class:`~mongoengine.fields.DictField` is appropriate
224226
user = ReferenceField(User)
225227
answers = DictField()
226228

227-
survey_response = SurveyResponse(date=datetime.now(), user=request.user)
229+
survey_response = SurveyResponse(date=datetime.utcnow(), user=request.user)
228230
response_form = ResponseForm(request.POST)
229231
survey_response.answers = response_form.cleaned_data()
230232
survey_response.save()
@@ -526,8 +528,9 @@ There are a few top level defaults for all indexes that can be set::
526528
meta = {
527529
'index_options': {},
528530
'index_background': True,
531+
'index_cls': False,
532+
'auto_create_index': True,
529533
'index_drop_dups': True,
530-
'index_cls': False
531534
}
532535

533536

@@ -540,6 +543,12 @@ There are a few top level defaults for all indexes that can be set::
540543
:attr:`index_cls` (Optional)
541544
A way to turn off a specific index for _cls.
542545

546+
:attr:`auto_create_index` (Optional)
547+
When this is True (default), MongoEngine will ensure that the correct
548+
indexes exist in MongoDB each time a command is run. This can be disabled
549+
in systems where indexes are managed separately. Disabling this will improve
550+
performance.
551+
543552
:attr:`index_drop_dups` (Optional)
544553
Set the default value for if an index should drop duplicates
545554

@@ -618,7 +627,7 @@ collection after a given period. See the official
618627
documentation for more information. A common usecase might be session data::
619628

620629
class Session(Document):
621-
created = DateTimeField(default=datetime.now)
630+
created = DateTimeField(default=datetime.utcnow)
622631
meta = {
623632
'indexes': [
624633
{'fields': ['created'], 'expireAfterSeconds': 3600}

docs/guide/querying.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -565,6 +565,15 @@ cannot use the `$` syntax in keyword arguments it has been mapped to `S`::
565565
>>> post.tags
566566
['database', 'mongodb']
567567

568+
From MongoDB version 2.6, push operator supports $position value which allows
569+
to push values with index.
570+
>>> post = BlogPost(title="Test", tags=["mongo"])
571+
>>> post.save()
572+
>>> post.update(push__tags__0=["database", "code"])
573+
>>> post.reload()
574+
>>> post.tags
575+
['database', 'code', 'mongo']
576+
568577
.. note::
569578
Currently only top level lists are handled, future versions of mongodb /
570579
pymongo plan to support nested positional operators. See `The $ positional

docs/guide/signals.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,10 @@ Available signals include:
4343
has taken place but before saving.
4444

4545
`post_save`
46-
Called within :meth:`~mongoengine.Document.save` after all actions
47-
(validation, insert/update, cascades, clearing dirty flags) have completed
48-
successfully. Passed the additional boolean keyword argument `created` to
49-
indicate if the save was an insert or an update.
46+
Called within :meth:`~mongoengine.Document.save` after most actions
47+
(validation, insert/update, and cascades, but not clearing dirty flags) have
48+
completed successfully. Passed the additional boolean keyword argument
49+
`created` to indicate if the save was an insert or an update.
5050

5151
`pre_delete`
5252
Called within :meth:`~mongoengine.Document.delete` prior to

docs/guide/text-indexes.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,4 @@ Ordering by text score
4848

4949
::
5050

51-
objects = News.objects.search('mongo').order_by('$text_score')
51+
objects = News.objects.search_text('mongo').order_by('$text_score')

docs/tutorial.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ of them stand out as particularly intuitive solutions.
8686
Posts
8787
^^^^^
8888

89-
Happily mongoDB *isn't* a relational database, so we're not going to do it that
89+
Happily MongoDB *isn't* a relational database, so we're not going to do it that
9090
way. As it turns out, we can use MongoDB's schemaless nature to provide us with
9191
a much nicer solution. We will store all of the posts in *one collection* and
9292
each post type will only store the fields it needs. If we later want to add
@@ -153,7 +153,7 @@ post. This works, but there is no real reason to be storing the comments
153153
separately from their associated posts, other than to work around the
154154
relational model. Using MongoDB we can store the comments as a list of
155155
*embedded documents* directly on a post document. An embedded document should
156-
be treated no differently that a regular document; it just doesn't have its own
156+
be treated no differently than a regular document; it just doesn't have its own
157157
collection in the database. Using MongoEngine, we can define the structure of
158158
embedded documents, along with utility methods, in exactly the same way we do
159159
with regular documents::

0 commit comments

Comments
 (0)