Changeset - 5cc96df705b9
[Not reviewed]
default
0 9 0
Marcin Kuzminski - 15 years ago 2010-10-18 03:04:58
marcin@python-works.com
fixed @repo into :repo for docs
fixed routes descriptions
9 files changed with 60 insertions and 40 deletions:
0 comments (0 inline, 0 general)
rhodecode/config/routing.py
Show inline comments
 
"""Routes configuration
 
"""
 
Routes configuration
 

	
 
The more specific and detailed routes should be defined first so they
 
may take precedent over the more generic routes. For more information
 
@@ -15,24 +16,28 @@ def make_map(config):
 
    map.minimization = False
 
    map.explicit = False
 

	
 
    def check_repo(environ, match_dict):
 
        """
 
        check for valid repository for proper 404 handling
 
        :param environ:
 
        :param match_dict:
 
        """
 
        repo_name = match_dict.get('repo_name')
 
        return not cr(repo_name, config['base_path'])
 

	
 
    # The ErrorController route (handles 404/500 error pages); it should
 
    # likely stay at the top, ensuring it can always be resolved
 
    map.connect('/error/{action}', controller='error')
 
    map.connect('/error/{action}/{id}', controller='error')
 

	
 
    #==========================================================================
 
    # CUSTOM ROUTES HERE
 
    #==========================================================================
 

	
 
    #MAIN PAGE
 
    map.connect('hg_home', '/', controller='hg', action='index')
 
    
 
    def check_repo(environ, match_dict):
 
        """
 
        check for valid repository for proper 404 handling
 
        @param environ:
 
        @param match_dict:
 
        """
 
        repo_name = match_dict.get('repo_name')
 
        return not cr(repo_name, config['base_path'])
 
 
 
    #REST REPO MAP
 
    #ADMIN REPOSITORY REST ROUTES
 
    with map.submapper(path_prefix='/_admin', controller='admin/repos') as m:
 
        m.connect("repos", "/repos",
 
             action="create", conditions=dict(method=["POST"]))
 
@@ -68,10 +73,13 @@ def make_map(config):
 
             action="delete_perm_user", conditions=dict(method=["DELETE"],
 
                                                        function=check_repo))
 
        
 
    #ADMIN USER REST ROUTES
 
    map.resource('user', 'users', controller='admin/users', path_prefix='/_admin')
 

	
 
    #ADMIN PERMISSIONS REST ROUTES
 
    map.resource('permission', 'permissions', controller='admin/permissions', path_prefix='/_admin')
 
    
 
    #REST SETTINGS MAP
 
    #ADMIN SETTINGS REST ROUTES
 
    with map.submapper(path_prefix='/_admin', controller='admin/settings') as m:
 
        m.connect("admin_settings", "/settings",
 
             action="create", conditions=dict(method=["POST"]))
 
@@ -102,7 +110,7 @@ def make_map(config):
 
        m.connect("admin_settings_create_repository", "/create_repository",
 
             action="create_repository", conditions=dict(method=["GET"]))
 
    
 
    #ADMIN
 
    #ADMIN MAIN PAGES
 
    with map.submapper(path_prefix='/_admin', controller='admin/admin') as m:
 
        m.connect('admin_home', '', action='index')#main page
 
        m.connect('admin_add_repo', '/add_repo/{new_repo:[a-z0-9\. _-]*}',
 
@@ -126,7 +134,7 @@ def make_map(config):
 
                conditions=dict(function=check_repo))
 
    
 
    
 
    #OTHERS
 
    #REPOSITORY ROUTES
 
    map.connect('changeset_home', '/{repo_name:.*}/changeset/{revision}',
 
                controller='changeset', revision='tip',
 
                conditions=dict(function=check_repo))
rhodecode/controllers/admin/repos.py
Show inline comments
 
@@ -193,7 +193,7 @@ class ReposController(BaseController):
 
    def delete_perm_user(self, repo_name):
 
        """
 
        DELETE an existing repository permission user
 
        @param repo_name:
 
        :param repo_name:
 
        """
 
        
 
        try:
rhodecode/lib/auth.py
Show inline comments
 
@@ -66,7 +66,7 @@ class PasswordGenerator(object):
 
    
 
def get_crypt_password(password):
 
    """Cryptographic function used for password hashing based on sha1
 
    @param password: password to hash
 
    :param password: password to hash
 
    """    
 
    return bcrypt.hashpw(password, bcrypt.gensalt(10))
 

	
 
@@ -120,7 +120,7 @@ def set_available_permissions(config):
 
    permission given in db. We don't wannt to check each time from db for new 
 
    permissions since adding a new permission also requires application restart
 
    ie. to decorate new views with the newly created permission
 
    @param config:
 
    :param config:
 
    """
 
    log.info('getting information about all available permissions')
 
    try:
 
@@ -138,7 +138,7 @@ def fill_data(user):
 
    """
 
    Fills user data with those from database and log out user if not present
 
    in database
 
    @param user:
 
    :param user:
 
    """
 
    sa = meta.Session
 
    dbuser = sa.query(User).get(user.user_id)
 
@@ -156,7 +156,7 @@ def fill_data(user):
 
def fill_perms(user):
 
    """
 
    Fills user permission attribute with permissions taken from database
 
    @param user:
 
    :param user:
 
    """
 
    
 
    sa = meta.Session
 
@@ -228,7 +228,7 @@ def fill_perms(user):
 
def get_user(session):
 
    """
 
    Gets user from session, and wraps permissions into user
 
    @param session:
 
    :param session:
 
    """
 
    user = session.get('rhodecode_user', AuthUser())
 
    if user.is_authenticated:
rhodecode/lib/helpers.py
Show inline comments
 
@@ -28,8 +28,8 @@ from webhelpers.text import chop_at, col
 
class _Link(object):
 
    '''
 
    Make a url based on label and url with help of url_for
 
    @param label:name of link    if not defined url is used
 
    @param url: the url for link
 
    :param label:name of link    if not defined url is used
 
    :param url: the url for link
 
    '''
 

	
 
    def __call__(self, label='', *url_, **urlargs):
 
@@ -52,8 +52,8 @@ get_error = _GetError()
 
def recursive_replace(str, replace=' '):
 
    """
 
    Recursive replace of given sign to just one instance
 
    @param str: given string
 
    @param replace:char to find and replace multiple instances
 
    :param str: given string
 
    :param replace:char to find and replace multiple instances
 
        
 
    Examples::
 
    >>> recursive_replace("Mighty---Mighty-Bo--sstones",'-')
 
