本文整理汇总了Python中data.storage.Storage类的典型用法代码示例。如果您正苦于以下问题:Python Storage类的具体用法?Python Storage怎么用?Python Storage使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Storage类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: updateBoard
def updateBoard(id,boardName):
print '--in moo.createBoard'
user_id = request.forms.get("id")
bName=request.forms.get("boardName")
print "id", user_id
print "boardName", bName
couch = couchdb.Server()
mydb = couch['userdb']
myboardDB = couch['boards']
#doc = mydb[user_id]
if user_id in mydb:
if bName in myboardDB:
# bname=request.PUT.get('boardName')
# bdesc = request.PUT.get('boardDesc')
# category = request.PUT.get('category')
# boardType = request.PUT.get('isPrivate')
bname = request.POST.get('name')
bdesc = request.POST.get('boardDesc')
category = request.POST.get('category')
boardType = request.POST.get('isPrivate')
print "new board name is ", bname
global storage
storage = Storage()
boardId = storage.updateBoard(user_id,bName, bname, bdesc, category, boardType)
return boardId
else:
return "Board not Authorized!"
else:
return "User not authorized"
示例2: deleteComment
def deleteComment(userId,boardName,pinId):
print
'--in moo.deleteComment'
global storage
storage = Storage()
bId = storage.getBoardId(boardName)
couch = couchdb.Server()
mydb = couch['userdb']
board = couch['boards']
pins= couch ['pinsdb']
if userId in mydb:
if bId in board:
if pinId in pins:
# desc=request.POST.get('description')
#print desc
global storage
storage = Storage()
pinId = storage.deleteComment(userId,bId,pinId)
return pinId
else:
return "Pin not found!"
else:
return "Board not Found!"
else:
return "User Not Authorized!"
示例3: updatePin
def updatePin(userId,boardName,pinId):
couch = couchdb.Server()
mydb = couch['userdb']
board = couch['boards']
pin=couch['pinsdb']
global storage
storage = Storage()
bId = storage.getBoardId(boardName)
if userId in mydb:
if bId in board:
if pinId in pin:
pname = request.POST.get('pinName')
pdesc = request.POST.get('pinDesc')
image = request.POST.get('image')
boardId = storage.updatePin(userId,bId, pinId,pname, pdesc,image )
return boardId
else:
return "Invalid Pin Id!"
else:
return "Invalid Board Id!"
else:
return "User not authorized"
示例4: Business
class Business(object):
def __init__(self):
print 'business created'
# Get storage object
self.__store = Storage()
def get(self, value):
print 'In business.get method'
try:
return self.__store.get('business', 'business_id', value)
except:
traceback.print_exc()
return 'failed'
def remove(self, value):
print 'In business.remove method'
try:
return self.__store.remove('business', 'business_id', value)
except:
traceback.print_exc()
return 'failed'
def getAll(self):
print 'In business.getAll method'
try:
return self.__store.getAll('business')
except:
traceback.print_exc()
return 'failed'
示例5: signUp
def signUp():
print '---> moo.signUp'
Fname = request.POST.get('fname')
Lname = request.POST.get('lname')
emailId = request.POST.get('emailId')
password = request.POST.get('password')
global storage
storage = Storage()
user_id = storage.insertUser(Fname, Lname, emailId, password)
return user_id
示例6: getBoardList
def getBoardList(userId):
print '--in moo.getBoardList'
L = list()
couch = couchdb.Server()
print "id is ----",userId
myUserdb = couch['userdb']
if userId in myUserdb:
storage = Storage()
L = storage.getBoardNames(userId)
return L
else:
return "User Id does not exist!"
示例7: deleteBoard
def deleteBoard(userId,boardName):
print '--in moo.deleteBoard'
couch = couchdb.Server()
mydb = couch['userdb']
myboardDB = couch['boards']
global storage
storage = Storage()
bId = storage.getBoardId(boardName)
if userId in mydb:
if bId in myboardDB:
boardId = storage.deleteBoard(userId,bId)
else:
return "Board not Authorized!"
else:
return "User not authorized"
示例8: Message
class Message(object):
def __init__(self):
print 'message created'
# create storage
self.__store = Storage()
def add(self, data):
print 'In message.add method'
try:
return self.__store.add('message', data)
except:
traceback.print_exc()
return 'failed'
def get(self, value):
print 'In message.get method'
try:
return self.__store.get('message', '_id', ObjectId(value))
except:
traceback.print_exc()
return 'failed'
def update(self, value, data):
print 'In message.update method'
try:
return self.__store.update('message', '_id', ObjectId(value), data)
except:
traceback.print_exc()
return 'failed'
def remove(self, value):
print 'In message.remove method'
try:
return self.__store.remove('message', '_id', ObjectId(value))
except:
traceback.print_exc()
return 'failed'
def getAll(self):
print 'In message.getAll method'
try:
return self.__store.getAll('message')
except:
traceback.print_exc()
return 'failed'
示例9: Announcement
class Announcement(object):
def __init__(self):
print 'Announcement created'
# create storag
self.__store = Storage()
def add(self, data):
print 'In announcement.add method'
try:
return self.__store.add('announcement', data)
except:
traceback.print_exc()
return 'failed'
def get(self, value):
print 'In announcement.get method'
try:
return self.__store.get('announcement', '_id', ObjectId(value))
except:
traceback.print_exc()
return 'failed'
def update(self, value, data):
print 'In announcement.update method'
try:
return self.__store.update('announcement', '_id', ObjectId(value), data)
except:
traceback.print_exc()
return 'failed'
def remove(self, value):
print 'In announcement.remove method'
try:
return self.__store.remove('announcement', '_id', ObjectId(value))
except:
traceback.print_exc()
return 'failed'
def getAll(self):
print 'In announcement.getAll method'
try:
return self.__store.getAll('announcement')
except:
traceback.print_exc()
return 'failed'
示例10: getBoardDetails
def getBoardDetails(userId,boardName):
print '--in moo.getBoardList'
couch = couchdb.Server()
myUserdb = couch['userdb']
myboardDB = couch['boards']
storage = Storage()
bId = storage.getBoardId(boardName)
if userId in myUserdb:
if bId in myboardDB:
doc = storage.viewBoard(bId)
return doc
else:
return "Board Id does not exist"
else:
return "User not Authorized!"
示例11: createBoard
def createBoard(userId):
couch = couchdb.Server()
myUserdb = couch['userdb']
print myUserdb
if userId in myUserdb:
bname=request.POST.get('boardName')
bdesc = request.POST.get('boardDesc')
category=request.POST.get('category')
boardType=request.POST.get('isPrivate')
global storage
storage = Storage()
boardId = storage.insertBoard(userId,bname,bdesc,category,boardType)
return boardId
else:
return "User not Authorized!"
示例12: viewAllPin
def viewAllPin(userId,boardName):
print
'--in moo.viewAllPins'
couch = couchdb.Server()
board = couch['boards']
myUserdb = couch['userdb']
global storage
storage = Storage()
bId = storage.getBoardId(boardName)
if id in myUserdb:
if bId in board:
doc=storage.viewAllPins(id,bId)
return doc
else:
return "Board Id not Found!"
else:
return "User Id Not Found!"
示例13: Category
class Category(object):
def __init__(self):
print 'Category created'
# create storage
self.__store = Storage()
def add(self, data):
print 'In Category.add method'
try:
return self.__store.add('category', data)
except:
return 'failed'
def get(self, value):
print 'In Category.get method'
try:
return self.__store.get('category', '_id', ObjectId(value))
except:
return 'failed'
def update(self, value, data):
print 'In Category.update method'
try:
return self.__store.update('category', '_id', ObjectId(value), data)
except:
return 'failed'
def remove(self, value):
print 'In Category.remove method'
try:
return self.__store.remove('category', '_id', ObjectId(value))
except:
return 'failed'
def getAll(self):
print 'In Category.getAll method'
try:
return self.__store.getAll('category')
except:
return 'failed'
示例14: createBoard
def createBoard(id):
print '--in moo.createBoard'
user_id = request.forms.get("id")
print "id", user_id
couch = couchdb.Server()
mydb = couch['userdb']
#doc = mydb[user_id]
if user_id in mydb:
bname = request.POST.get('boardName')
bdesc = request.POST.get('boardDesc')
category = request.POST.get('category')
boardType = request.POST.get('isPrivate')
global storage
storage = Storage()
boardId = storage.insertBoard(user_id, bname, bdesc, category, boardType)
return boardId
else:
return "User not Authorized!"
示例15: updateBoard
def updateBoard(userId,boardName):
print '--in moo.createBoard'
global storage
storage = Storage()
couch = couchdb.Server()
mydb = couch['userdb']
myboardDB = couch['boards']
bId = storage.getBoardId(boardName)
if userId in mydb:
if bId in myboardDB:
bname = request.POST.get('name')
bdesc = request.POST.get('boardDesc')
category = request.POST.get('category')
boardType = request.POST.get('isPrivate')
boardId = storage.updateBoard(userId,bId, bname, bdesc, category, boardType)
return boardId
else:
return "Board not Authorized!"
else:
return "User not authorized"