def get_map():
    " This function returns mapper object for dispatcher "
    map = Mapper()
    # Add routes here
    urlmap(map, [
        ('/', 'controllers#index'),
        ('/write', 'controllers#write'),
        ('/read', 'controllers#read'),        
        ('/clean', 'controllers#clean'),
        ('/reset', 'controllers#reset')
    ])

    # Old style map connecting
    #map.connect('Route_name', '/route/url', controller='controllerName',
    #action='actionName')

    if DEBUG:
        r = [Route(None, '/{path_info:.*}',
              controller='noodles.utils.static',
              action='index',
              path=os.path.join(os.getcwd(), 'static'),
              auth=True)]

        map.extend(r, '/static')

    return map
示例#2
0
def get_map():
    " This function returns mapper object for dispatcher "
    map = Mapper()
    # Add routes here
    urlmap(map, [('/', 'controllers#index'), ('/write', 'controllers#write'),
                 ('/read', 'controllers#read'),
                 ('/clean', 'controllers#clean'),
                 ('/reset', 'controllers#reset')])

    # Old style map connecting
    #map.connect('Route_name', '/route/url', controller='controllerName',
    #action='actionName')

    if DEBUG:
        r = [
            Route(None,
                  '/{path_info:.*}',
                  controller='noodles.utils.static',
                  action='index',
                  path=os.path.join(os.getcwd(), 'static'),
                  auth=True)
        ]

        map.extend(r, '/static')

    return map
示例#3
0
def get_map():
    " This function returns mapper object for dispatcher "
    map = Mapper()
    # Add routes here
    urlmap(map, [
        ('/', 'controllers#index'),
        #('/route/url', 'controllerName.actionName')
    ])

    # Old style map connecting
    #map.connect('Route_name', '/route/url', controller='controllerName',
    #action='actionName')

    if DEBUG:
        r = [Route(None, '/{path_info:.*}',
              controller='noodles.utils.static',
              action='index',
              path=os.path.join(os.getcwd(), 'static'),
              auth=True)]

        map.extend(r, '/static')

        user = [
                Route(None, '/create',
                      controller='user_controller',
                      action='add_user'),
                Route(None, '/detail/:id',
                      controller='user_controller',
                      action='detail_user'),
                Route(None, '/list',
                      controller='user_controller',
                      action='list_users'),
                Route(None, '/delete/:id',
                      controller='user_controller',
                      action='delete_user'),
                Route(None, '/update/:id',
                      controller='user_controller',
                      action='update_user'),
                ]

        map.extend(user, '/user')

        article = [
                   Route(None, '/create',
                         controller='article_controller',
                         action='add_article'),
                   Route(None, '/read/:id',
                         controller='article_controller',
                         action='read'),
                   Route(None, '/list',
                         controller='article_controller',
                         action='list_articles'),
                   Route(None, '/delete/:id',
                         controller='article_controller',
                         action='delete_article'),
                   ]

        map.extend(article, '/article')

    return map
示例#4
0
def get_map():
    " This function returns mapper object for dispatcher "
    map = Mapper()
    # Add routes here
    urlmap(map, [

                ('/', 'controllers#index'),
                ('/static/{path_info:.*}','noodles.utils.static#index', {'path': os.path.join(os.getcwd(), 'static')})
                #('/route/url', 'controllerName.actionName')     
            ])

    # Old style map connecting 
    #map.connect('Route_name', '/route/url', controller='controllerName', action='actionName')


    return map
示例#5
0
def get_map():
    " This function returns mapper object for dispatcher "
    map = Mapper()
    # Add routes here
    urlmap(map, [

                ('/', 'controllers#index'),
                #a demonstration of long polling:
                ('/lp/{conn_info:.*}','controllers#TestSock.router'),

                ('/streamer/{conn_id}','controllers#streamer'),
                ('/static/{path_info:.*}', 'noodles.utils.static#index',{'path': os.path.join(os.getcwd(), 'static')}),

            ])

    # Old style map connecting
    #map.connect('Route_name', '/route/url', controller='controllerName', action='actionName')

    #map.connect(None, '/static/{path_info:.*}', controller='static', action='index',path='static'
    #)  # Handling static files

    return map
