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