Skip to content

The id field of a MongoEngine Document is not serialized #5

Closed
safehammad opened this Issue Dec 31, 2010 · 0 comments

2 participants

@safehammad

The simpleapi.server.serializer.MongoDocumentSerializer currently doesn't serialize the id.

There is a question as to whether serializing to string or to pymongo.objectid.ObjectId makes sense. There are good arguments either way, however I think the expectation is that MongoEngine documents are serialized to Python built-in types such as string. Also:

  • Serializing the id to string retains compatibility with how simpleapi encodes to JSON/XML etc.
  • MongoEngine will happily accept a string id when querying or saving a Document.
  • An ObjectId object can easily be created in the unlikely event that it is required.

The following change implements serializing id to string:
safehammad/simpleapi@2a415e6

@flosch flosch was assigned Jul 5, 2011
@flosch flosch closed this Mar 29, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.