示例#6
0
def get_map():
    " This function returns mapper object for dispatcher "
    mp = Mapper()
    # Add routes here

    taskmaps = [
        (URL_PREFIX + '/s/{task:[\d\/]+}/commits', 'controllers#task_commits'),
        (URL_PREFIX + '/s/{task:[\d\/]+}/validate',
         'controllers#validate_save'),
        (URL_PREFIX + '/s/{task:[\d\/]+}/show_in_gantt',
         'controllers#show_in_gantt'),
        (URL_PREFIX + '/s/{task:[\d\/]+}/log', 'controllers#history'),
        (URL_PREFIX + '/s/{task:[\d\/]+}/j', 'controllers#journal'),
        (URL_PREFIX + '/s/{task:[\d\/]+}/j/{jid}', 'controllers#journal_edit'),
        (URL_PREFIX + '/s/{task:((new/|)[\d\/]+)}', 'controllers#task'),
        (URL_PREFIX + '/s/{task:([\d\/]+)}/c', 'controllers#task_changes'),
        (URL_PREFIX + '/s/{task:([\d\/]+)}/rev/{rev:.*}', 'controllers#task'),
    ]
    taskmaps += ([(t[0].replace('/s/', '/'), t[1]) for t in taskmaps])

    urlmap(
        mp,
        [
            (URL_PREFIX + '/s/new', 'controllers#task', {
                'task': 'new'
            }),  # new top level task handler
            (URL_PREFIX + '/commits/{repo:.*}/{rev:.*}',
             'controllers#commit_validity'),
            (URL_PREFIX + '/', 'controllers#index'),
            (URL_PREFIX + '/test', 'controllers#test'),
            (URL_PREFIX + '/tr', 'controllers#index', {
                'gethours': True
            }),
            (URL_PREFIX + '/karma', 'controllers#karma'),
            (URL_PREFIX + '/incoming', 'controllers#incoming'),
            (URL_PREFIX + '/incoming/{tags:.*}', 'controllers#incoming'),
            (URL_PREFIX + '/metastates', 'controllers#metastates'),
            (URL_PREFIX + '/metastates/tags-{tags:([^\/]*)}/{state:.*}',
             'controllers#metastate'),
            (URL_PREFIX + '/metastates/tags-{tags:([^\/]*)}',
             'controllers#metastates'),
            (URL_PREFIX + '/metastates/{state:.*}', 'controllers#metastate'),
            (URL_PREFIX + '/feed', 'controllers#feed'),
            (URL_PREFIX + '/feed/fs', 'controllers#feed_fs'),
            (URL_PREFIX + '/feed/{user}', 'controllers#feed'),
            (URL_PREFIX + '/feed/{user}/fs', 'controllers#feed_fs'),
            (URL_PREFIX + '/journal', 'controllers#global_journal'),
            (URL_PREFIX + '/journal/groupby/{groupby}',
             'controllers#global_journal'),
            (URL_PREFIX + '/metastate-set', 'controllers#metastate_set'),
            (URL_PREFIX + '/tl', 'controllers#top_level'),
            (URL_PREFIX + '/st', 'controllers#storage'),
            (URL_PREFIX + '/participants', 'controllers#participants'),
            (URL_PREFIX + '/tags', 'controllers#tags'),
            (URL_PREFIX + "/tag-pri", 'controllers#tag_pri'),
            (URL_PREFIX + '/tag/{tag}', 'controllers#bytag'),
            (URL_PREFIX + '/pri', 'controllers#prioritization'),

            # tasks go here.
            (URL_PREFIX + '/search', 'controllers#search'),
            (URL_PREFIX + '/favicon.ico', 'controllers#favicon'),
            (URL_PREFIX + '/assets/{r_type}/{r_file}', 'controllers#assets'),
            (URL_PREFIX + "/g", "controllers#gantt"),
            (URL_PREFIX + "/g/save", "controllers#gantt_save"),
            (URL_PREFIX + "/g/{tid:.*}", "controllers#gantt"),
            (URL_PREFIX + "/tt", "controllers#time_tracking_dashboard"),
            (URL_PREFIX + "/tt/{rangeback:.*}/{persons:.*}",
             "controllers#time_tracking_dashboard"),
            (URL_PREFIX + "/tt/{rangeback:.*}",
             "controllers#time_tracking_dashboard"),
            (URL_PREFIX + "/ttt", "controllers#time_tracking_dashboard", {
                'mode': 'tid'
            }),
            (URL_PREFIX + "/ttt/{rangeback:.*}/{tids:([\d\/,]+)}",
             "controllers#time_tracking_dashboard", {
                 'mode': 'tid'
             }),
        ])

    for tm in taskmaps:
        mp.connect(None,
                   tm[0],
                   controller=tm[1].split('#')[0],
                   action=tm[1].split('#')[1])

    for pf, gethours in list({'/tr': True, '': False}.items()):
        mp.connect(None,
                   URL_PREFIX + '/assignments/{person}' + pf,
                   controller='controllers',
                   action='assignments',
                   gethours=gethours)
        mp.connect(None,
                   URL_PREFIX + '/a/{person}' + pf,
                   controller='controllers',
                   action='assignments',
                   gethours=gethours)  # synonym to /assignments
        mp.connect(None,
                   URL_PREFIX + '/created/{person}' + pf,
                   controller='controllers',
                   action='created',
                   gethours=gethours),
        mp.connect(None,
                   URL_PREFIX + '/informed/{person}' + pf,
                   controller='controllers',
                   action='informed',
                   gethours=gethours),
        mp.connect(None,
                   URL_PREFIX + '/handled_by/{person}' + pf,
                   controller='controllers',
                   action='handled_by',
                   gethours=gethours),
        mp.connect(None,
                   URL_PREFIX + '/assignments/{person}/{mode}' + pf,
                   controller='controllers',
                   action='assignments_mode',
                   gethours=gethours)
        mp.connect(None,
                   URL_PREFIX + '/latest' + pf,
                   controller='controllers',
                   action='latest',
                   gethours=gethours),
        mp.connect(None,
                   URL_PREFIX + '/latest/{max_days}' + pf,
                   controller='controllers',
                   action='latest',
                   gethours=gethours)

    for msabbr, msgroup in list(METASTATE_URLS.items()):

        def mcnt(msabbr, mp):
            url = URL_PREFIX + '/' + msabbr
            # (URL_PREFIX+'/q', 'controllers#queue',{'assignee':'me'}),
            mp.connect(None,
                       url,
                       controller='controllers',
                       action='queue',
                       metastate_group=msgroup,
                       assignee='me')
            # (URL_PREFIX+'/q/archive', 'controllers#queue',{'assignee':'me','archive':True}),
            mp.connect(None,
                       url + '/archive',
                       controller='controllers',
                       action='queue',
                       assignee='me',
                       archive=True,
                       metastate_group=msgroup)
            # (URL_PREFIX+'/q/assignee/{assignee}', 'controllers#queue'),
            mp.connect(None,
                       url + '/assignee/{assignee}',
                       controller='controllers',
                       action='queue',
                       metastate_group=msgroup)
            # (URL_PREFIX+'/q/assignee/{assignee}/archive', 'controllers#queue',{'archive':True}),
            mp.connect(None,
                       url + '/assignee/{assignee}/archive',
                       controller='controllers',
                       action='queue',
                       metastate_group=msgroup,
                       archive=True)
            # (URL_PREFIX+'/q/all', 'controllers#queue'),
            mp.connect(None,
                       url + '/all',
                       controller='controllers',
                       action='queue',
                       metastate_group=msgroup)
            # (URL_PREFIX+'/q/all/archive', 'controllers#queue',{'archive':True}),
            mp.connect(None,
                       url + '/all/archive',
                       controller='controllers',
                       action='queue',
                       metastate_group=msgroup,
                       archive=True)
            return mp

        mp = mcnt(msabbr, mp)

    filters = ['day', 'creator', 'state']
    for flt in filters:
        url = URL_PREFIX + '/journal/filter'

        def mcnt(url, flt, mp, chain=[]):
            url += '/%s/{%s}' % (flt, flt)
            #print 'connecting',url
            mp.connect(None,
                       url,
                       controller='controllers',
                       action='global_journal')
            mp.connect(None,
                       url + '/groupby/{groupby}',
                       controller='controllers',
                       action='global_journal')
            chain.append(flt)
            for flt2 in filters:
                if flt2 not in chain:
                    mcnt(url, flt2, mp, chain)
            return mp

        mp = mcnt(url, flt, mp)

    return mp
