Esempio n. 1
0
class FileSystemController(CdbController):
    def __init__(self):
        CdbController.__init__(self)
        self.fileSystemControllerImpl = FileSystemControllerImpl()

    @cherrypy.expose
    @CdbController.execute
    def getDirectoryList(self, directoryName, **kwargs):
        if not len(directoryName):
            raise InvalidRequest('Invalid directory name.')
        if not kwargs.has_key('parentDirectory'):
            raise InvalidRequest('Missing parent directory.')
        parentDirectory = kwargs.get('parentDirectory')
        path = '%s/%s' % (parentDirectory, directoryName)
        response = self.fileSystemControllerImpl.getDirectoryList(
            path).getFullJsonRep()
        self.logger.debug('Returning path for %s: %s' % (path, response))
        return response
class FileSystemSessionController(CdbSessionController):
    def __init__(self):
        CdbSessionController.__init__(self)
        self.fileSystemControllerImpl = FileSystemControllerImpl()

    @cherrypy.expose
    @CdbSessionController.require(CdbSessionController.isLoggedIn())
    @CdbSessionController.execute
    def writeFile(self, fileName, **kwargs):
        if not kwargs.has_key('parentDirectory'):
            raise InvalidRequest('Missing parent directory.')
        parentDirectory = kwargs.get('parentDirectory')
        encodedFileContent = kwargs.get('encodedFileContent', '')
        fileContent = Encoder.decode(encodedFileContent)
        filePath = '%s/%s' % (parentDirectory, fileName)
        response = '%s' % self.fileSystemControllerImpl.writeFile(
            filePath, fileContent).getFullJsonRep()
        self.logger.debug('Returning: %s' % response)
        return response
Esempio n. 3
0
 def __init__(self):
     CdbController.__init__(self)
     self.fileSystemControllerImpl = FileSystemControllerImpl()