MongoEngine/mongoengine — pull request #417 by PaulUithol (2013-07-25 13:02:45+00:00)
Title: BaseDocument._delta doesn't properly end it's path at Documents when using `dbref=False`

When using `dbref=False`, `BaseDocument._delta` sometimes doesn't stop at referenced documents, but tries to assign ObjectIds to other field types.

This leads to wrong update statements, followed by an OperationError:

```
update mongoenginetest.organization query: { _id: ObjectId('51f1207eea89fc0da8373ac5') }
update: { $set: { employees.0.name: ObjectId('51f1207eea89fc0da8373ac4') } } idhack:1 keyUpdates:0
exception: LEFT_SUBFIELD only supports Object: employees.0 not: 7 code:10145 locks(micros) w:115 0ms

OperationError: Could not save document (LEFT_SUBFIELD only supports Object: employees.0 not: 7)
```

See the accompanying test case. I've also managed to fix this problem for us, but I'm not completely sure this is the correct fix.