Permalink
Browse files

added __init__.py and moved example code into main function

  • Loading branch information...
1 parent 5231801 commit c85c9c1dd32f242e8c2724b18c2e1baef3d61ecf @domoritz domoritz committed Jul 26, 2012
Showing with 31 additions and 27 deletions.
  1. 0 __init__.py
  2. +31 −27 example.py
View
No changes.
View
@@ -4,30 +4,34 @@
from popit import PopIt
from pprint import pprint
-api = PopIt(instance = 'professors', hostname = '127-0-0-1.org.uk', port = 3000, user = 'test@test.co.uk', password = 'tJo1zBum')
-
-# Create
-print("CREATE")
-new = api.person.post({'name': 'Albert Keinstein'})
-pprint(new)
-
-id = new['result']['_id']
-
-# Update
-print("UPDATE")
-result = api.person(id).put({"name": "Albert Einstein"})
-pprint(result)
-
-# Read
-print("READ")
-result = api.person(id).get()
-pprint(result)
-
-# read all
-results = api.person().get()
-pprint(results)
-
-# Delete
-print("DELETE")
-result = api.person(id).delete()
-pprint(result)
+def main():
+ api = PopIt(instance = 'professors', hostname = '127-0-0-1.org.uk', port = 3000, user = 'test@test.co.uk', password = 'tJo1zBum')
+
+ # Create
+ print("CREATE")
+ new = api.person.post({'name': 'Albert Keinstein'})
+ pprint(new)
+
+ id = new['result']['_id']
+
+ # Update
+ print("UPDATE")
+ result = api.person(id).put({"name": "Albert Einstein"})
+ pprint(result)
+
+ # Read
+ print("READ")
+ result = api.person(id).get()
+ pprint(result)
+
+ # read all
+ results = api.person().get()
+ pprint(results)
+
+ # Delete
+ print("DELETE")
+ result = api.person(id).delete()
+ pprint(result)
+
+if __name__ == '__main__':
+ main()

0 comments on commit c85c9c1

Please sign in to comment.