Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ab4d4e6230 | ||
|
|
7cd38c56c6 | ||
|
|
864053615b | ||
|
|
db2366f112 | ||
|
|
0ea4abda81 |
@@ -2,6 +2,10 @@
|
|||||||
Changelog
|
Changelog
|
||||||
=========
|
=========
|
||||||
|
|
||||||
|
Changes in 0.7.5
|
||||||
|
================
|
||||||
|
- ReferenceFields with dbref=False use ObjectId instead of strings (MongoEngine/mongoengine#134)
|
||||||
|
See ticket for upgrade notes (https://github.com/MongoEngine/mongoengine/issues/134)
|
||||||
|
|
||||||
Changes in 0.7.4
|
Changes in 0.7.4
|
||||||
================
|
================
|
||||||
|
|||||||
@@ -344,6 +344,10 @@ Its value can take any of the following constants:
|
|||||||
their :file:`models.py` in the :const:`INSTALLED_APPS` tuple.
|
their :file:`models.py` in the :const:`INSTALLED_APPS` tuple.
|
||||||
|
|
||||||
|
|
||||||
|
.. warning::
|
||||||
|
Signals are not triggered when doing cascading updates / deletes - if this
|
||||||
|
is required you must manually handle the update / delete.
|
||||||
|
|
||||||
Generic reference fields
|
Generic reference fields
|
||||||
''''''''''''''''''''''''
|
''''''''''''''''''''''''
|
||||||
A second kind of reference field also exists,
|
A second kind of reference field also exists,
|
||||||
|
|||||||
@@ -50,4 +50,11 @@ Example usage::
|
|||||||
signals.post_save.connect(Author.post_save, sender=Author)
|
signals.post_save.connect(Author.post_save, sender=Author)
|
||||||
|
|
||||||
|
|
||||||
|
ReferenceFields and signals
|
||||||
|
---------------------------
|
||||||
|
|
||||||
|
Currently `reverse_delete_rules` do not trigger signals on the other part of
|
||||||
|
the relationship. If this is required you must manually handled the
|
||||||
|
reverse deletion.
|
||||||
|
|
||||||
.. _blinker: http://pypi.python.org/pypi/blinker
|
.. _blinker: http://pypi.python.org/pypi/blinker
|
||||||
|
|||||||
@@ -34,10 +34,10 @@ To get help with using MongoEngine, use the `MongoEngine Users mailing list
|
|||||||
Contributing
|
Contributing
|
||||||
------------
|
------------
|
||||||
|
|
||||||
The source is available on `GitHub <http://github.com/hmarr/mongoengine>`_ and
|
The source is available on `GitHub <http://github.com/MongoEngine/mongoengine>`_ and
|
||||||
contributions are always encouraged. Contributions can be as simple as
|
contributions are always encouraged. Contributions can be as simple as
|
||||||
minor tweaks to this documentation. To contribute, fork the project on
|
minor tweaks to this documentation. To contribute, fork the project on
|
||||||
`GitHub <http://github.com/hmarr/mongoengine>`_ and send a
|
`GitHub <http://github.com/MongoEngine/mongoengine>`_ and send a
|
||||||
pull request.
|
pull request.
|
||||||
|
|
||||||
Also, you can join the developers' `mailing list
|
Also, you can join the developers' `mailing list
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ from signals import *
|
|||||||
__all__ = (document.__all__ + fields.__all__ + connection.__all__ +
|
__all__ = (document.__all__ + fields.__all__ + connection.__all__ +
|
||||||
queryset.__all__ + signals.__all__)
|
queryset.__all__ + signals.__all__)
|
||||||
|
|
||||||
VERSION = (0, 7, 4)
|
VERSION = (0, 7, 5)
|
||||||
|
|
||||||
|
|
||||||
def get_version():
|
def get_version():
|
||||||
|
|||||||
@@ -709,6 +709,10 @@ class ReferenceField(BaseField):
|
|||||||
|
|
||||||
Bar.register_delete_rule(Foo, 'bar', NULLIFY)
|
Bar.register_delete_rule(Foo, 'bar', NULLIFY)
|
||||||
|
|
||||||
|
.. note ::
|
||||||
|
`reverse_delete_rules` do not trigger pre / post delete signals to be
|
||||||
|
triggered.
|
||||||
|
|
||||||
.. versionchanged:: 0.5 added `reverse_delete_rule`
|
.. versionchanged:: 0.5 added `reverse_delete_rule`
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@@ -788,7 +792,7 @@ class ReferenceField(BaseField):
|
|||||||
collection = self.document_type._get_collection_name()
|
collection = self.document_type._get_collection_name()
|
||||||
return DBRef(collection, id_)
|
return DBRef(collection, id_)
|
||||||
|
|
||||||
return "%s" % id_
|
return id_
|
||||||
|
|
||||||
def to_python(self, value):
|
def to_python(self, value):
|
||||||
"""Convert a MongoDB-compatible type to a Python type.
|
"""Convert a MongoDB-compatible type to a Python type.
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
%define srcname mongoengine
|
%define srcname mongoengine
|
||||||
|
|
||||||
Name: python-%{srcname}
|
Name: python-%{srcname}
|
||||||
Version: 0.7.4
|
Version: 0.7.5
|
||||||
Release: 1%{?dist}
|
Release: 1%{?dist}
|
||||||
Summary: A Python Document-Object Mapper for working with MongoDB
|
Summary: A Python Document-Object Mapper for working with MongoDB
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
from __future__ import with_statement
|
from __future__ import with_statement
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
from bson import DBRef
|
from bson import DBRef, ObjectId
|
||||||
|
|
||||||
from mongoengine import *
|
from mongoengine import *
|
||||||
from mongoengine.connection import get_db
|
from mongoengine.connection import get_db
|
||||||
@@ -187,8 +187,8 @@ class FieldTest(unittest.TestCase):
|
|||||||
self.assertEqual(group.members, [user])
|
self.assertEqual(group.members, [user])
|
||||||
|
|
||||||
raw_data = Group._get_collection().find_one()
|
raw_data = Group._get_collection().find_one()
|
||||||
self.assertTrue(isinstance(raw_data['author'], basestring))
|
self.assertTrue(isinstance(raw_data['author'], ObjectId))
|
||||||
self.assertTrue(isinstance(raw_data['members'][0], basestring))
|
self.assertTrue(isinstance(raw_data['members'][0], ObjectId))
|
||||||
|
|
||||||
def test_recursive_reference(self):
|
def test_recursive_reference(self):
|
||||||
"""Ensure that ReferenceFields can reference their own documents.
|
"""Ensure that ReferenceFields can reference their own documents.
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import tempfile
|
|||||||
|
|
||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
|
|
||||||
from bson import Binary, DBRef
|
from bson import Binary, DBRef, ObjectId
|
||||||
import gridfs
|
import gridfs
|
||||||
|
|
||||||
from nose.plugins.skip import SkipTest
|
from nose.plugins.skip import SkipTest
|
||||||
@@ -1104,7 +1104,7 @@ class FieldTest(unittest.TestCase):
|
|||||||
p = Person.objects.get(name="Ross")
|
p = Person.objects.get(name="Ross")
|
||||||
self.assertEqual(p.parent, p1)
|
self.assertEqual(p.parent, p1)
|
||||||
|
|
||||||
def test_str_reference_fields(self):
|
def test_objectid_reference_fields(self):
|
||||||
|
|
||||||
class Person(Document):
|
class Person(Document):
|
||||||
name = StringField()
|
name = StringField()
|
||||||
@@ -1117,7 +1117,7 @@ class FieldTest(unittest.TestCase):
|
|||||||
|
|
||||||
col = Person._get_collection()
|
col = Person._get_collection()
|
||||||
data = col.find_one({'name': 'Ross'})
|
data = col.find_one({'name': 'Ross'})
|
||||||
self.assertEqual(data['parent'], "%s" % p1.pk)
|
self.assertEqual(data['parent'], p1.pk)
|
||||||
|
|
||||||
p = Person.objects.get(name="Ross")
|
p = Person.objects.get(name="Ross")
|
||||||
self.assertEqual(p.parent, p1)
|
self.assertEqual(p.parent, p1)
|
||||||
|
|||||||
Reference in New Issue
Block a user