Giter Site home page Giter Site logo

mongoengine's Introduction

MongoEngine

Info:MongoEngine is an ORM-like layer on top of PyMongo.
Repository:https://github.com/MongoEngine/mongoengine
Author: Harry Marr (http://github.com/hmarr)
Maintainer:Ross Lawley (http://github.com/rozza)
https://secure.travis-ci.org/MongoEngine/mongoengine.png?branch=master

About

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 setup.py install.

Dependencies

  • pymongo 2.1.1+
  • sphinx (optional - for documentation generation)

Examples

Some simple examples of what MongoEngine code looks like:

class BlogPost(Document):
    title = StringField(required=True, max_length=200)
    posted = DateTimeField(default=datetime.datetime.now)
    tags = ListField(StringField(max_length=50))

class TextPost(BlogPost):
    content = StringField(required=True)

class LinkPost(BlogPost):
    url = StringField(required=True)

# Create a text-based post
>>> post1 = TextPost(title='Using MongoEngine', content='See the tutorial')
>>> post1.tags = ['mongodb', 'mongoengine']
>>> post1.save()

# Create a link-based post
>>> post2 = LinkPost(title='MongoEngine Docs', url='hmarr.com/mongoengine')
>>> post2.tags = ['mongoengine', 'documentation']
>>> post2.save()

# Iterate over all posts using the BlogPost superclass
>>> for post in BlogPost.objects:
...     print '===', post.title, '==='
...     if isinstance(post, TextPost):
...         print post.content
...     elif isinstance(post, LinkPost):
...         print 'Link:', post.url
...     print
...

>>> len(BlogPost.objects)
2
>>> len(HtmlPost.objects)
1
>>> len(LinkPost.objects)
1

# Find tagged posts
>>> len(BlogPost.objects(tags='mongoengine'))
2
>>> len(BlogPost.objects(tags='mongodb'))
1

Tests

To run the test suite, ensure you are running a local instance of MongoDB on the standard port, and run: python setup.py test.

Community

Contributing

We welcome contributions! see the`Contribution guidelines <https://github.com/MongoEngine/mongoengine/blob/master/CONTRIBUTING.rst>`_

mongoengine's People

Contributors

alefnula avatar aleszoulek avatar anemitz avatar aparrish avatar atroche avatar benmur avatar colinhowe avatar cyberdelia avatar danielhasselrot avatar dcrosta avatar dimonb avatar flosch avatar glyphobet avatar hasenbanck avatar hmarr avatar iapain avatar kajic avatar lig avatar mattdennewitz avatar meirkriheli avatar mirceapasoi avatar n1k0 avatar nvie avatar punteney avatar rozza avatar samuelclay avatar schallis avatar srackham avatar stephrdev avatar wpjunior avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mongoengine's Issues

Query arguments not converted to MongoDB types

When queries are filtered by calling Document.objects, the arguments are passed directly to PyMongo's Collection.find method. To allow custom types to be defined and to fix a few problems concerning ObjectIds, the fields that each query argument correspond to should be resolved, and the value should be passed through the field's to_mongo method.

Unable to have a primary key in a base document

I'm creating a tumblelog using mongoengine and Django but I'm having trouble defining a primary_key on the base document. I am getting a ValueError:

File "/home/eric/.virtualenvs/django-1.2/lib/python2.5/site-packages/mongoengine/base.py", line 261, in __new__
    raise ValueError('Cannot override primary key field')

I'm using mongoengine 0.3:

from mongoengine.django.auth import User
from mongoengine import *

class Post(Document): 
    slug = StringField(max_length=120, required=True, primary_key=True)
    title = StringField(max_length=120, required=True)
    is_live = BooleanField(required=True)
    pub_date = DateTimeField(required=True)
    author = ReferenceField(User, required=True)
    tags = ListField(StringField(max_length=30))


class HTMLPost(Post):
    content = StringField(required=True)

Use real field names when querying

At the moment, field names used in queries correspond the name under which the field is stored in the database. The name used should correspond to the class variable name set on the Document, which would then be used to retrieve the field and find the name that the database uses, e.g.

class Story(Document):
    # STORY_TITLE is what existing data uses
    title = StringField(name='STORY_TITLE')

# Bad, how things currently are:
story = Story.objects(STORY_TITLE='MongoDB Stuff')[0]

# Good, how things should be:
story = Story.objects(title='MongoDB Stuff')[0]

Add distinct method for querysets

Please wrap pymongo's distinct. Something like:

def distinct(self, foo):
    return self._cursor.distinct(foo)

but you need to transform foo into a pymongo query string.

Consider signal dispatcher integration

MongoDB offers no relationship management, so post_save and post_delete signals (at the very least) would help keep denormalized data clean. Django has an excellent fork/refactoring of PyDispatcher, and PyDispatcher itself may fit the bill.

Array Element By Position

Array Element by Position

Array elements also may be accessed by specific array position:

// i.e. comments[0].by == "Abe"

db.blogposts.find( { "comments.0.by" : "Abe" } )
(The above examples use the mongo shell's Javascript syntax. The same operations can be done in any language for which Mongo has a driver available.)

Would be nice to have this sort of syntax as well. I recently had the need to do something like the following:

db.program.update({"program": "test", "sites.slug": "site-1"}, {$set: {"sites.$.disabled": true}})

Add Django integration

  • If a connection has not been specified and a connection is needed, try importing the database settings from django.conf.settings.
  • Add a Django package to MongoEngine that contains implementations of the auth (done 07/01/10), sessions (done 11/01/10), etc frameworks, using MongoEngine. This will allow Django to be used more easily without the ORM.

DictField default value should not be mutable?

DictField default value (reference) can be incorrectly shared by other instances.
e.g.
class D(Document):
data = DictField(default = {})

d1 = D()
d1.data['foo'] = 'bar'
d2 = D()
print d2.data
=> {'bar':'foo'}

Embedded Documents & Editing

So I have a document called program. Inside there I have an embedded
document called sites. The sites document consists of 4 fields (tags,
slug, url, name).

So a program can have multiple sites and I want to be able to delete
one site from that program. The command to do this via the mongo
console is:

working command

db.program.update({"slug": "test-program"}, {$pull: {"sites": {"slug": "site-1"}}})

I tried to run the following:

Program.objects(slug="test-program").update(pull__sites__slug=slug)

Doing a print on the update method in mongo engine basically produced the following
db.projects.update({"slug": "test-program"}, {$pull: {"sites.slug": "site-1"}})

the model

`class PaySite(EmbeddedDocument):
"""Represents a paysite, for a program."""
name = StringField(required=True)
slug = StringField(required=True)
url = URLField(required=True, verify_exists=True)
tags = ListField(StringField(required=True))
date_created = DateTimeField(default=datetime.datetime.utcnow)

class Program(Document):
name = StringField(required=True)
url = URLField(required=True)
affiliate_id = StringField(required=True)
active = BooleanField(required=True, default=True)
slug = StringField(required=True)
deleted = BooleanField(default=False)
date_created = DateTimeField(default=datetime.datetime.utcnow)
sites = ListField(EmbeddedDocumentField(PaySite)) `

Being able to query the embedded document somehow, to provide the new paysite object to the program object, or a way to modify embedded documents directly would be nice.

override primary key?

Hi, I have the following schema, and it failed when loading, it that intentional?

raise ValueError('Cannot override primary key field')
ValueError: Cannot override primary key field

code:
class price1(Document):
pid = StringField(maxlength=20)

class price2(price1):
pass

Document.objects(tags="python") not equiv to Document.objects(Q(tags="python"))

I have a document with a ListField of StringFields called "tags" when I query it with tags="python" it returns documents whose tags contains "python". This is like the expression, "python" in ["python", "django", "mongo"]

I assume that Q(tags="python") would behave in the same way, however, it acts as the expression ["python"] == tags, which fails for any documents that's not tagged ["python"]

Chaining initial objects filter and subsequent QuerySet managers breaks query

Chaining QuerySetManagers overwrites the curent query spec with its own, instead of just merging.

# get latest blog posts
latest_posts = BlogPost.published()

The latest_posts query is now, say, { _types: "BlogPost", is_published: True }.

# filter to just posts published in the last 7 days
start_date = self.get_argument("start_date", None)
if start_date:
    latest_reviews = BlogPost.objects(published_date__gte=start_date)

The latest_posts query is now { _types: "BlogPost", published_date: {$gte: datetime(...) }.

Comparing objects should be more natural.

If we compare something like request.user == myuser it always returns False, but if we do request.user.id == myuser.id then it returns properly. IMO comparing objects should be more natural so we basically needs eq() which does this.

QuerySets evaporate on successive iteration

mongoengine.__version__ == '0.2.2'

You can only iterate over a QuerySet once, and you'd better well have gotten what you needed! Expected behavior would be for the QuerySet to cache its results and remain stable over the lifetime of the object.

A sample session:

In [25]: docs = Foo.objects()

In [26]: list(docs)

Out[26]: [<Foo: Foo object>]

In [27]: list(docs)

Out[27]: []

In [28]: list(docs)

Out[28]: []

In [29]: print docs
-------> print(docs)
---------------------------------------------------------------------------
InvalidOperation                          Traceback (most recent call last)

/<ipython console> in <module>()

/lib/python2.6/site-packages/mongoengine/queryset.pyc in __repr__(self)
    598
    599     def __repr__(self):
--> 600         data = list(self[:REPR_OUTPUT_SIZE + 1])
    601         if len(data) > REPR_OUTPUT_SIZE:
    602             data[-1] = "...(remaining elements truncated)..."

/lib/python2.6/site-packages/mongoengine/queryset.pyc in __getitem__(self, key)
    351         if isinstance(key, slice):
    352             try:
--> 353                 self._cursor_obj = self._cursor[key]
    354             except IndexError, err:
    355                 # PyMongo raises an error if key.start == key.stop, catch it,


/lib/python2.6/site-packages/pymongo/cursor.pyc in __getitem__(self, index)
    220           - `index`: An integer or slice index to be applied to this cursor
    221         """
--> 222         self.__check_okay_to_chain()
    223         if isinstance(index, slice):
    224             if index.step is not None:

/lib/python2.6/site-packages/pymongo/cursor.pyc in __check_okay_to_chain(self)
    155         """
    156         if self.__retrieved or self.__id is not None:
--> 157             raise InvalidOperation("cannot set options after executing query")
    158
    159     def limit(self, limit):

InvalidOperation: cannot set options after executing query

Support storing files in GridFS

To support large blobs that would not be suitable for a BinaryField, a FileDocument or EmbeddedFileDocument could be needed, that would be backed by GridFS.

If this is interesting for MongoEngine, I might take a shot at implementing it, since I need it for a project of mine.

Is this the expected behavior for queries on superclasses of an inherited document?

It seems that queries on superclasses return None objects unless you have imported the subclass. Is this the expected behavior? It strikes me as odd.

It may or may not be relevant to know that this is within the context of Django apps.

documents.py:

>>> from mongoengine import *
>>> class Content(Document):
>>>     created_at = DateTimeField()
>>> class Tweet(Content):
>>>     text = StringField()

create_tweets.py:

>>> from datetime import datetime
>>> from documents import Tweet
>>> for i in range(1, 150):
...     t = Tweet(text='This is a tweet!', created_at=datetime.utcnow())
...     t.save()

views.py:

>>> from documents import Content
>>> Content.objects.first() # Returns None
>>> Content.objects()
[None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, None, '...(remaining elements truncated)...']
>>> from documents import Tweet
>>> Content.objects()
[<Tweet: Tweet object>, <Tweet: Tweet object>, <Tweet: Tweet object>, <Tweet: Tweet object>, <Tweet: Tweet object>, <Tweet: Tweet object>, <Tweet: Tweet object>, <Tweet: Tweet object>, <Tweet: Tweet object>, <Tweet: Tweet object>, <Tweet: Tweet object>, <Tweet: Tweet object>, <Tweet: Tweet object>, <Tweet: Tweet object>, <Tweet: Tweet object>, <Tweet: Tweet object>, <Tweet: Tweet object>, <Tweet: Tweet object>, <Tweet: Tweet object>, <Tweet: Tweet object>, '...(remaining elements truncated)...']

Queryset returns None for documents which inherit a class from another file

Scenario:

  • Create a document class called Person which inherits from mongoengine.Document in people/person.py.
  • Create a document class called Employee which inherits from Person in people/employee.py.
  • Create and save instances of both classes.
  • Call Person.objects(). You will get back a queryset as expected but there will be a None value in place of each expected Employee instance.

I'll try to write up a test case to catch this soon.

"_types" should be included in applicable indexes

As _types is transparently inserted into a query spec before querying MongoDB, it should also be transparently inserted into each of a model's indexes. An index without _types may be overlooked by the MongoDB planner.

A simple check for allowed inheritance here would probably be enough, right?

Denormalized fields

ReferenceFields and EmbeddedDocumentFields should allow for a list of denormalized sub-fields. By this, I mean it should be possible to store additional fields alongside the ID.

For example, if I have an author ReferenceField that points to a User document, I may want to be able to denormalize the user's name into the reference field so that it can be returned more quickly without needing to dereference. Naturally, trying to retrieve any fields that aren't denormalized would result in a full dereference of the referenced document.

One of the benefits of doing this formally through a field is that when updates are made, they can be propagated to both the denormalized sub-fields and the referenced document.

bulk save?

Hi, can I create a list of Documents and do a bulk save? or I have to save one by one.

Add dynamic documents

At the moment, documents must have a defined schema - for most cases this is appropriate, but a 'dynamic' schemaless document type could be useful where you can add fields not defined in a schema.

__init__() keywords must be strings

Since the last update, it cannot build the MongoSession again because the keys() are unicode strings.

diff --git a/mongoengine/base.py b/mongoengine/base.py
index 83faa92..2dde93b 100644
--- a/mongoengine/base.py
+++ b/mongoengine/base.py
@@ -421,7 +421,7 @@ class BaseDocument(object):
         # class if unavailable
         class_name = son.get(u'_cls', cls._class_name)

-        data = dict((unicode(key), value) for key, value in son.items())
+        data = dict((str(key), value) for key, value in son.items())

         if '_types' in data:
             del data['_types']

http://github.com/hmarr/mongoengine/commit/48facec5246dcd9c0b3e543eab2de55e25ce4132

The tests are failing btw.

EmbeddedDocument validation errors being obfuscated

A validation error raised by an EmbeddedDocument inside of a ListField is muddled when the master Document is saved. The developer is only warned that all items in the list should be of the specified type, and is not given any hint that a validation error is the root cause.

Document.save() should only update dirty fields

Using pymongo.collection.Collection.save() replaces the document in the DB with the one being saved if the ids match. This could be an issue if two clients retrieve an object, then both try to save it (see issue 14 for more info). To reduce the effect of this, Document.save() could call Collection.update() with only the dirty parameters, using the object's id as the update query.

An example of this being useful is a blogging application, where each page object has a page_views field which is always updated using $inc. Without this adjustment, when saving changes to a post, any hits to the page between when the server retrieved a post, and when it called save() would be lost as the retrieved value would be restored.

Add multiple database support

At the moment, only one database connection may be used. MongoDB supports master-slave replication and replica pairs (plus auto-sharding, which is in alpha, and limited master-master replication) - MongoEngine should provide an interface to working with these setups.

Multiple inheritance causes a MRO error

Following piece of code causes the following MRO error:

class A(Document): pass
class B(A): pass
class C(B): pass

The relevant python traceback:

...
  File "/Users/flosch/devlibs/3rdparty/mongoengine/base.py", line 235, in __new__
    new_class = super_new(cls, name, bases, attrs)
  File "/Users/flosch/devlibs/3rdparty/mongoengine/base.py", line 177, in __new__
    or (DoesNotExist,), module))
  File "/Users/flosch/devlibs/3rdparty/mongoengine/base.py", line 444, in subclass_exception
    return type(name, parents, {'__module__': module})
TypeError: Error when calling the metaclass bases
    Cannot create a consistent method resolution
order (MRO) for bases DoesNotExist, DoesNotExist

(using: mongoengine master, pymongo 1.6, python 2.6.5, Mac OS X Snow Leopard)

Enforced presence of "_types" in index prevents indexing a ListField

Compound indexes cannot contain two lists, as it causes unreasonable index growth (n^2). Transparently including _types in an index prevents including a ListField -- MongoDB "cannot index parallel arrays".

Buildindex baseballapp.game idxNo:3 { name: "_types_1_player_ids_1", ns: "baseballapp.game", key: { _types: 1, player_ids: 1 }, unique: false }
User Exception cannot index parallel arrays

Edit: this can possibly be solved by not adding _types to indexes that contain ListFields, and then using Cursor.hint() to tell the query optimizer to use the index every though _types is in the query.

Add 'update' method to QuerySet to enable atomic updates

Just in the same way that QuerySet has a delete method to delete all items matching the current query, there should be an update method that takes arguments that are in a similar style to query arguments, specifying the field and the operation as the key, and the value as the value e.g.

Story.objects(tags='mongo').update(push__tags='database')
Story.objects(slug=story_slug).update(inc__view_count=1)

One issue is that the pymongo.Collection.update method only received the multi parameter, which allows multiple documents to be updated at once, in version 1.1.1. Two options are to either drop support for PyMongo 1.1.1 or to reimplement update with multi as a Javascript function and use exec.

__ilike filter


Class.objects(name__ilike='carol%')

to filter 'carol', 'Caroline', ...
is it possible?

Vladimir

Pseudo-ReferenceField

Per IRC conversation with one of the 10gen-ers, it sounds like storing an ObjectId is more efficient than storing a DBRef, and a DBRef is little more than a glorified findOne. If the document that this field references is a constant, there really isn't a reason to use a DBRef -- it would be safe to accept a document subclass to store with the field instance, and perform a findOne on __get__.

Though, modules like the json module don't call __get__ to retrieve a value. I'm not sure what we'd need to do there.

Here's a quick example:

class LazyReferenceField(fields.BaseField):
    """A reference to an ObjectId and model that will be 
    magically "dereferenced" on access (lazily).

    This field simulates a ``DBRef``, but only stores an ``ObjectId``.
    Data is fetched from the given ``document_type`` as necessary
    by ``__get__``.

    :param document_type: a ``Document`` subclass
    """

    def __init__(self, document_type, **kwargs):
        if not issubclass(document_type, Document):
            raise ValidationError('Argument to LazyReferenceField constructor '
                                  'must be a top level document class')
        self.document_type = document_type
        super(LazyReferenceField, self).__init__(**kwargs)

    def __get__(self, instance, owner):
        """Custom descriptor to allow lazy pseudo-dereferencing.
        """
        if instance is None:
            return self

        # Get value from document instance if available
        doc_id = instance._data.get(self.name)

        if isinstance(doc_id, pymongo.objectid.ObjectId):
            value = self.document_type.objects(id=doc_id).first()
            if value is not None:
                instance._data[self.name] = value
            return value

        return doc_id

Test fail: QuerySetTest.test_update_pull

# python setup.py test -q || git log --oneline | head -n 1
0.3
running test
running egg_info
writing requirements to mongoengine.egg-info/requires.txt
writing mongoengine.egg-info/PKG-INFO
writing top-level names to mongoengine.egg-info/top_level.txt
writing dependency_links to mongoengine.egg-info/dependency_links.txt
reading manifest file 'mongoengine.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
no previously-included directories found matching 'docs/_build'
writing manifest file 'mongoengine.egg-info/SOURCES.txt'
running build_ext
........................................................E..........................
======================================================================
ERROR: Ensure that the 'pull' update operation works correctly.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/mnt/sda5/Projekty/virtualenvs/mongoengine/mongoengine/tests/queryset.py", line 646, in test_update_pull
    BlogPost.objects(slug="test").update(pull__comments__content="test2")
  File "/mnt/sda5/Projekty/virtualenvs/mongoengine/mongoengine/mongoengine/queryset.py", line 718, in update
    raise OperationError(u'Update failed (%s)' % unicode(err))
OperationError: Update failed (Modifier spec implies existence of an encapsulating object with a name that already represents a non-object, or is referenced in another $set clause)

----------------------------------------------------------------------
Ran 83 tests in 0.462s

FAILED (errors=1)
[1]    9833 exit 1     python setup.py test -q
eecc618 fixes issue #41 since unicode kwargs is an feature of python 2.6.5 and above.

Add 'fail if not current' behaviour to Document.save

Dirty fields on document objects should be tracked. The QuerySet.update() method may be used to update the dirty fields, using the old values of the dirty fields as the query. This will mean that the update fails if the fields have been changed in the database since the object was retrieved.

AttributeError triggering is weird

Hi,

Let's admit I have this model:

class Person(Document):
    first_name = StringField(required=True)
    last_name = StringField()

>>> p = Person(first_name='Bastien')
>>> p.save()
>>> p.last_name

This code will produce an

AttributeError: last_name

As it has been defined, shouldn't p.name be returning None, even if it has not been specified, instead of an Exception?

Because if an attribute is not required, the following code might be something like:

if p.last_name:
    print 'Hi %s %s' % (p.first_name, p.last_name)
else:
    print 'Hi %s' % (p.first_name)

If I want to do that with the current code, an Exception is raised. What do you think?

Add indexing support

Multi-field indexing support should be added probably through the meta dict that may be used when Documents are being defined, e.g.

class Story(Document):
    title = StringField()
    rating = IntField()
    meta = {'indexes': ['-rating', 'title']}

These indexes could be 'ensured' lazily by determining which fields they affect, then only ensuring them before a query that uses one of the fields.

Should serialization dereference DBRefs?

python's json module won't call __get__ when serializing a Document, so raw DBRef objects are returned. should DBRefs somehow be dereferenced when serializing a Document?

InvalidDocument raised when attempting to save a decimal.Decimal instance in a DecimalField

In [1]: import decimal, mongoengine

In [2]: class MyDoc(mongoengine.Document):
...: f1 = mongoengine.DecimalField()
...:

In [3]: doc = MyDoc(f1=decimal.Decimal("1.50"))

In [4]: doc.validate()

In [5]: doc.save()
/Users/don/Development/python/virtualenvs/bloono/lib/python2.6/site-packages/pymongo/collection.py:246: RuntimeWarning: couldn't encode - reloading python modules and trying again. if you see this without getting an InvalidDocument exception please see http://api.mongodb.org/python/current/faq.html#does-pymongo-work-with-mod-wsgi

message.insert(self.__full_name, docs, check_keys, safe), safe)

InvalidDocument Traceback (most recent call last)

/Users/don/Development/python/bloono/ in ()

/Users/don/Development/python/virtualenvs/bloono/lib/python2.6/site-packages/mongoengine/document.pyc in save(self, safe, force_insert)
76 object_id = collection.insert(doc, safe=safe)
77 else:
---> 78 object_id = collection.save(doc, safe=safe)
79 except pymongo.errors.OperationFailure, err:
80 message = 'Could not save document (%s)'

/Users/don/Development/python/virtualenvs/bloono/lib/python2.6/site-packages/pymongo/collection.pyc in save(self, to_save, manipulate, safe)
204
205 if "_id" not in to_save:
--> 206 return self.insert(to_save, manipulate, safe)
207 else:
208 self.update({"_id": to_save["_id"]}, to_save, True,

/Users/don/Development/python/virtualenvs/bloono/lib/python2.6/site-packages/pymongo/collection.pyc in insert(self, doc_or_docs, manipulate, safe, check_keys)
244
245 self.__database.connection._send_message(
--> 246 message.insert(self.__full_name, docs, check_keys, safe), safe)
247
248 ids = [doc.get("_id", None) for doc in docs]

InvalidDocument: Cannot encode object: Decimal('1.50')

In [6]: mongoengine.VERSION
Out[6]: (0, 3, 0)

In [7]: mongoengine.connection._connection.server_info()
Out[7]:
{u'bits': 64,
u'gitVersion': u'514f8bbab657c1dc110d45eea6ea33de296dbb26',
u'ok': 1.0,
u'sysInfo': u'Darwin erh2.10gen.cc 9.6.0 Darwin Kernel Version 9.6.0: Mon Nov 24 17:37:00 PST 2008; root:xnu-1228.9.59~1/RELEASE_I386 i386 BOOST_LIB_VERSION=1_37',
u'version': u'1.4.0'}

Exception in latest version

I get the following exception when deriving from Class that is derived from Document.

class RangedParameters(Measurements):
 File "/home/smit023/bzr/ipcim/song_ui/src/mongoengine/mongoengine/base.py", line 235, in __new__
new_class = super_new(cls, name, bases, attrs)
File "/home/smit023/bzr/ipcim/song_ui/src/mongoengine/mongoengine/base.py", line 177, in __new__
or (DoesNotExist,), module))
File "/home/smit023/bzr/ipcim/song_ui/src/mongoengine/mongoengine/base.py", line 444, in subclass_exception
return type(name, parents, {'__module__': module})
TypeError: Error when calling the metaclass bases
Cannot create a consistent method resolution order (MRO) for bases DoesNotExist, DoesNotExist

reverting to 00c8d7e fixes this issue

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.