Allow searching multiple levels deep in DictFields
Allow DictField entries containing strings to use matching operators
Thanks again to @theojulien for the initial code #108
Managers can now be directly declared in a Document eg::
```python
class CustomQuerySetManager(QuerySetManager):
@staticmethod
def get_queryset(doc_cls, queryset):
return queryset(is_published=True)
class Post(Document):
is_published = BooleanField(default=False)
published = CustomQuerySetManager()
```
Refactored the name of the `_manager_func` to `get_queryset` to mark it as
part the public API. If declaring a Manager with a get_queryset method, it
should be a staticmethod, that accepts the document_class and the queryset.
Note - you can still use decorators in fact in the example below,
we effectively do the same thing as the first example and is much less verbose.
```python
class Post(Document):
is_published = BooleanField(default=False)
@queryset_manager
def published(doc_cls, queryset):
return queryset(is_published=True)
```
Thanks to @theojulienne for the initial impetus and code sample #108
This ensures that indexes are created with the unique flag, if a user
declares the index, that would automatically be declared by the `unique_indexes`
logic.
Thanks to btubbs for the test case.
Fixes#129
Comments in unit tests should say "degrees," not "miles":
MongoDB docs are confusing, only the spherical queries $nearSphere and $centerSphere use radians. The $near and $center queries, which are the ones that are used in these mongoengine tests, use the same units as the coordinates. For distances on the earth, this means they use degrees. (This is also why the 2d indexes can be used for other 2d data, not just points on the earth.)
Here's a mongo shell session demonstrating that $near and $center use degrees, and that $nearSphere and $centerSphere are the ones that use radians: https://gist.github.com/964126
So, these mongoengine tests are using $near and $center, which use degrees, not miles, kilometers, or radians.
Thanks glyphobet for the clarification and taking time to explain it!