Commit 125b0e23 by Raphael Lullis

Moving code to its own folder, so we can have a namespaced package. Reflecting changes in README

parent 25b176f7
...@@ -9,15 +9,15 @@ Basic Usage ...@@ -9,15 +9,15 @@ Basic Usage
Let's get everything set up first. You'll need to give **ParsePy** your _Application Id_ and _Master Key_ (available from your Parse dashboard) in order to get access to your data. Let's get everything set up first. You'll need to give **ParsePy** your _Application Id_ and _Master Key_ (available from your Parse dashboard) in order to get access to your data.
~~~~~ {python} ~~~~~ {python}
>>> import ParsePy >>> import parse
>>> ParsePy.APPLICATION_ID = "your application id" >>> parse.APPLICATION_ID = "your application id"
>>> ParsePy.MASTER_KEY = "your master key here" >>> parse.MASTER_KEY = "your master key here"
~~~~~ ~~~~~
To create a new object of the Parse class _GameScore_: To create a new object of the Parse class _GameScore_:
~~~~~ {python} ~~~~~ {python}
>>> gameScore = ParsePy.ParseObject("GameScore") >>> gameScore = parse.ParseObject("GameScore")
>>> gameScore.score = 1337 >>> gameScore.score = 1337
>>> gameScore.playerName = "Sean Plott" >>> gameScore.playerName = "Sean Plott"
>>> gameScore.cheatMode = False >>> gameScore.cheatMode = False
...@@ -72,13 +72,13 @@ Additional Datatypes ...@@ -72,13 +72,13 @@ Additional Datatypes
If we want to store data in a ParseObject, we should wrap it in a ParseBinaryDataWrapper. The ParseBinaryDataWrapper behaves just like a string, and inherits all of _str_'s methods. If we want to store data in a ParseObject, we should wrap it in a ParseBinaryDataWrapper. The ParseBinaryDataWrapper behaves just like a string, and inherits all of _str_'s methods.
~~~~~ {python} ~~~~~ {python}
>>> gameScore.victoryImage = ParsePy.ParseBinaryDataWrapper('\x03\xf3\r\n\xc7\x81\x7fNc ... ') >>> gameScore.victoryImage = parse.ParseBinaryDataWrapper('\x03\xf3\r\n\xc7\x81\x7fNc ... ')
~~~~~ ~~~~~
We can store a reference to another ParseObject by assigning it to an attribute: We can store a reference to another ParseObject by assigning it to an attribute:
~~~~~ {python} ~~~~~ {python}
>>> collectedItem = ParsePy.ParseObject("CollectedItem") >>> collectedItem = parse.ParseObject("CollectedItem")
>>> collectedItem.type = "Sword" >>> collectedItem.type = "Sword"
>>> collectedItem.isAwesome = True >>> collectedItem.isAwesome = True
>>> collectedItem.save() # we have to save it before it can be referenced >>> collectedItem.save() # we have to save it before it can be referenced
...@@ -89,7 +89,7 @@ We can store a reference to another ParseObject by assigning it to an attribute: ...@@ -89,7 +89,7 @@ We can store a reference to another ParseObject by assigning it to an attribute:
We can also store geoPoint dataTypes as attributes using the format <code>'POINT(longitude latitude)'</code>, with latitude and longitude as float values We can also store geoPoint dataTypes as attributes using the format <code>'POINT(longitude latitude)'</code>, with latitude and longitude as float values
~~~~~ {python} ~~~~~ {python}
>>> restaurant = ParsePy.ParseObject("Restaurant") >>> restaurant = parse.ParseObject("Restaurant")
>>> restaurant.name = "Los Pollos Hermanos" >>> restaurant.name = "Los Pollos Hermanos"
>>> restaurant.location ="POINT(12.0 -34.45)" >>> restaurant.location ="POINT(12.0 -34.45)"
>>> restaurant.save() >>> restaurant.save()
...@@ -102,13 +102,13 @@ Querying ...@@ -102,13 +102,13 @@ Querying
To retrieve an object with a Parse class of _GameScore_ and an _objectId_ of _xxwXx9eOec_, run: To retrieve an object with a Parse class of _GameScore_ and an _objectId_ of _xxwXx9eOec_, run:
~~~~~ {python} ~~~~~ {python}
>>> gameScore = ParsePy.ParseQuery("GameScore").get("xxwXx9eOec") >>> gameScore = parse.ParseQuery("GameScore").get("xxwXx9eOec")
~~~~~ ~~~~~
We can also run more complex queries to retrieve a range of objects. For example, if we want to get a list of _GameScore_ objects with scores between 1000 and 2000 ordered by _playerName_, we would call: We can also run more complex queries to retrieve a range of objects. For example, if we want to get a list of _GameScore_ objects with scores between 1000 and 2000 ordered by _playerName_, we would call:
~~~~~ {python} ~~~~~ {python}
>>> query = ParsePy.ParseQuery("GameScore") >>> query = parse.ParseQuery("GameScore")
>>> query = query.gte("score", 1000).lt("score", 2000).order("playerName") >>> query = query.gte("score", 1000).lt("score", 2000).order("playerName")
>>> GameScores = query.fetch() >>> GameScores = query.fetch()
~~~~~ ~~~~~
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment