Пример #1
0
    def __init__(self, rootpath, bundle, filenames, ignores):
        # Let FileApp determine content_type and encoding based on bundlename.
        FileApp.__init__(self, bundle)

        self.filenames = []
        for filename in filenames:
            fullpath = os.path.join(rootpath, filename)
            if not os.path.normpath(fullpath).startswith(rootpath):
                # Raising forbidden here would expose private information.
                raise webob.exc.HTTPNotFound()  # pragma: no cover
            if not os.path.exists(fullpath):
                raise webob.exc.HTTPNotFound()
            self.filenames.append(fullpath)
Пример #2
0
    def __init__(self, rootpath, bundle, filenames, ignores):
        # Let FileApp determine content_type and encoding based on bundlename.
        FileApp.__init__(self, bundle)

        self.filenames = []
        for filename in filenames:
            fullpath = os.path.join(rootpath, filename)
            if not os.path.normpath(fullpath).startswith(rootpath):
                # Raising forbidden here would expose private information.
                raise webob.exc.HTTPNotFound()  # pragma: no cover
            if not os.path.exists(fullpath):
                raise webob.exc.HTTPNotFound()
            self.filenames.append(fullpath)
Пример #3
0
    def __init__(self, path, digest, filename=None):
        h = {}
        if not filename is None:
            (type, encoding) = mimetypes.guess_type(filename)
            if not type is None:
                h['Content-Type'] = type
            #if not encoding is None:
            #    h['Content-Encoding'] = encoding
        expires = datetime.datetime.now() + datetime.timedelta(seconds = int(config['app_conf']['expires.archive.file']))
        h['Expires'] = wsgiref.handlers.format_date_time( time.mktime( expires.timetuple() ))
        h['Cache-Control'] = 'public, max-age=%d'%int(config['app_conf']['expires.archive.file'])

        FileApp.__init__(self, path, **h)

        self.digest = digest