示例#7
0
def get_map():
    " This function returns mapper object for dispatcher "
    mp = Mapper()
    # Add routes here

    urlmap(mp, [

        (URL_PREFIX+'/', 'controllers#index'),
        (URL_PREFIX+'/tr', 'controllers#index',{'gethours':True}),

        (URL_PREFIX+'/feed', 'controllers#feed'),
        (URL_PREFIX+'/feed/fs', 'controllers#feed_fs'),
        (URL_PREFIX+'/feed/{user}', 'controllers#feed'),
        (URL_PREFIX+'/feed/{user}/fs', 'controllers#feed_fs'),

        (URL_PREFIX+'/tracking/{rng}','controllers#tracking'),

        (URL_PREFIX+'/journal', 'controllers#global_journal'),
        (URL_PREFIX+'/journal/groupby/{groupby}', 'controllers#global_journal'),

        (URL_PREFIX+'/metastate-set','controllers#metastate_set'),

        (URL_PREFIX+'/tl', 'controllers#top_level'),
        (URL_PREFIX+'/st', 'controllers#storage'),
        (URL_PREFIX+'/iterations', 'controllers#iterations'),
        (URL_PREFIX+'/participants', 'controllers#participants'),
        (URL_PREFIX+'/tags', 'controllers#tags'),
        (URL_PREFIX+'/tag/{tag}', 'controllers#bytag'),
        (URL_PREFIX+'/s/{task:.*}/log','controllers#history'),
        (URL_PREFIX+'/s/{task:.*}/j','controllers#journal'),
        (URL_PREFIX+'/s/{task:.*}/j/{jid}','controllers#journal_edit'),
        (URL_PREFIX+'/s/{task:.*}','controllers#task'),

        (URL_PREFIX+'/{task:[\d\/]+}/log','controllers#history'),
        (URL_PREFIX+'/{task:[\d\/]+}/j','controllers#journal'),
        (URL_PREFIX+'/{task:[\d\/]+}/j/{jid}','controllers#journal_edit'),
        (URL_PREFIX+'/{task:[\d\/]+}','controllers#task'),


        (URL_PREFIX+'/repr/{task:.*}','controllers#rpr'),
        (URL_PREFIX+'/search','controllers#search'),
        (URL_PREFIX+'/favicon.ico', 'controllers#favicon'),
        (URL_PREFIX+'/assets/{r_type}/{r_file}', 'controllers#assets'),
    ])

    for pf,gethours in {'/tr':True,'':False}.items():
        mp.connect(None,URL_PREFIX+'/assignments/{person}'+pf, controller='controllers',action='assignments',gethours=gethours)
        mp.connect(None,URL_PREFIX+'/created/{person}'+pf, controller='controllers',action='created',gethours=gethours),
        mp.connect(None,URL_PREFIX+'/assignments/{person}/{mode}'+pf, controller='controllers',action='assignments_mode',gethours=gethours)
        mp.connect(None,URL_PREFIX+'/latest'+pf, controller='controllers',action='latest',gethours=gethours),
        mp.connect(None,URL_PREFIX+'/latest/{max_days}'+pf, controller='controllers',action='latest',gethours=gethours)
        
    for msabbr,msgroup in METASTATE_URLS.items():

        def mcnt(msabbr,mp):
            url = URL_PREFIX+'/'+msabbr
            # (URL_PREFIX+'/q', 'controllers#queue',{'assignee':'me'}),
            mp.connect(None,url,controller='controllers',action='queue',metastate_group=msgroup,assignee='me')
            # (URL_PREFIX+'/q/archive', 'controllers#queue',{'assignee':'me','archive':True}),
            mp.connect(None,url+'/archive',controller='controllers',action='queue',assignee='me',archive=True,metastate_group=msgroup)
            # (URL_PREFIX+'/q/assignee/{assignee}', 'controllers#queue'),
            mp.connect(None,url+'/assignee/{assignee}',controller='controllers',action='queue',metastate_group=msgroup)
            # (URL_PREFIX+'/q/assignee/{assignee}/archive', 'controllers#queue',{'archive':True}),
            mp.connect(None,url+'/assignee/{assignee}/archive',controller='controllers',action='queue',metastate_group=msgroup,archive=True)
            # (URL_PREFIX+'/q/all', 'controllers#queue'),
            mp.connect(None,url+'/all',controller='controllers',action='queue',metastate_group=msgroup)
            # (URL_PREFIX+'/q/all/archive', 'controllers#queue',{'archive':True}),
            mp.connect(None,url+'/all/archive',controller='controllers',action='queue',metastate_group=msgroup,archive=True)
            return mp

        mp = mcnt(msabbr,mp)

    filters = ['day','creator','state']
    for flt in filters:
        url = URL_PREFIX+'/journal/filter'
        def mcnt(url,flt,mp,chain=[]):
            url+='/%s/{%s}'%(flt,flt)
            print 'connecting',url
            mp.connect(None,url,controller='controllers',action='global_journal')
            mp.connect(None,url+'/groupby/{groupby}',controller='controllers',action='global_journal')
            chain.append(flt)
            for flt2 in filters:
                if flt2 not in chain:
                    mcnt(url,flt2,mp,chain)
            return mp
        mp = mcnt(url,flt,mp)


        
    return mp
