Show More
@@ -1,4 +1,5 b'' | |||
|
1 | """Routes configuration | |
|
1 | """ | |
|
2 | Routes configuration | |
|
2 | 3 | |
|
3 | 4 | The more specific and detailed routes should be defined first so they |
|
4 | 5 | may take precedent over the more generic routes. For more information |
@@ -15,24 +16,28 b' def make_map(config):' | |||
|
15 | 16 | map.minimization = False |
|
16 | 17 | map.explicit = False |
|
17 | 18 | |
|
19 | def check_repo(environ, match_dict): | |
|
20 | """ | |
|
21 | check for valid repository for proper 404 handling | |
|
22 | :param environ: | |
|
23 | :param match_dict: | |
|
24 | """ | |
|
25 | repo_name = match_dict.get('repo_name') | |
|
26 | return not cr(repo_name, config['base_path']) | |
|
27 | ||
|
18 | 28 | # The ErrorController route (handles 404/500 error pages); it should |
|
19 | 29 | # likely stay at the top, ensuring it can always be resolved |
|
20 | 30 | map.connect('/error/{action}', controller='error') |
|
21 | 31 | map.connect('/error/{action}/{id}', controller='error') |
|
22 | 32 | |
|
33 | #========================================================================== | |
|
23 | 34 | # CUSTOM ROUTES HERE |
|
35 | #========================================================================== | |
|
36 | ||
|
37 | #MAIN PAGE | |
|
24 | 38 | map.connect('hg_home', '/', controller='hg', action='index') |
|
25 | 39 | |
|
26 | def check_repo(environ, match_dict): | |
|
27 | """ | |
|
28 | check for valid repository for proper 404 handling | |
|
29 | @param environ: | |
|
30 | @param match_dict: | |
|
31 | """ | |
|
32 | repo_name = match_dict.get('repo_name') | |
|
33 | return not cr(repo_name, config['base_path']) | |
|
34 | ||
|
35 | #REST REPO MAP | |
|
40 | #ADMIN REPOSITORY REST ROUTES | |
|
36 | 41 | with map.submapper(path_prefix='/_admin', controller='admin/repos') as m: |
|
37 | 42 | m.connect("repos", "/repos", |
|
38 | 43 | action="create", conditions=dict(method=["POST"])) |
@@ -68,10 +73,13 b' def make_map(config):' | |||
|
68 | 73 | action="delete_perm_user", conditions=dict(method=["DELETE"], |
|
69 | 74 | function=check_repo)) |
|
70 | 75 | |
|
76 | #ADMIN USER REST ROUTES | |
|
71 | 77 | map.resource('user', 'users', controller='admin/users', path_prefix='/_admin') |
|
78 | ||
|
79 | #ADMIN PERMISSIONS REST ROUTES | |
|
72 | 80 | map.resource('permission', 'permissions', controller='admin/permissions', path_prefix='/_admin') |
|
73 | 81 | |
|
74 | #REST SETTINGS MAP | |
|
82 | #ADMIN SETTINGS REST ROUTES | |
|
75 | 83 | with map.submapper(path_prefix='/_admin', controller='admin/settings') as m: |
|
76 | 84 | m.connect("admin_settings", "/settings", |
|
77 | 85 | action="create", conditions=dict(method=["POST"])) |
@@ -102,7 +110,7 b' def make_map(config):' | |||
|
102 | 110 | m.connect("admin_settings_create_repository", "/create_repository", |
|
103 | 111 | action="create_repository", conditions=dict(method=["GET"])) |
|
104 | 112 | |
|
105 | #ADMIN | |
|
113 | #ADMIN MAIN PAGES | |
|
106 | 114 | with map.submapper(path_prefix='/_admin', controller='admin/admin') as m: |
|
107 | 115 | m.connect('admin_home', '', action='index')#main page |
|
108 | 116 | m.connect('admin_add_repo', '/add_repo/{new_repo:[a-z0-9\. _-]*}', |
@@ -126,7 +134,7 b' def make_map(config):' | |||
|
126 | 134 | conditions=dict(function=check_repo)) |
|
127 | 135 | |
|
128 | 136 | |
|
129 | #OTHERS | |
|
137 | #REPOSITORY ROUTES | |
|
130 | 138 | map.connect('changeset_home', '/{repo_name:.*}/changeset/{revision}', |
|
131 | 139 | controller='changeset', revision='tip', |
|
132 | 140 | conditions=dict(function=check_repo)) |
@@ -193,7 +193,7 b' class ReposController(BaseController):' | |||
|
193 | 193 | def delete_perm_user(self, repo_name): |
|
194 | 194 | """ |
|
195 | 195 | DELETE an existing repository permission user |
|
196 |
|
|
|
196 | :param repo_name: | |
|
197 | 197 | """ |
|
198 | 198 | |
|
199 | 199 | try: |
@@ -66,7 +66,7 b' class PasswordGenerator(object):' | |||
|
66 | 66 | |
|
67 | 67 | def get_crypt_password(password): |
|
68 | 68 | """Cryptographic function used for password hashing based on sha1 |
|
69 |
|
|
|
69 | :param password: password to hash | |
|
70 | 70 | """ |
|
71 | 71 | return bcrypt.hashpw(password, bcrypt.gensalt(10)) |
|
72 | 72 | |
@@ -120,7 +120,7 b' def set_available_permissions(config):' | |||
|
120 | 120 | permission given in db. We don't wannt to check each time from db for new |
|
121 | 121 | permissions since adding a new permission also requires application restart |
|
122 | 122 | ie. to decorate new views with the newly created permission |
|
123 |
|
|
|
123 | :param config: | |
|
124 | 124 | """ |
|
125 | 125 | log.info('getting information about all available permissions') |
|
126 | 126 | try: |
@@ -138,7 +138,7 b' def fill_data(user):' | |||
|
138 | 138 | """ |
|
139 | 139 | Fills user data with those from database and log out user if not present |
|
140 | 140 | in database |
|
141 |
|
|
|
141 | :param user: | |
|
142 | 142 | """ |
|
143 | 143 | sa = meta.Session |
|
144 | 144 | dbuser = sa.query(User).get(user.user_id) |
@@ -156,7 +156,7 b' def fill_data(user):' | |||
|
156 | 156 | def fill_perms(user): |
|
157 | 157 | """ |
|
158 | 158 | Fills user permission attribute with permissions taken from database |
|
159 |
|
|
|
159 | :param user: | |
|
160 | 160 | """ |
|
161 | 161 | |
|
162 | 162 | sa = meta.Session |
@@ -228,7 +228,7 b' def fill_perms(user):' | |||
|
228 | 228 | def get_user(session): |
|
229 | 229 | """ |
|
230 | 230 | Gets user from session, and wraps permissions into user |
|
231 |
|
|
|
231 | :param session: | |
|
232 | 232 | """ |
|
233 | 233 | user = session.get('rhodecode_user', AuthUser()) |
|
234 | 234 | if user.is_authenticated: |
@@ -28,8 +28,8 b' from webhelpers.text import chop_at, col' | |||
|
28 | 28 | class _Link(object): |
|
29 | 29 | ''' |
|
30 | 30 | Make a url based on label and url with help of url_for |
|
31 |
|
|
|
32 |
|
|
|
31 | :param label:name of link if not defined url is used | |
|
32 | :param url: the url for link | |
|
33 | 33 | ''' |
|
34 | 34 | |
|
35 | 35 | def __call__(self, label='', *url_, **urlargs): |
@@ -52,8 +52,8 b' get_error = _GetError()' | |||
|
52 | 52 | def recursive_replace(str, replace=' '): |
|
53 | 53 | """ |
|
54 | 54 | Recursive replace of given sign to just one instance |
|
55 |
|
|
|
56 |
|
|
|
55 | :param str: given string | |
|
56 | :param replace:char to find and replace multiple instances | |
|
57 | 57 | |
|
58 | 58 | Examples:: |
|
59 | 59 | >>> recursive_replace("Mighty---Mighty-Bo--sstones",'-') |
@@ -72,7 +72,7 b' class _ToolTip(object):' | |||
|
72 | 72 | """ |
|
73 | 73 | Special function just to wrap our text into nice formatted autowrapped |
|
74 | 74 | text |
|
75 |
|
|
|
75 | :param tooltip_title: | |
|
76 | 76 | """ |
|
77 | 77 | |
|
78 | 78 | return wrap_paragraphs(escape(tooltip_title), trim_at)\ |
@@ -226,7 +226,7 b' class CodeHtmlFormatter(HtmlFormatter):' | |||
|
226 | 226 | def pygmentize(filenode, **kwargs): |
|
227 | 227 | """ |
|
228 | 228 | pygmentize function using pygments |
|
229 |
|
|
|
229 | :param filenode: | |
|
230 | 230 | """ |
|
231 | 231 | return literal(code_highlight(filenode.content, |
|
232 | 232 | filenode.lexer, CodeHtmlFormatter(**kwargs))) |
@@ -234,7 +234,7 b' def pygmentize(filenode, **kwargs):' | |||
|
234 | 234 | def pygmentize_annotation(filenode, **kwargs): |
|
235 | 235 | """ |
|
236 | 236 | pygmentize function for annotation |
|
237 |
|
|
|
237 | :param filenode: | |
|
238 | 238 | """ |
|
239 | 239 | |
|
240 | 240 | color_dict = {} |
@@ -53,9 +53,9 b' def repo_size(ui, repo, hooktype=None, *' | |||
|
53 | 53 | def user_action_mapper(ui, repo, hooktype=None, **kwargs): |
|
54 | 54 | """ |
|
55 | 55 | Maps user last push action to new changeset id, from mercurial |
|
56 |
|
|
|
57 |
|
|
|
58 |
|
|
|
56 | :param ui: | |
|
57 | :param repo: | |
|
58 | :param hooktype: | |
|
59 | 59 | """ |
|
60 | 60 | |
|
61 | 61 | try: |
@@ -115,8 +115,8 b' class ResultWrapper(object):' | |||
|
115 | 115 | Smart function that implements chunking the content |
|
116 | 116 | but not overlap chunks so it doesn't highlight the same |
|
117 | 117 | close occurrences twice. |
|
118 |
|
|
|
119 |
|
|
|
118 | :param matcher: | |
|
119 | :param size: | |
|
120 | 120 | """ |
|
121 | 121 | memory = [(0, 0)] |
|
122 | 122 | for span in self.matcher.spans(): |
@@ -109,8 +109,8 b' class DaemonLock(object):' | |||
|
109 | 109 | def makelock(self, lockname, pidfile): |
|
110 | 110 | """ |
|
111 | 111 | this function will make an actual lock |
|
112 |
|
|
|
113 |
|
|
|
112 | :param lockname: acctual pid of file | |
|
113 | :param pidfile: the file to write the pid in | |
|
114 | 114 | """ |
|
115 | 115 | if self.debug: |
|
116 | 116 | print 'creating a file %s and pid: %s' % (pidfile, lockname) |
@@ -108,7 +108,7 b' class SmtpMailer(object):' | |||
|
108 | 108 | ''' |
|
109 | 109 | Get content based on type, if content is a string do open first |
|
110 | 110 | else just read because it's a probably open file object |
|
111 |
|
|
|
111 | :param msg_file: | |
|
112 | 112 | ''' |
|
113 | 113 | if isinstance(msg_file, str): |
|
114 | 114 | return open(msg_file, "rb").read() |
@@ -49,6 +49,18 b' def is_mercurial(environ):' | |||
|
49 | 49 | return True |
|
50 | 50 | return False |
|
51 | 51 | |
|
52 | def is_git(environ): | |
|
53 | """ | |
|
54 | Returns True if request's target is git server. ``HTTP_USER_AGENT`` would | |
|
55 | then have git client version given. | |
|
56 | ||
|
57 | :param environ: | |
|
58 | """ | |
|
59 | http_user_agent = environ.get('HTTP_USER_AGENT') | |
|
60 | if http_user_agent.startswith('git'): | |
|
61 | return True | |
|
62 | return False | |
|
63 | ||
|
52 | 64 | def action_logger(user, action, repo, ipaddr, sa=None): |
|
53 | 65 | """ |
|
54 | 66 | Action logger for various action made by users |
@@ -191,9 +203,9 b" def make_ui(read_from='file', path=None," | |||
|
191 | 203 | A function that will read python rc files or database |
|
192 | 204 | and make an mercurial ui object from read options |
|
193 | 205 | |
|
194 |
|
|
|
195 |
|
|
|
196 |
|
|
|
206 | :param path: path to mercurial config file | |
|
207 | :param checkpaths: check the path | |
|
208 | :param read_from: read from 'file' or 'db' | |
|
197 | 209 | """ |
|
198 | 210 | |
|
199 | 211 | baseui = ui.ui() |
@@ -421,8 +433,8 b' class OrderedDict(dict, DictMixin):' | |||
|
421 | 433 | #=============================================================================== |
|
422 | 434 | def create_test_index(repo_location, full_index): |
|
423 | 435 | """Makes default test index |
|
424 |
|
|
|
425 |
|
|
|
436 | :param repo_location: | |
|
437 | :param full_index: | |
|
426 | 438 | """ |
|
427 | 439 | from rhodecode.lib.indexers.daemon import WhooshIndexingDaemon |
|
428 | 440 | from rhodecode.lib.pidlock import DaemonLock, LockHeld |
General Comments 0
You need to be logged in to leave comments.
Login now