本文整理汇总了Python中meta.Session.delete方法的典型用法代码示例。如果您正苦于以下问题:Python Session.delete方法的具体用法?Python Session.delete怎么用?Python Session.delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类meta.Session
的用法示例。
在下文中一共展示了Session.delete方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Manager
# 需要导入模块: from meta import Session [as 别名]
# 或者: from meta.Session import delete [as 别名]
#.........这里部分代码省略.........
break
i += 1
except IndexError:
act_deact = None
if deactivate:
act_deact = "deactivate"
else:
act_deact = "activate"
s = "Cannot find '%s' to %s." % (str(opt), act_deact)
self.logger.error(s)
return
# Error
else:
s = "Not a valid site! Use site's feed url or site number."
self.logger.error(s)
raise TypeError(s)
def del_site(self, opt):
"""
Removes site.
User can pass as 'opt' a site number or feed url.
"""
# Del by option number
if isinstance(opt, int):
try:
site = self.session.query(Site).filter(Site.id == opt).one()
feed = self.session.query(Feed).filter(Feed.siteid == opt).one()
i = 0
while True:
if self.sites[i].feed.url == site.feed.url:
del self.sites[i]
break
i += 1
self.session.delete(site)
self.session.commit()
except IndexError:
s = "Cannot find to remove site #" + str(opt) + "."
self.logger.error(s)
return
# Del by feed url
elif isinstance(opt, str):
i = 0
while True:
try:
site = self.sites[i]
if site.feed.url == opt:
self.session.delete(site)
self.session.delete(site.feed)
del self.sites[i]
self.session.commit()
return
i += 1
except IndexError:
s = "Cannot find to remove site's feed '" + opt + "'."
self.logger.error(s)
return
# Error
else:
s = "Not a valid site! Use site's feed url or site number."
self.logger.error(s)
raise TypeError(s)
def del_sites(self):
"""
Deletes all sites.
"""