Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
C
corepost
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
nexlab
corepost
Commits
3ab1b71e
Commit
3ab1b71e
authored
Mar 05, 2012
by
Jacek Furmankiewicz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cleaning up docs
parent
acc7850f
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
56 deletions
+3
-56
README.md
README.md
+3
-56
No files found.
README.md
View file @
3ab1b71e
...
@@ -15,7 +15,7 @@ The simplest possible REST application:
...
@@ -15,7 +15,7 @@ The simplest possible REST application:
from corepost.web import route, RESTResource
from corepost.web import route, RESTResource
from corepost.enums import Http
from corepost.enums import Http
class R
estApp
():
class R
ESTService
():
@route("/",Http.GET)
@route("/",Http.GET)
def root(self,request,**kwargs):
def root(self,request,**kwargs):
...
@@ -30,7 +30,7 @@ The simplest possible REST application:
...
@@ -30,7 +30,7 @@ The simplest possible REST application:
return "%s" % numericid
return "%s" % numericid
if __name__ == '__main__':
if __name__ == '__main__':
app = RESTResource((R
estApp
,))
app = RESTResource((R
ESTService
,))
app.run()
app.run()
...
@@ -45,59 +45,6 @@ on a particular service:
...
@@ -45,59 +45,6 @@ on a particular service:
from corepost import Response, NotFoundException, AlreadyExistsException
from corepost import Response, NotFoundException, AlreadyExistsException
from corepost.web import RESTResource, route, Http
from corepost.web import RESTResource, route, Http
class DB():
"""Fake in-memory DB for testing"""
customers = {}
@classmethod
def getAllCustomers(cls):
return DB.customers.values()
@classmethod
def getCustomer(cls,customerId):
if customerId in DB.customers:
return DB.customers[customerId]
else:
raise NotFoundException("Customer",customerId)
@classmethod
def saveCustomer(cls,customer):
if customer.customerId in DB.customers:
raise AlreadyExistsException("Customer",customer.customerId)
else:
DB.customers[customer.customerId] = customer
@classmethod
def deleteCustomer(cls,customerId):
if customerId in DB.customers:
del(DB.customers[customerId])
else:
raise NotFoundException("Customer",customerId)
@classmethod
def deleteAllCustomers(cls):
DB.customers.clear()
@classmethod
def getCustomerAddress(cls,customerId,addressId):
c = DB.getCustomer(customerId)
if addressId in c.addresses:
return c.addresses[addressId]
else:
raise NotFoundException("Customer Address",addressId)
class Customer:
"""Represents customer entity"""
def __init__(self,customerId,firstName,lastName):
(self.customerId,self.firstName,self.lastName) = (customerId,firstName,lastName)
self.addresses = {}
class CustomerAddress:
"""Represents customer address entity"""
def __init__(self,streetNumber,streetName,stateCode,countryCode):
(self.streetNumber,self.streetName,self.stateCode,self.countryCode) = (streetNumber,streetName,stateCode,countryCode)
class CustomerRESTService():
class CustomerRESTService():
path = "/customer"
path = "/customer"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment