当前位置: 首页>>代码示例>>Python>>正文


Python Storage.update方法代码示例

本文整理汇总了Python中data.storage.Storage.update方法的典型用法代码示例。如果您正苦于以下问题:Python Storage.update方法的具体用法?Python Storage.update怎么用?Python Storage.update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在data.storage.Storage的用法示例。


在下文中一共展示了Storage.update方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: Users

# 需要导入模块: from data.storage import Storage [as 别名]
# 或者: from data.storage.Storage import update [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' 
开发者ID:richil-bhalerao,项目名称:doccapp_deploy,代码行数:54,代码来源:user.py

示例2: Announcement

# 需要导入模块: from data.storage import Storage [as 别名]
# 或者: from data.storage.Storage import update [as 别名]
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'
开发者ID:richil-bhalerao,项目名称:MOOC,代码行数:49,代码来源:announcement.py

示例3: Message

# 需要导入模块: from data.storage import Storage [as 别名]
# 或者: from data.storage.Storage import update [as 别名]
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'    
开发者ID:richil-bhalerao,项目名称:MOOC,代码行数:49,代码来源:message.py

示例4: Category

# 需要导入模块: from data.storage import Storage [as 别名]
# 或者: from data.storage.Storage import update [as 别名]
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'    
开发者ID:richil-bhalerao,项目名称:MOOC,代码行数:44,代码来源:category.py

示例5: Course

# 需要导入模块: from data.storage import Storage [as 别名]
# 或者: from data.storage.Storage import update [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'
开发者ID:richil-bhalerao,项目名称:doccapp,代码行数:69,代码来源:course.py


注:本文中的data.storage.Storage.update方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。