示例#8
0
def get_map():
    " This function returns mapper object for dispatcher "
    m = Mapper()
    # Add routes here
    urlmap(m, [
        ('/', 'controllers#index'),
        ('/dns', 'controllers#dns'),
        ('/hosts', 'controllers#hosts'),
        ('/groups', 'controllers#groups'),
        ('/images', 'controllers#images'),
    ])
    cn = 'controllers'
    m.connect('/sleep/{seconds:[\d]+}', controller=cn, action='slp')
    m.connect("/dns/{domain}",
              controller=cn,
              action='new_dns_record',
              conditions=dict(method=['POST']))
    m.connect("/dns/{domain}",
              controller=cn,
              action='del_dns_record',
              conditions=dict(method=['DELETE']))
    m.connect('/sessions',
              controller=cn,
              action='sessions',
              conditions=dict(method=['GET']))
    m.connect('/sessions/{host}/{node}/{name}',
              controller=cn,
              action='kill_session',
              conditions=dict(method=['DELETE']))
    m.connect("/nodes",
              controller=cn,
              action='nodes',
              conditions=dict(method=['GET']))
    m.connect("/nodes",
              controller=cn,
              action='new_node',
              conditions=dict(method=['POST']))
    m.connect('/nodes/{host}',
              controller=cn,
              action='nodes',
              conditions=dict(method=['GET']))
    m.connect('/nodes/{host}',
              controller=cn,
              action='new_node',
              conditions=dict(method=['POST']))
    m.connect('/nodes/{host}/{node}',
              controller=cn,
              action='node',
              conditions=dict(method=['GET']))
    m.connect('/nodes/{host}/{node}',
              controller=cn,
              action='update_node',
              conditions=dict(method=['PUT']))
    m.connect('/nodes/{host}/{node}',
              controller=cn,
              action='delete_node',
              conditions=dict(method=['DELETE']))
    m.connect('/nodes/{host}/{node}',
              controller=cn,
              action='migrate_node',
              conditions=dict(method=['POST']))
    m.connect('/nodes/{host}/{node}/disk',
              controller=cn,
              action='enlarge_disk',
              conditions=dict(method=['PUT']))

    m.connect('/nodes/{host}/{node}/memory',
              controller=cn,
              action='memory',
              conditions=dict(method=['GET']))
    m.connect('/nodes/{host}/{node}/memory',
              controller=cn,
              action='memory_update',
              conditions=dict(method=['PUT']))

    m.connect('/nodes/{host}/{node}/pubkey',
              controller=cn,
              action='host_auth_list',
              conditions=dict(method=['GET']))
    m.connect('/nodes/{host}/{node}/pubkey',
              controller=cn,
              action='host_auth_add',
              conditions=dict(method=['POST']))

    m.connect('/openvpn/',
              controller=cn,
              action='openvpn_list',
              conditions=dict(method=['GET']))
    m.connect('/openvpn/all',
              controller=cn,
              action='openvpn_all',
              conditions=dict(method=['GET']))
    m.connect('/openvpn/status',
              controller=cn,
              action='openvpn_status',
              conditions=dict(method=['GET']))
    m.connect('/openvpn/ips',
              controller=cn,
              action='openvpn_ips',
              conditions=dict(method=['GET']))
    m.connect('/openvpn/',
              controller=cn,
              action='openvpn_add',
              conditions=dict(method=['POST']))
    return m