wlanslovenija / django-tastypie-mongoengine

MongoEngine support for django-tastypie.
Other
73 stars 59 forks source link

Getting the schema for a DynamicEmbeddedDocument via a top level endpoint #45

Closed lawrlee closed 11 years ago

lawrlee commented 11 years ago

With django-tastypie-mongoengine 0.4 and django-tastypie 0.9.14, I am trying to expose the schema for a resource created from a DynamicEmbeddedDocument. This used to work in 0.3+0.9.11 but now throws an AttributeError: 'ListQuerySet' object has no attribute '_document' error, presumably because the resource returns a ListQuerySet object that doesn't get converted to a MongoEngineListResource by the EmbeddedListField.

For example, if I have the resources:

class EmbeddedFooResource(MongoEngineResource):
    ...
    class Meta:
        object_class = Foo #this is a DynamicEmbeddedDocument
        resource_name = 'foo'

class BarResource(MongoEngineResource):
    foo = EmbeddedListField('EmbeddedFooResource')
    ...
    class Meta:
        queryset = Bar.objects.all()
        resource_name = 'bar'

How would I get the schema for EmbeddedFooResource? api/v1/foo/schema/ isn't working for me and api/v1/bar/<_id>/1/foo/schema/ isn't possible. Thanks!

mitar commented 11 years ago

Can you please create a test which was working on previous version and is failing now?

lawrlee commented 11 years ago

additional test functions in 45003777feccc4112baf4b92588466b6447cdd7a

mitar commented 11 years ago

FYI, I will not have for some time time to check this. I am really busy for few weeks. Feel free to remind me by commenting here.

mitar commented 11 years ago

OK. I don't understand why is schema provided in parent document's schema not enough? Why do you need to access schemas for subdocuments directly?