fixed unicode-bug; replaced str(err) with err.message
This commit is contained in:
parent
a2d8b0ffbe
commit
69e9b5d55e
@ -78,9 +78,9 @@ class Document(BaseDocument):
|
|||||||
object_id = collection.save(doc, safe=safe)
|
object_id = collection.save(doc, safe=safe)
|
||||||
except pymongo.errors.OperationFailure, err:
|
except pymongo.errors.OperationFailure, err:
|
||||||
message = 'Could not save document (%s)'
|
message = 'Could not save document (%s)'
|
||||||
if 'duplicate key' in str(err):
|
if u'duplicate key' in err.message:
|
||||||
message = 'Tried to save duplicate unique keys (%s)'
|
message = u'Tried to save duplicate unique keys (%s)'
|
||||||
raise OperationError(message % str(err))
|
raise OperationError(message % err.message)
|
||||||
id_field = self._meta['id_field']
|
id_field = self._meta['id_field']
|
||||||
self[id_field] = self._fields[id_field].to_python(object_id)
|
self[id_field] = self._fields[id_field].to_python(object_id)
|
||||||
|
|
||||||
@ -95,7 +95,7 @@ class Document(BaseDocument):
|
|||||||
try:
|
try:
|
||||||
self.__class__.objects(**{id_field: object_id}).delete(safe=safe)
|
self.__class__.objects(**{id_field: object_id}).delete(safe=safe)
|
||||||
except pymongo.errors.OperationFailure, err:
|
except pymongo.errors.OperationFailure, err:
|
||||||
raise OperationError('Could not delete document (%s)' % str(err))
|
raise OperationError(u'Could not delete document (%s)' % err.message)
|
||||||
|
|
||||||
def reload(self):
|
def reload(self):
|
||||||
"""Reloads all attributes from the database.
|
"""Reloads all attributes from the database.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user