wlanslovenija / django-tastypie-mongoengine

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

Questions about versions and an obj_create error #44

Closed guerrysemones closed 11 years ago

guerrysemones commented 11 years ago

Hi,

I'm running into an issue with obj_create in resources.py throwing an exception. It happens after an upgrade while posting to the simplest model I can create. I really expect this is a versioning problem and before doing a pull request, wondered if you know something right off that might be the answer.

I have been successfully running the following: python 2.7 django-tastypie==0.9.11 django-tastypie-mongoengine==0.2.1 mongoengine==0.6.16

My app has one document model which I have been POSTing and GETing from with no problem. Today I tried adding PUT and PATCH for the model, and received "not implemented" messages in the return data. I thought that (and I could be wrong) that tastypie did not implement put and/or patch in 0.9.11. So, I upgraded my packages to:

django-tastypie==0.9.12 django-tastypie-mongoengine==0.3 mongoengine==0.6.16

After this point, doing a post on my original model resulted in: updated_bundle = self.obj_create(bundle, _self.remove_api_resource_names(kwargs)) File \"/Users/guerry/Envs/adfreeq/lib/python2.7/site-packages/tastypie_mongoengine/resources.py\", line 504, in obj_create\n return super(MongoEngineResource, self).obj_create(bundle, request, _kwargs)\n\nTypeError: obj_create() takes exactly 2 arguments (3 given)

I created a very simple model and resource (below) and got the same result.

class TestRecord(Document): my_text = StringField(max_length='10')

class TestRecordResource(resources.MongoEngineResource): class Meta: queryset = TestRecord.objects.all() resource_name = 'record' allowed_methods = ('post', 'get')

curl "http://localhost:8000/api/v1/record/" --dump-header - -H "Content-Type: application/json" -X POST --data '{ "my_text": "cool text" }'

Any thoughts?

guerrysemones commented 11 years ago

Incidentally, I downgraded to the original versions of each package and the code for my original model and the simple model worked. If you have any immediate feedback, I'd appreciate it as I'm under deadline. Meanwhile, I will try to make a pull request and make a simple test in an effort to recreate the problem.

guerrysemones commented 11 years ago

I see now with the simplest model that put/patch does work with my original configuration. Odd that I was getting the not implemented messages, but that was with a much more involved model, custom validation, custom security, etc. Still, I'd like to be able to upgrade all the involved packages, so I'd still like to resolve what I described above.

gmcguire commented 11 years ago

See #43, I think you'll need to stick with tastypie 0.9.11 until tastypie-mongoengine has been updated to support 0.9.12's changes.

guerrysemones commented 11 years ago

Ah, thanks. I saw that #43 , but misinterpreted some of what I saw there as done--I guess I should have clued into the fact that it was not closed. Duh.

mitar commented 11 years ago

Yes, sorry for your troubles. tastypie sadly makes backwards incompatible changes even with minor versions. Hm, I might also put an upper limit on the dependency in setup.py.

guerrysemones commented 11 years ago

No need to apologize. You're work has saved me tons of time and effort over all. :-) The dependency checks would be a nice thing, though!