本文整理汇总了Python中bproject.models.models.DBSession.flush方法的典型用法代码示例。如果您正苦于以下问题:Python DBSession.flush方法的具体用法?Python DBSession.flush怎么用?Python DBSession.flush使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bproject.models.models.DBSession
的用法示例。
在下文中一共展示了DBSession.flush方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: edit
# 需要导入模块: from bproject.models.models import DBSession [as 别名]
# 或者: from bproject.models.models.DBSession import flush [as 别名]
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
示例2: add_category
# 需要导入模块: from bproject.models.models import DBSession [as 别名]
# 或者: from bproject.models.models.DBSession import flush [as 别名]
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
示例3: add
# 需要导入模块: from bproject.models.models import DBSession [as 别名]
# 或者: from bproject.models.models.DBSession import flush [as 别名]
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
示例4: modify
# 需要导入模块: from bproject.models.models import DBSession [as 别名]
# 或者: from bproject.models.models.DBSession import flush [as 别名]
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
示例5: delete_category
# 需要导入模块: from bproject.models.models import DBSession [as 别名]
# 或者: from bproject.models.models.DBSession import flush [as 别名]
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
示例6: add_entry
# 需要导入模块: from bproject.models.models import DBSession [as 别名]
# 或者: from bproject.models.models.DBSession import flush [as 别名]
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
示例7: delete_entry
# 需要导入模块: from bproject.models.models import DBSession [as 别名]
# 或者: from bproject.models.models.DBSession import flush [as 别名]
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
示例8: edit_entry
# 需要导入模块: from bproject.models.models import DBSession [as 别名]
# 或者: from bproject.models.models.DBSession import flush [as 别名]
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
示例9: delete
# 需要导入模块: from bproject.models.models import DBSession [as 别名]
# 或者: from bproject.models.models.DBSession import flush [as 别名]
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
示例10: edit_category
# 需要导入模块: from bproject.models.models import DBSession [as 别名]
# 或者: from bproject.models.models.DBSession import flush [as 别名]
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
示例11: add_new
# 需要导入模块: from bproject.models.models import DBSession [as 别名]
# 或者: from bproject.models.models.DBSession import flush [as 别名]
def add_new(self, history):
log.debug("add_new")
response = Return()
try:
if history:
history.date = history.date if history.date else helpers.dtnow()
DBSession.add(history)
DBSession.flush()
response.success()
log.info("History item {0}:{1} has been added".format(history.option, history.action))
else:
log.error(msg)
response.nodata()
except Exception as ex:
log.exception(ex)
response.exception()
return response
示例12: add
# 需要导入模块: from bproject.models.models import DBSession [as 别名]
# 或者: from bproject.models.models.DBSession import flush [as 别名]
def add(self, user = None):
log.debug("add")
response = Return()
try:
if user:
user.id = DBSession.add(user)
response.data = user
DBSession.flush()
msg = "User {0} has been added".format(user.name)
log.info(msg)
response.success()
self.history.add(static.options.users, static.actions.add, msg)
else:
response.nodata()
except Exception as ex:
log.exception(ex)
response.exception()
return response
示例13: delete
# 需要导入模块: from bproject.models.models import DBSession [as 别名]
# 或者: from bproject.models.models.DBSession import flush [as 别名]
def delete(self, identifier):
log.debug("delete")
result = Return()
try:
user = self.by_identifier(identifier)
if user:
self.accounts.delete(identifier)
DBSession.delete(user)
DBSession.flush()
result.success()
self.history.add(static.options.users, static.actions.delete, "User: {0} deleted".format(user.name))
else:
result.notfound()
log.info(result.msg)
except Exception as ex:
log.exception(ex)
result.exception()
return result
示例14: add
# 需要导入模块: from bproject.models.models import DBSession [as 别名]
# 或者: from bproject.models.models.DBSession import flush [as 别名]
def add(self, place = None):
log.debug("add")
result = Return()
try:
if place:
place.id = DBSession.add(place)
result.data = place
DBSession.flush()
msg = "Place {0} has been added".format(place.name)
# Add entry to audit trail
log.info(msg)
result.success()
else:
result.nodata()
except Exception as ex:
log.exception(ex)
result.exception()
return result
示例15: delete
# 需要导入模块: from bproject.models.models import DBSession [as 别名]
# 或者: from bproject.models.models.DBSession import flush [as 别名]
def delete(self, name = None, group = None):
log.debug("delete")
response = Return()
org = self.get(name = name, group = group)
if org:
try:
DBSession.delete(org)
DBSession.flush()
response.success()
response.msg = "Group {0} has been deleted".format(name)
log.info(response.msg)
self.history.add(static.options.groups, static.actions.delete, response.msg)
except Exception as ex:
DBSession.rollback()
log.exception(ex)
response.exception()
else:
response.notfound()
log.error(response.msg)
return response