#!/usr/bin/env python import cherrypy from dm.common.service.dmSessionController import DmSessionController from dm.ds_web_service.service.impl.userInfoSessionControllerImpl import UserInfoSessionControllerImpl class UserInfoSessionController(DmSessionController): def __init__(self): DmSessionController.__init__(self) self.userInfoSessionControllerImpl = UserInfoSessionControllerImpl() @cherrypy.expose @DmSessionController.require(DmSessionController.isLoggedIn()) @DmSessionController.execute def getUsers(self, **kwargs): return self.listToJson(self.userInfoSessionControllerImpl.getUsers()) @cherrypy.expose @DmSessionController.require(DmSessionController.isLoggedIn()) @DmSessionController.execute def getUserById(self, id, **kwargs): if not id: raise InvalidRequest('Invalid id provided.') response = self.userInfoSessionControllerImpl.getUserById(id).getFullJsonRep() self.logger.debug('Returning user info for %s: %s' % (id,response)) return response @cherrypy.expose @DmSessionController.require(DmSessionController.isLoggedIn()) @DmSessionController.execute def getUserByUsername(self, username, **kwargs): if not len(username): raise InvalidRequest('Invalid username provided.') response = self.userInfoSessionControllerImpl.getUserByUsername(username).getFullJsonRep() self.logger.debug('Returning user info for %s: %s' % (username,response)) return response