Skip to content

Commit

Permalink
Merge pull request #896 from MongoEngine/topic/remove-mutable-arguments
Browse files Browse the repository at this point in the history
Use None instead of mutable arguments
  • Loading branch information
thedrow committed Mar 1, 2015
2 parents fae39e4 + 4bd72eb commit 4f1d867
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions mongoengine/base/document.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,10 +297,13 @@ def get_text_score(self):

return self._data['_text_score']

def to_mongo(self, use_db_field=True, fields=[]):
def to_mongo(self, use_db_field=True, fields=None):
"""
Return as SON data ready for use with MongoDB.
"""
if not fields:
fields = []

data = SON()
data["_id"] = None
data['_cls'] = self._class_name
Expand Down Expand Up @@ -652,9 +655,11 @@ def _get_collection_name(cls):
return cls._meta.get('collection', None)

@classmethod
def _from_son(cls, son, _auto_dereference=True, only_fields=[], created=False):
def _from_son(cls, son, _auto_dereference=True, only_fields=None, created=False):
"""Create an instance of a Document (subclass) from a PyMongo SON.
"""
if not only_fields:
only_fields = []

# get the class name from the document, falling back to the given
# class if unavailable
Expand Down

0 comments on commit 4f1d867

Please sign in to comment.