本文整理汇总了Python中data.storage.Storage.addUserOwnCourse方法的典型用法代码示例。如果您正苦于以下问题:Python Storage.addUserOwnCourse方法的具体用法?Python Storage.addUserOwnCourse怎么用?Python Storage.addUserOwnCourse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类data.storage.Storage
的用法示例。
在下文中一共展示了Storage.addUserOwnCourse方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Users
# 需要导入模块: from data.storage import Storage [as 别名]
# 或者: from data.storage.Storage import addUserOwnCourse [as 别名]
class Users(object):
def __init__(self):
print 'User created\n'
# create storag
self.__store = Storage()
def addUser(self, data):
print 'In User.add method'
try:
self.__store.add('user', data)
return 'success'
except:
return 'failed'
def getUser(self, value):
print 'In User.get method'
try:
return self.__store.get('user', 'username', value)
except:
return 'failed'
def getAll(self):
print 'In Users.getAll method'
try:
return self.__store.getAll('user')
except:
return 'failed'
def updateUser(self, value, data):
print 'In User.update method'
try:
return self.__store.update('user', 'username', value, data)
except:
return 'failed'
def updateUserOwnCourse(self, email, courseid):
print 'In Course.updateUserOwnCourse method'
try:
return self.__store.addUserOwnCourse(email, courseid)
except:
traceback.print_exc()
return 'failed'
def removeUser(self, value):
print 'In User.remove method'
try:
return self.__store.remove('user', 'email', value)
except:
return 'failed'
示例2: Course
# 需要导入模块: from data.storage import Storage [as 别名]
# 或者: from data.storage.Storage import addUserOwnCourse [as 别名]
class Course(object):
def __init__(self):
print 'Course created\n'
# create storag
self.__store = Storage()
def add(self, email, data):
print 'In Course.add method'
try:
courseid = self.__store.add('course', data)
#Also update 'own' field of user collection
self.__store.addUserOwnCourse(email, str(courseid))
return courseid
except:
traceback.print_exc()
return 'failed'
def get(self, value):
print 'In Course.get method'
try:
return self.__store.get('course', '_id', ObjectId(value))
except:
traceback.print_exc()
return 'failed'
def update(self, value, data):
print 'In Course.update method'
try:
return self.__store.update('course', '_id', ObjectId(value), data)
except:
traceback.print_exc()
return 'failed'
def remove(self, value):
print 'In Course.remove method'
try:
return self.__store.remove('course', '_id', ObjectId(value))
except:
traceback.print_exc()
return 'failed'
def getAll(self):
print 'In Course.getAll method'
try:
return self.__store.getAll('courseContent')
except:
traceback.print_exc()
return 'failed'
def enroll(self, email, courseid):
print 'In Course.enroll method'
try:
return self.__store.enrollCourse(email, courseid)
except:
traceback.print_exc()
return 'failed'
def drop(self, email, courseid):
print 'In Course.drop method'
try:
return self.__store.dropCourse(email, courseid)
except:
traceback.print_exc()
return 'failed'