@@ -72,7 +72,7 @@ class _ToolTip(object):
 
        """
 
        Special function just to wrap our text into nice formatted autowrapped
 
        text
 
        @param tooltip_title:
 
        :param tooltip_title:
 
        """
 
        
 
        return wrap_paragraphs(escape(tooltip_title), trim_at)\
 
@@ -226,7 +226,7 @@ class CodeHtmlFormatter(HtmlFormatter):
 
def pygmentize(filenode, **kwargs):
 
    """
 
    pygmentize function using pygments
 
    @param filenode:
 
    :param filenode:
 
    """
 
    return literal(code_highlight(filenode.content,
 
                                  filenode.lexer, CodeHtmlFormatter(**kwargs)))
 
@@ -234,7 +234,7 @@ def pygmentize(filenode, **kwargs):
 
def pygmentize_annotation(filenode, **kwargs):
 
    """
 
    pygmentize function for annotation
 
    @param filenode:
 
    :param filenode:
 
    """
 
    
 
    color_dict = {}
rhodecode/lib/hooks.py
Show inline comments
 
@@ -53,9 +53,9 @@ def repo_size(ui, repo, hooktype=None, *
 
def user_action_mapper(ui, repo, hooktype=None, **kwargs):
 
    """
 
    Maps user last push action to new changeset id, from mercurial
 
    @param ui:
 
    @param repo:
 
    @param hooktype:
 
    :param ui:
 
    :param repo:
 
    :param hooktype:
 
    """
 
    
 
    try:
rhodecode/lib/indexers/__init__.py
Show inline comments
 
@@ -115,8 +115,8 @@ class ResultWrapper(object):
 
        Smart function that implements chunking the content
 
        but not overlap chunks so it doesn't highlight the same
 
        close occurrences twice.
 
        @param matcher:
 
        @param size:
 
        :param matcher:
 
        :param size:
 
        """
 
        memory = [(0, 0)]
 
        for span in self.matcher.spans():
rhodecode/lib/pidlock.py
Show inline comments
 
@@ -109,8 +109,8 @@ class DaemonLock(object):
 
    def makelock(self, lockname, pidfile):
 
        """
 
        this function will make an actual lock
 
        @param lockname: acctual pid of file
 
        @param pidfile: the file to write the pid in
 
        :param lockname: acctual pid of file
 
        :param pidfile: the file to write the pid in
 
        """
 
        if self.debug:
 
            print 'creating a file %s and pid: %s' % (pidfile, lockname)
rhodecode/lib/smtp_mailer.py
Show inline comments
 
@@ -108,7 +108,7 @@ class SmtpMailer(object):
 
        '''
 
        Get content based on type, if content is a string do open first
 
        else just read because it's a probably open file object
 
        @param msg_file:
 
        :param msg_file:
 
        '''
 
        if isinstance(msg_file, str):
 
            return open(msg_file, "rb").read()
rhodecode/lib/utils.py
Show inline comments
 
@@ -49,6 +49,18 @@ def is_mercurial(environ):
 
        return True
 
    return False
 

	
 
def is_git(environ):
 
    """
 
    Returns True if request's target is git server. ``HTTP_USER_AGENT`` would
 
    then have git client version given.
 
    
 
    :param environ:
 
    """
 
    http_user_agent = environ.get('HTTP_USER_AGENT')
 
    if http_user_agent.startswith('git'):
 
        return True
 
    return False
 

	
 
def action_logger(user, action, repo, ipaddr, sa=None):
 
    """
 
    Action logger for various action made by users
 
@@ -191,9 +203,9 @@ def make_ui(read_from='file', path=None,
 
    A function that will read python rc files or database
 
    and make an mercurial ui object from read options
 
    
 
    @param path: path to mercurial config file
 
    @param checkpaths: check the path
 
    @param read_from: read from 'file' or 'db'
 
    :param path: path to mercurial config file
 
    :param checkpaths: check the path
 
    :param read_from: read from 'file' or 'db'
 
    """
 

	
 
    baseui = ui.ui()
 
@@ -421,8 +433,8 @@ class OrderedDict(dict, DictMixin):
 
#===============================================================================
 
def create_test_index(repo_location, full_index):
 
    """Makes default test index
 
    @param repo_location:
 
    @param full_index:
 
    :param repo_location:
 
    :param full_index:
 
    """
 
    from rhodecode.lib.indexers.daemon import WhooshIndexingDaemon
 
    from rhodecode.lib.pidlock import DaemonLock, LockHeld
0 comments (0 inline, 0 general)