Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to create an arbitrary Object with dynamic Parse Class name #94

Closed
bitfinity opened this issue Mar 11, 2015 · 2 comments
Closed

How to create an arbitrary Object with dynamic Parse Class name #94

bitfinity opened this issue Mar 11, 2015 · 2 comments

Comments

@bitfinity
Copy link

I want to be able to create an arbitrary object as follows. Is this possible with your library?

flingyClass = 'Flingy' if something else 'FlingySomethingElse'
flingy = Object(className=flingyClass)
# and be able to query
flingy.Query.all()
@dgrtwo
Copy link
Collaborator

dgrtwo commented Mar 11, 2015

Yes, using the Object.factory method:

from parse_rest.datatypes import Object

flingyClass = "FlingySomethingElse"
flingy = Object.factory(flingyClass)

print flingy
# <class 'parse_rest.datatypes.FlingySomethingElse'>
print flingy.__name__
# FlingySomethingElse

You'll be able to use Query etc from that point on. You can see the code for that method here.

@dgrtwo dgrtwo closed this as completed Mar 11, 2015
@bitfinity
Copy link
Author

Awesome thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants