MongoEngine/mongoengine — pull request #88 by akolechkin (2012-08-23 05:04:10+00:00)
Title: fix for UnboundLocalError in composite index with pk field

Hello,

I've made a regression test, you can see the diff for my changeset.
In other words:
```python
class Comment(EmbeddedDocument):
comment_id = IntField(required=True)

class BlogPost(Document):
comments = EmbeddedDocumentField(Comment)
meta = {'indexes': [{'fields': ['pk', 'comments.comment_id'],
'unique': True}]}
```

atm, this code will raise an exception:

```python
File "...project/models.py", line 26, in
class BlogPost(Document):
File ".../lib/python2.7/site-packages/mongoengine/base.py", line 716, in __new__
for spec in indicies] + base_indexes
File ".../lib/python2.7/site-packages/mongoengine/queryset.py", line 524, in _build_index_spec
if use_types and not all(f._index_with_types for f in fields):
```

see my bug fix for this exceptions.

Also, i've made some code improvements to make it a bit clear.