Closed m-vdb closed 11 years ago
Please create a pull request with failing test.
yep, trying to find where it bugs with my best friend pdb, and if i succeed you'll have a pull request with a fix :D
No no. You can also just make a pull request with a test which fails. And then I can also look.
ok as you want, but since I need this to be fixed asap, I'll investigate too
OK. So yes. You can create pull request with test. And then later on augment it with another commit with a fix. :-)
done :)
btw, is there any support for DateTimeField ? (I can't see any document with a mongoengine.DateTimeField in documents.py)
Yes, that one should be automatically available in resource.
okay, I have something that fails, so I'll do another pull request.
For the first problem, I identified the cause :
in File tastypie_mongoengine.resources.py, line 475:
def obj_get(self, request=None, **kwargs):
# MongoEngine exceptions are separate from Django exceptions, we combine them here
try:
return super(MongoEngineResource, self).obj_get(request, **kwargs)
In the returned function, tastypie does a query on the documents, and uses filter(**kwargs)
on the queryset. And kwargs
contains resource_uri
, so that fails. A quick fix for me would be inserting kwargs.pop('resource_uri', None)
, but maybe this can be inserted upstream.
You are doing invalid REST request.
hum why is that ? could you explain a little more ?
See the test I fixed.
ok thanks for your help. Btw, my request was not that invalid. If I remove 'put'
from the ExporterResource.allowed_method
, the problem does not occur and everything goes well. Anyway, thanks for your help and your plugin :+1:
That's semi-normal. :-)
To be user friendly, you can specify referenced document by any unique combination of fields (like id). But on the other hand you can also in-place create a referenced document by specifying values. And then there is another user friendly thing: if there is some additional field in the request which is not in the document, it is ignored. Sometimes it can be not so intuitive how this interacts. :-) resource_uri
is not a real field so when it tries to do a query it fails with error above. If you would remove resource_uri
but leave other two fields, it should work. On the other hand, if it tries to create a new referenced document, it ignores resource_uri
and just creates a new embedded document. So I am not so sure "problem does not occur" really happens. Probably it creates another referenced document, it does not reference the one you want.
This happens when you want to be user friendly and resolve ambiguities. :-)
wow thanks for the explanation. I'll check that it does not create another document and that it does exactly what I want :-)
OK, maybe that auto-creation does not really work always. :-)
Hi !
I've got this schema :
And when trying to update a PipeResource, I've got this error :
So am I doing things right or do I miss something ? Because it seems that Tastypie hands the
resource_uri
field to MongoEngine, and it shouldn't... I precise that the EmbeddedExporterListResource is not only a ReferenceField, but contains other fieldsThansks for your help, I post this on stackoverflow too : http://stackoverflow.com/questions/13287098