#!/usr/bin/env python # # Route mapper for file system service. # ####################################################################### import sys import os import cherrypy from dm.common.utility import loggingManager from dm.fs_service.service.fsController import FsController ####################################################################### def setupRoutes(): """ Setup RESTFul routes. """ # Static instances shared between different routes fsController = FsController() # Define routes. # Make sure to have leading '/' for consistency. routes = [ # ('GET') routes do not require authorization. # ('PUT', 'POST', 'DELETE') routes require authorization. # # FS Controller routes # # Get directory listing { 'name' : 'getDirectoryList', 'path' : '/directory/list', 'controller' : fsController, 'action' : 'getDirectoryList', 'method' : ['GET'] }, ] # Add routes to dispatcher. d = cherrypy.dispatch.RoutesDispatcher() logger = loggingManager.getLogger('setupRoutes') for route in routes: logger.debug('Connecting route: %s' % route) d.connect(route['name'], route['path'], action=route['action'], controller=route['controller'], conditions=dict(method=route['method'])) return d