Show More
@@ -65,7 +65,7 b' class SummaryController(BaseRepoControll' | |||||
65 | def index(self, repo_name): |
|
65 | def index(self, repo_name): | |
66 |
|
66 | |||
67 | e = request.environ |
|
67 | e = request.environ | |
68 |
c.dbrepo = dbrepo = |
|
68 | c.dbrepo = dbrepo = c.rhodecode_db_repo | |
69 |
|
69 | |||
70 | c.following = self.scm_model.is_following_repo(repo_name, |
|
70 | c.following = self.scm_model.is_following_repo(repo_name, | |
71 | self.rhodecode_user.user_id) |
|
71 | self.rhodecode_user.user_id) |
@@ -83,19 +83,32 b' def str2bool(_str):' | |||||
83 | return _str in ('t', 'true', 'y', 'yes', 'on', '1') |
|
83 | return _str in ('t', 'true', 'y', 'yes', 'on', '1') | |
84 |
|
84 | |||
85 |
|
85 | |||
86 |
def convert_line_endings( |
|
86 | def convert_line_endings(line, mode): | |
|
87 | """ | |||
|
88 | Converts a given line "line end" accordingly to given mode | |||
|
89 | ||||
|
90 | Available modes are:: | |||
|
91 | 0 - Unix | |||
|
92 | 1 - Mac | |||
|
93 | 2 - DOS | |||
|
94 | ||||
|
95 | :param line: given line to convert | |||
|
96 | :param mode: mode to convert to | |||
|
97 | :rtype: str | |||
|
98 | :return: converted line according to mode | |||
|
99 | """ | |||
87 | from string import replace |
|
100 | from string import replace | |
88 | #modes: 0 - Unix, 1 - Mac, 2 - DOS |
|
101 | ||
89 | if mode == 0: |
|
102 | if mode == 0: | |
90 |
|
|
103 | line = replace(line, '\r\n', '\n') | |
91 |
|
|
104 | line = replace(line, '\r', '\n') | |
92 | elif mode == 1: |
|
105 | elif mode == 1: | |
93 |
|
|
106 | line = replace(line, '\r\n', '\r') | |
94 |
|
|
107 | line = replace(line, '\n', '\r') | |
95 | elif mode == 2: |
|
108 | elif mode == 2: | |
96 | import re |
|
109 | import re | |
97 |
|
|
110 | line = re.sub("\r(?!\n)|(?<!\r)\n", "\r\n", line) | |
98 |
return |
|
111 | return line | |
99 |
|
112 | |||
100 |
|
113 | |||
101 | def detect_mode(line, default): |
|
114 | def detect_mode(line, default): | |
@@ -254,13 +267,13 b' def age(curdate):' | |||||
254 | return _(u'just now') |
|
267 | return _(u'just now') | |
255 |
|
268 | |||
256 |
|
269 | |||
257 | def credentials_hidder(uri): |
|
270 | def uri_filter(uri): | |
258 | """ |
|
271 | """ | |
259 | Removes user:password from given url string |
|
272 | Removes user:password from given url string | |
260 |
|
273 | |||
261 | :param uri: |
|
274 | :param uri: | |
262 | :rtype: unicode |
|
275 | :rtype: unicode | |
263 |
:returns: filtered list of strings |
|
276 | :returns: filtered list of strings | |
264 | """ |
|
277 | """ | |
265 | if not uri: |
|
278 | if not uri: | |
266 | return '' |
|
279 | return '' | |
@@ -284,3 +297,19 b' def credentials_hidder(uri):' | |||||
284 | host, port = uri[:cred_pos], uri[cred_pos + 1:] |
|
297 | host, port = uri[:cred_pos], uri[cred_pos + 1:] | |
285 |
|
298 | |||
286 | return filter(None, [proto, host, port]) |
|
299 | return filter(None, [proto, host, port]) | |
|
300 | ||||
|
301 | ||||
|
302 | def credentials_filter(uri): | |||
|
303 | """ | |||
|
304 | Returns a url with removed credentials | |||
|
305 | ||||
|
306 | :param uri: | |||
|
307 | """ | |||
|
308 | ||||
|
309 | uri = uri_filter(uri) | |||
|
310 | #check if we have port | |||
|
311 | if len(uri) > 2 and uri[2]: | |||
|
312 | uri[2] = ':' + uri[2] | |||
|
313 | ||||
|
314 | return ''.join(uri) | |||
|
315 |
@@ -2,8 +2,11 b'' | |||||
2 |
|
2 | |||
3 | Provides the BaseController class for subclassing. |
|
3 | Provides the BaseController class for subclassing. | |
4 | """ |
|
4 | """ | |
5 | from pylons import config, tmpl_context as c, request, session |
|
5 | import logging | |
|
6 | ||||
|
7 | from pylons import config, tmpl_context as c, request, session, url | |||
6 | from pylons.controllers import WSGIController |
|
8 | from pylons.controllers import WSGIController | |
|
9 | from pylons.controllers.util import redirect | |||
7 | from pylons.templating import render_mako as render |
|
10 | from pylons.templating import render_mako as render | |
8 |
|
11 | |||
9 | from rhodecode import __version__ |
|
12 | from rhodecode import __version__ | |
@@ -14,6 +17,7 b' from rhodecode.model.scm import ScmModel' | |||||
14 | from rhodecode import BACKENDS |
|
17 | from rhodecode import BACKENDS | |
15 | from rhodecode.model.db import Repository |
|
18 | from rhodecode.model.db import Repository | |
16 |
|
19 | |||
|
20 | log = logging.getLogger(__name__) | |||
17 |
|
21 | |||
18 | class BaseController(WSGIController): |
|
22 | class BaseController(WSGIController): | |
19 |
|
23 | |||
@@ -63,13 +67,16 b' class BaseRepoController(BaseController)' | |||||
63 | super(BaseRepoController, self).__before__() |
|
67 | super(BaseRepoController, self).__before__() | |
64 | if c.repo_name: |
|
68 | if c.repo_name: | |
65 |
|
69 | |||
66 |
c.rhodecode_repo = Repository.by_repo_name(c.repo_name) |
|
70 | c.rhodecode_db_repo = Repository.by_repo_name(c.repo_name) | |
|
71 | c.rhodecode_repo = c.rhodecode_db_repo.scm_instance | |||
|
72 | ||||
|
73 | if c.rhodecode_repo is None: | |||
|
74 | log.error('%s this repository is present in database but it ' | |||
|
75 | 'cannot be created as an scm instance', c.repo_name) | |||
67 |
|
76 | |||
68 | if c.rhodecode_repo is not None: |
|
77 | redirect(url('home')) | |
69 | c.repository_followers = \ |
|
|||
70 | self.scm_model.get_followers(c.repo_name) |
|
|||
71 | c.repository_forks = self.scm_model.get_forks(c.repo_name) |
|
|||
72 | else: |
|
|||
73 | c.repository_followers = 0 |
|
|||
74 | c.repository_forks = 0 |
|
|||
75 |
|
78 | |||
|
79 | c.repository_followers = \ | |||
|
80 | self.scm_model.get_followers(c.repo_name) | |||
|
81 | c.repository_forks = self.scm_model.get_forks(c.repo_name) | |||
|
82 |
@@ -321,7 +321,7 b' flash = _Flash()' | |||||
321 | # SCM FILTERS available via h. |
|
321 | # SCM FILTERS available via h. | |
322 | #============================================================================== |
|
322 | #============================================================================== | |
323 | from vcs.utils import author_name, author_email |
|
323 | from vcs.utils import author_name, author_email | |
324 |
from rhodecode.lib import credentials_ |
|
324 | from rhodecode.lib import credentials_filter, age as _age | |
325 |
|
325 | |||
326 | age = lambda x:_age(x) |
|
326 | age = lambda x:_age(x) | |
327 | capitalize = lambda x: x.capitalize() |
|
327 | capitalize = lambda x: x.capitalize() | |
@@ -329,7 +329,7 b' email = author_email' | |||||
329 | email_or_none = lambda x: email(x) if email(x) != x else None |
|
329 | email_or_none = lambda x: email(x) if email(x) != x else None | |
330 | person = lambda x: author_name(x) |
|
330 | person = lambda x: author_name(x) | |
331 | short_id = lambda x: x[:12] |
|
331 | short_id = lambda x: x[:12] | |
332 |
hide_credentials = lambda x: ''.join(credentials_ |
|
332 | hide_credentials = lambda x: ''.join(credentials_filter(x)) | |
333 |
|
333 | |||
334 | def bool2icon(value): |
|
334 | def bool2icon(value): | |
335 | """Returns True/False values represented as small html image of true/false |
|
335 | """Returns True/False values represented as small html image of true/false |
@@ -112,7 +112,11 b' class CachedRepoList(object):' | |||||
112 | continue |
|
112 | continue | |
113 |
|
113 | |||
114 |
|
114 | |||
115 |
|
115 | if not scmr: | ||
|
116 | log.error('%s this repository is present in database but it ' | |||
|
117 | 'cannot be created as an scm instance', | |||
|
118 | dbr.repo_name) | |||
|
119 | continue | |||
116 |
|
120 | |||
117 |
|
121 | |||
118 | last_change = scmr.last_change |
|
122 | last_change = scmr.last_change |
@@ -140,8 +140,8 b' logview.pylons.util = #eee' | |||||
140 | ######################################################### |
|
140 | ######################################################### | |
141 | ### DB CONFIGS - EACH DB WILL HAVE IT'S OWN CONFIG ### |
|
141 | ### DB CONFIGS - EACH DB WILL HAVE IT'S OWN CONFIG ### | |
142 | ######################################################### |
|
142 | ######################################################### | |
143 |
|
|
143 | sqlalchemy.db1.url = sqlite:///%(here)s/test.db | |
144 | sqlalchemy.db1.url = postgresql://postgres:qwe@localhost/rhodecode_tests |
|
144 | #sqlalchemy.db1.url = postgresql://postgres:qwe@localhost/rhodecode_tests | |
145 | #sqlalchemy.db1.echo = False |
|
145 | #sqlalchemy.db1.echo = False | |
146 | #sqlalchemy.db1.pool_recycle = 3600 |
|
146 | #sqlalchemy.db1.pool_recycle = 3600 | |
147 | sqlalchemy.convert_unicode = true |
|
147 | sqlalchemy.convert_unicode = true | |
@@ -171,6 +171,18 b' handlers = console' | |||||
171 | qualname = routes.middleware |
|
171 | qualname = routes.middleware | |
172 | # "level = DEBUG" logs the route matched and routing variables. |
|
172 | # "level = DEBUG" logs the route matched and routing variables. | |
173 |
|
173 | |||
|
174 | [logger_beaker] | |||
|
175 | level = DEBUG | |||
|
176 | handlers = | |||
|
177 | qualname = beaker.container | |||
|
178 | propagate = 1 | |||
|
179 | ||||
|
180 | [logger_templates] | |||
|
181 | level = INFO | |||
|
182 | handlers = | |||
|
183 | qualname = pylons.templating | |||
|
184 | propagate = 1 | |||
|
185 | ||||
174 | [logger_rhodecode] |
|
186 | [logger_rhodecode] | |
175 | level = ERROR |
|
187 | level = ERROR | |
176 | handlers = console |
|
188 | handlers = console |
General Comments 0
You need to be logged in to leave comments.
Login now