Exemple #1
0
    def process(self):
        """
        Process the request.
        
        Produce the data that needs to be displayed for any request
        handled by this browser. Currently, there is only one request
        handled by the meta browser.
        
        @return:  Http return code and data as a tuple.
        @rtype:   tuple
        
        """
        path = self.request.getRequestPath()[len(settings.PREFIX_STATIC) + 1:]
        if ".." in path:
            # Won't allow that
            return HTTP.BAD_REQUEST, "Invalid path specifier"
        if path.endswith("/"):
            path = path[:-1]

        try:
            fname = settings.get_root_dir() + settings.STATIC_LOCATION + path
            rfr = RawFileReader()
            data = rfr.readFile(fname)
            res = Result.ok(data)
            # Examine the extension of the filename to see if we can set the content
            # type based on any of them. If we set the content type here then the
            # request dispatcher will not attempt to call a render method on the
            # data we return.
            i = path.rfind(".")
            if i > -1:
                # Found an extension in the filename
                ext = path[i + 1:].lower()
                if ext in ["jpg", "png", "gif", "jpeg"]:
                    res.addHeader("Content-type", "image/%s" % ext)
            return res
        except (Exception, JavaException), e:
            return Result.notFound("Not found")
 def process(self):
     """
     Process the request.
     
     Produce the data that needs to be displayed for any request
     handled by this browser. Currently, there is only one request
     handled by the meta browser.
     
     @return:  Http return code and data as a tuple.
     @rtype:   tuple
     
     """
     path = self.request.getRequestPath()[len(settings.PREFIX_STATIC)+1:]
     if ".." in path:
         # Won't allow that
         return HTTP.BAD_REQUEST, "Invalid path specifier"
     if path.endswith("/"):
         path = path[:-1]
         
     try:
         fname = settings.get_root_dir()+settings.STATIC_LOCATION + path
         rfr   = RawFileReader()
         data  = rfr.readFile(fname)
         res   = Result.ok(data)
         # Examine the extension of the filename to see if we can set the content
         # type based on any of them. If we set the content type here then the
         # request dispatcher will not attempt to call a render method on the
         # data we return.
         i = path.rfind(".")
         if i > -1:
             # Found an extension in the filename
             ext = path[i+1:].lower()
             if ext in [ "jpg", "png", "gif", "jpeg" ]:
                 res.addHeader("Content-type", "image/%s" % ext)
         return res
     except (Exception, JavaException), e:
         return Result.notFound("Not found")
Exemple #3
0
def __get_component_dir():
    return settings.get_root_dir() + settings.CONF_LOCATION + "components/"
Exemple #4
0
 def _get_storage_location(self):
     return settings.get_root_dir()+self.storage_location
 def _get_storage_location(self):
     return settings.get_root_dir()+self.storage_location