milesrichardson / ParsePy

A relatively up-to-date fork of ParsePy, the Python wrapper for the Parse.com API. Originally maintained by @dgrtwo
MIT License
515 stars 184 forks source link

Resaving object with a Pointer<_User> field #112

Closed dumbshow closed 9 years ago

dumbshow commented 9 years ago

Hi,

I have some javascript code which is populating a parse database. I would like to later work with this data in python. One of the fields is a pointer to the current user, which is set like this, according to the conventions of ParseReact:

mut = ParseReact.Mutation.Create('Person', { .... user: Parse.User.current().toPlainObject() }).dispatch();

The user field shows up in the parse database as type Pointer<_User>. I'm able to query and manipulate this object in python with parse_rest, but resaving raises this exception:

ResourceRequestBadRequest: {"code":111,"error":"invalid type for key user, expected _User, but got User"}

It does appear that some efforts have been made to accommodate the "_User" type here: https://github.com/garethr/booky/blob/08615163198a2b51353aeba07f25ec9ed477d60c/src/booky/lib/builder.py#L17-24

Any thoughts on why this save is failing? Thank you for any help.

dumbshow commented 9 years ago

For what it's worth, I don't need to manipulate the user field in python. So if there were a way to exclude it from the query or save, that would be a solution too. Thanks again.

dumbshow commented 9 years ago

My problem was solved by importing the User class before working with queries containing a user object:

from parse_rest.user import User

Should I close the issue? Thanks.

ashrayjain commented 9 years ago

Thanks! This was very helpful to me! It should probably be added to the documentation.

twenty12 commented 9 years ago

That was very helpful. Thank you!