annotate pylons_app/lib/utils.py @ 111:70b1e5d1e20d

simplehg, cleanup
author Marcin Kuzminski <marcin@python-works.com>
date Wed, 28 Apr 2010 00:16:08 +0200
parents f24b9a2934cf
children cc5cf1a93902
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
82
670713507d03 Moved summary to seperate controller,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff changeset
1
670713507d03 Moved summary to seperate controller,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff changeset
2 def get_repo_slug(request):
670713507d03 Moved summary to seperate controller,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff changeset
3 path_info = request.environ.get('PATH_INFO')
96
f24b9a2934cf added is mercurial method in utils,
Marcin Kuzminski <marcin@python-works.com>
parents: 93
diff changeset
4 uri_lst = path_info.split('/')
93
aec4c0071cb3 added empty controllers for branches tags files graph, routing and test for them
Marcin Kuzminski <marcin@python-works.com>
parents: 82
diff changeset
5 repo_name = uri_lst[1]
82
670713507d03 Moved summary to seperate controller,
Marcin Kuzminski <marcin@python-blog.com>
parents:
diff changeset
6 return repo_name
96
f24b9a2934cf added is mercurial method in utils,
Marcin Kuzminski <marcin@python-works.com>
parents: 93
diff changeset
7
f24b9a2934cf added is mercurial method in utils,
Marcin Kuzminski <marcin@python-works.com>
parents: 93
diff changeset
8 def is_mercurial(environ):
f24b9a2934cf added is mercurial method in utils,
Marcin Kuzminski <marcin@python-works.com>
parents: 93
diff changeset
9 """
f24b9a2934cf added is mercurial method in utils,
Marcin Kuzminski <marcin@python-works.com>
parents: 93
diff changeset
10 Returns True if request's target is mercurial server - header
f24b9a2934cf added is mercurial method in utils,
Marcin Kuzminski <marcin@python-works.com>
parents: 93
diff changeset
11 ``HTTP_ACCEPT`` of such request would start with ``application/mercurial``.
f24b9a2934cf added is mercurial method in utils,
Marcin Kuzminski <marcin@python-works.com>
parents: 93
diff changeset
12 """
f24b9a2934cf added is mercurial method in utils,
Marcin Kuzminski <marcin@python-works.com>
parents: 93
diff changeset
13 http_accept = environ.get('HTTP_ACCEPT')
f24b9a2934cf added is mercurial method in utils,
Marcin Kuzminski <marcin@python-works.com>
parents: 93
diff changeset
14 if http_accept and http_accept.startswith('application/mercurial'):
f24b9a2934cf added is mercurial method in utils,
Marcin Kuzminski <marcin@python-works.com>
parents: 93
diff changeset
15 return True
f24b9a2934cf added is mercurial method in utils,
Marcin Kuzminski <marcin@python-works.com>
parents: 93
diff changeset
16 return False