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


Python models.DBSession类代码示例

本文整理汇总了Python中bproject.models.models.DBSession的典型用法代码示例。如果您正苦于以下问题:Python DBSession类的具体用法?Python DBSession怎么用?Python DBSession使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: add_category

 def add_category(self, category):
     """ Inserts new category """
     log.debug("categories-add")
     category.dt = datetime.now()
     category.id = DBSession.add(category)
     DBSession.flush()
     return category
开发者ID:bartoszp32,项目名称:BProject,代码行数:7,代码来源:settingsfacade.py

示例2: edit

 def edit(self, idx = None, name = None):
     """ Lets to change name of existing group """
     log.debug("edit")
     response = Return()
     # Look for already existing record
     org = self.get(name = name)
     if org is None:
         # Group found
         if idx != None and name != None:
             group = self.get(idx = idx)
             old_name = group.name
             group.id = idx
             group.name = name
             group.dt = helpers.dtnow()
             DBSession.add(group)
             #response.data = group
             DBSession.flush()
             response.success()
             response.msg = "Successfully changed from {0} to {1}".format(old_name, name)
             log.info(response.msg)
             self.history.add(static.options.groups, static.actions.edit, response.msg)
         else:
             response.nodata()
             log.error(response.msg)
     else:
         # Group exist - name have to be unique
         response.msg = "Group already exists - not unique group name: {0}".format(name)
         log.error(response.msg)
     return response
开发者ID:bartoszp32,项目名称:BProject,代码行数:29,代码来源:groupsfacade.py

示例3: add

 def add(self, name, permissions = ""):
     log.debug("add")
     response = Return()
     group = None
     if name is None:
         response.nodata()
         log.error(response.msg)
     else:
         try:
             if not(self.get(name = name)):
                 group = Group(name = name)
                 group.permissions = permissions
                 group.id = DBSession.add(group)
                 response.data = group
                 DBSession.flush()
                 response.success()
                 response.msg = "Group {0} has been added".format(name)
                 log.info(response.msg)
                 self.history.add(static.options.groups, static.actions.add, response.msg)
             else:
                 response.msg = "Group {0} already exists".format(name)
                 log.error(response.msg)
         except Exception as ex:
             log.exception(ex)
             response.exception()
     return response
开发者ID:bartoszp32,项目名称:BProject,代码行数:26,代码来源:groupsfacade.py

示例4: changepassword

 def changepassword(self, identifier, old, new, rpt):
     log.debug("change password")
     result = Return()
     try:
         if identifier and old and new and rpt:
             if new == rpt:
                 account = self.by_identifier(identifier)
                 if account:
                     if self.encryptor.compare(old, account.password, account.salt):
                         account.salt = self.encryptor.salt()
                         account.password = self.encryptor.encode(new, account.salt)
                         account.dt = helpers.dtnow()
                         DBSession.add(account)
                         result.success()
                         result.data = new
                     else:
                         result.msg = "Incorrect password"
                 else:
                     result.notfound(identifier)
             else:
                 result.msg = "Passwords are not equal"
         else:
             result.nodata()
         log.info(result.msg)
     except Exception as ex:
         log.exception(ex)
         result.exception()
     return result
开发者ID:bartoszp32,项目名称:BProject,代码行数:28,代码来源:accountfacade.py

示例5: modify

 def modify(self, identifier, new_user):
     log.debug("modify")
     result = Return()
     try:
         if identifier and new_user:
             result = self.validate_existing(new_user)
             if result.status:
                 user = self.by_identifier(identifier)
                 if user:
                     user.name = new_user.get("name")
                     user.lastname = new_user.get("lastname")
                     user.email = new_user.get("email")
                     user.dt = helpers.dtnow()
                     DBSession.add(user)
                     result.data = self.get_details(user)
                     DBSession.flush()
                     result.success()
                     self.history.add(static.options.users, static.actions.edit, "User: {0} modified".format(user.name))
                 else:
                     result.notfound()
         else:
             result.nodata()
         log.info(result.msg)
     except Exception as ex:
         log.exception(ex)
         result.exception()
     return result
开发者ID:bartoszp32,项目名称:BProject,代码行数:27,代码来源:usersfacade.py

示例6: delete_category

 def delete_category(self, idx):
     """ Removes category by id """
     log.debug("categories-delete")
     category = self.get_category_by_id(idx)
     if category:
         DBSession.delete(category)
         DBSession.flush()
     return category
