本文整理汇总了Python中trac.versioncontrol.RepositoryManager.close方法的典型用法代码示例。如果您正苦于以下问题:Python RepositoryManager.close方法的具体用法?Python RepositoryManager.close怎么用?Python RepositoryManager.close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类trac.versioncontrol.RepositoryManager
的用法示例。
在下文中一共展示了RepositoryManager.close方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: from_comment
# 需要导入模块: from trac.versioncontrol import RepositoryManager [as 别名]
# 或者: from trac.versioncontrol.RepositoryManager import close [as 别名]
def from_comment(cls, env, comment, user=None, notify=True):
"""
Creates a subscription from a Comment object.
"""
sub = {
'user': user or comment.author,
'type': comment.type,
'notify': notify,
}
# Munge attachments
if comment.type == 'attachment':
sub['path'] = comment.path.split(':')[1]
sub['repos'] = ''
sub['rev'] = ''
# Munge changesets and browser
if comment.type in ('changeset', 'browser'):
if comment.type == 'browser':
sub['path'] = comment.path
else:
sub['path'] = ''
repo = RepositoryManager(env).get_repository(None)
try:
sub['repos'] = repo.reponame
try:
_cs = repo.get_changeset(comment.revision)
sub['rev'] = _cs.rev
except NoSuchChangeset:
# Invalid changeset
return None
finally:
repo.close()
return cls._from_dict(env, sub)
示例2: match_request
# 需要导入模块: from trac.versioncontrol import RepositoryManager [as 别名]
# 或者: from trac.versioncontrol.RepositoryManager import close [as 别名]
def match_request(self, request):
"""Match requests which are POST, include a 'commit' argument, and point at an existing repo"""
if request.method != 'POST':
return False
repo_name = _get_repo_name(request.path_info)
if repo_name is None:
return False
repo = RepositoryManager(self.env).get_repository(repo_name)
if repo is None:
return False
repo.close()
from cgi import parse_qs
request.args = parse_qs(request.read())
if request.args.get('commit', request.args.get('payload', None)) is None:
return False
## XXX: evil hack to disable CSRF checking (is there a better way?)
request._inheaders.insert(0, ('content-type', 'xx'))
## Go!
self.log.info('Handling a beanstalk hook callback for repository [%s]' % repo_name)
return True