Skip to content

Commit

Permalink
updated demo
Browse files Browse the repository at this point in the history
  • Loading branch information
flyingfisch committed May 15, 2015
1 parent 9bb5a93 commit 8d6717f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
Binary file modified .crud-demo.py.swp
Binary file not shown.
13 changes: 8 additions & 5 deletions crud-demo.py
Expand Up @@ -2,6 +2,7 @@

from rest import CRUD

#User class {{{
class User:
name = ""
age = 0
Expand All @@ -14,28 +15,30 @@ def __init__(self, name, age, weight):

def __repr__(self):
return "User {{ name: {0}, age: {1}, weight: {2} }}".format(self.name, self.age, self.weight)
#}}}

# make a collection of users
users = CRUD()

# make some users
joe = User("Joe Smith", 45, 180)
mary = User("Mary Jones", 21, 120)
james = User("James Donovan", 28, 190)
john = User("John Doe", 32, 210)

# add them to users
users.create([joe, mary, james])

print("Users created\r\n", users.read())

# put john in users
users.create(john)

print("Added another\r\n", users.read())

# modify john
john = User("John Doe, Jr.", 32, 210)

users.update(3, john)

print("Updated John\r\n", users.read())

# delete john
users.delete(3)

print("Deleted John\r\n", users.read())

0 comments on commit 8d6717f

Please sign in to comment.