开发者ID:bartoszp32,项目名称:BProject,代码行数:8,代码来源:settingsfacade.py

示例7: delete_entry

 def delete_entry(self, idx):
     log.debug("delete-entry")
     entry = self.get_entry_by_id(idx)
     if entry:
         DBSession.delete(entry)
         DBSession.flush()
         return True
     else:
         log.error("Entry with id: {0} doesn't exists".format(idx))
     return False
开发者ID:bartoszp32,项目名称:BProject,代码行数:10,代码来源:settingsfacade.py

示例8: add_entry

 def add_entry(self, entry, category):
     log.debug("entries-add")
     catEntry = self.get_category_by_id(category)
     entry.dt = datetime.now()
     catEntry.entries.append(entry)
     data = DBSession.add(catEntry)
     entry = self.get_entry_by_code(entry.code)
     log.info("New id: {0}".format(data))
     DBSession.flush()
     return entry
开发者ID:bartoszp32,项目名称:BProject,代码行数:10,代码来源:settingsfacade.py

示例9: get

 def get(self, idx = None, name = None):
     log.debug("get place by id: {0}, name: {1}", idx, name)
     place = None
     try:
         if idx:
             place = DBSession.query(Place).filter_by(id = int(idx)).first()
         elif name:
             place = DBSession.query(Place).filter_by(name = name).first()
     except Exception as ex:
         log.exception(ex)
     return place
开发者ID:bartoszp32,项目名称:BProject,代码行数:11,代码来源:placesfacade.py

示例10: edit_entry

 def edit_entry(self, idx, entry):
     log.debug("edit-entry")
     original = self.get_entry_by_id(idx)
     if original:
         original.name = entry.name
         original.value = entry.value
         original.type = entry.type
         original.dt = datetime.now()
         DBSession.add(original)
         DBSession.flush()
         return True
     return False
开发者ID:bartoszp32,项目名称:BProject,代码行数:12,代码来源:settingsfacade.py

示例11: delete

 def delete(self, place):
     log.debug("places_delete")
     if place:
         try:
             DBSession.delete(place)
             DBSession.flush()
             return True
         except Exception as ex:
             log.exception(ex)
     else:
         log.error("Empty place object")
     return False
开发者ID:bartoszp32,项目名称:BProject,代码行数:12,代码来源:placesfacade.py

示例12: update

 def update(self, place = None):
     log.debug("places_update")
     if place:
         try:
             DBSession.add(place)
             log.info("Place {0} removed")
             return True
         except Exception as ex:
             log.exception(ex)
     else: 
         log.error("Place obj is empty")
     return False
开发者ID:bartoszp32,项目名称:BProject,代码行数:12,代码来源:placesfacade.py

示例13: setgroups

 def setgroups(self, identifier, jsongroups):
     log.debug("setgroups")
     groups = []
     account = self.by_identifier(identifier)
     for json in jsongroups:
         g = json.get("group")
         if json.get("assigned"):
             group = self.groups.get(idx = g.get("id"))
             groups.append(group)
     account.dt = helpers.dtnow()
     account.groups = groups
     DBSession.add(account)
开发者ID:bartoszp32,项目名称:BProject,代码行数:12,代码来源:accountfacade.py

示例14: get

 def get(self, idx = None, name = None, group = None):
     log.debug("get")
     org = None
     try:
         if group is not None:
             org = DBSession.query(Group).filter_by(id = group.id).first()
         elif idx is not None:
             org = DBSession.query(Group).filter_by(id = int(idx)).first()
         elif name is not None:
             org = DBSession.query(Group).filter_by(name = name).first()
     except Exception as ex:
         log.exception(ex)
     return org
开发者ID:bartoszp32,项目名称:BProject,代码行数:13,代码来源:groupsfacade.py

示例15: edit_category

 def edit_category(self, idx, category):
     """ Updates existing cateogry by id """
     log.debug("categories-edit")
     original = self.get_category_by_id(idx)
     if original is not None:
         original.name = category.name
         original.code = category.code
         original.options = category.options
         original.dt = datetime.now()
         DBSession.add(original)
         DBSession.flush()
         return original
     else:
         return None
开发者ID:bartoszp32,项目名称:BProject,代码行数:14,代码来源:settingsfacade.py


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