コード例 #1
0
ファイル: database.py プロジェクト: dreamyeah/DreamBlog
 def to_json(self):
     return dict(id=self.id,
                 title=self.title,
                 body=unicode(self.rendered_body),
                 create_time=http_date(self.create_time),
                 update_time=http_date(self.update_time),
                 comments=[c.to_json() for c in self.comments],
                 author=self.author.to_json(),
                 category=self.category.slug)
コード例 #2
0
ファイル: database.py プロジェクト: 365zph/flask-website
 def to_json(self):
     return dict(id=self.id, title=self.title,
                 body=unicode(self.rendered_body),
                 pub_date=http_date(self.pub_date),
                 comments=[c.to_json() for c in self.comments],
                 author=self.author.to_json(),
                 category=self.category.slug)
コード例 #3
0
    def set_required_headers(self):
        """Sets headers required for the ICAP response.

        Currently these set ISTag and Date headers.

        """
        self.response.headers['Date'] = http_date()
        self.response.headers['ISTag'] = self.is_tag
コード例 #4
0
    def set_required_headers(self):
        """Sets headers required for the ICAP response.

        Currently these set ISTag and Date headers.

        """
        self.response.headers['Date'] = http_date()
        self.response.headers['ISTag'] = self.is_tag
コード例 #5
0
ファイル: AttachFile.py プロジェクト: aahlad/soar
def _do_box(pagename, request):
    _ = request.getText

    pagename, filename, fpath = _access_file(pagename, request)
    if not request.user.may.read(pagename):
        return _('You are not allowed to get attachments from this page.')
    if not filename:
        return  # error msg already sent in _access_file

    timestamp = datetime.datetime.fromtimestamp(os.path.getmtime(fpath))
    if_modified = request.if_modified_since
    if if_modified and if_modified >= timestamp:
        request.status_code = 304
    else:
        ci = ContainerItem(request, pagename, filename)
        filename = wikiutil.taintfilename(request.values['member'])
        mt = wikiutil.MimeType(filename=filename)
        content_type = mt.content_type()
        mime_type = mt.mime_type()

        # TODO: fix the encoding here, plain 8 bit is not allowed according to the RFCs
        # There is no solution that is compatible to IE except stripping non-ascii chars
        filename_enc = filename.encode(config.charset)

        # for dangerous files (like .html), when we are in danger of cross-site-scripting attacks,
        # we just let the user store them to disk ('attachment').
        # For safe files, we directly show them inline (this also works better for IE).
        dangerous = mime_type in request.cfg.mimetypes_xss_protect
        content_dispo = dangerous and 'attachment' or 'inline'

        now = time.time()
        request.headers['Date'] = http_date(now)
        request.headers['Content-Type'] = content_type
        request.headers['Last-Modified'] = http_date(timestamp)
        request.headers['Expires'] = http_date(now - 365 * 24 * 3600)
        #request.headers['Content-Length'] = os.path.getsize(fpath)
        content_dispo_string = '%s; filename="%s"' % (content_dispo,
                                                      filename_enc)
        request.headers['Content-Disposition'] = content_dispo_string

        # send data
        request.send_file(ci.get(filename))
コード例 #6
0
ファイル: AttachFile.py プロジェクト: Glottotopia/aagd
def _do_box(pagename, request):
    _ = request.getText

    pagename, filename, fpath = _access_file(pagename, request)
    if not request.user.may.read(pagename):
        return _('You are not allowed to get attachments from this page.')
    if not filename:
        return # error msg already sent in _access_file

    timestamp = datetime.datetime.fromtimestamp(os.path.getmtime(fpath))
    if_modified = request.if_modified_since
    if if_modified and if_modified >= timestamp:
        request.status_code = 304
    else:
        ci = ContainerItem(request, pagename, filename)
        filename = wikiutil.taintfilename(request.values['member'])
        mt = wikiutil.MimeType(filename=filename)
        content_type = mt.content_type()
        mime_type = mt.mime_type()

        # TODO: fix the encoding here, plain 8 bit is not allowed according to the RFCs
        # There is no solution that is compatible to IE except stripping non-ascii chars
        filename_enc = filename.encode(config.charset)

        # for dangerous files (like .html), when we are in danger of cross-site-scripting attacks,
        # we just let the user store them to disk ('attachment').
        # For safe files, we directly show them inline (this also works better for IE).
        dangerous = mime_type in request.cfg.mimetypes_xss_protect
        content_dispo = dangerous and 'attachment' or 'inline'

        now = time.time()
        request.headers['Date'] = http_date(now)
        request.headers['Content-Type'] = content_type
        request.headers['Last-Modified'] = http_date(timestamp)
        request.headers['Expires'] = http_date(now - 365 * 24 * 3600)
        #request.headers['Content-Length'] = os.path.getsize(fpath)
        content_dispo_string = '%s; filename="%s"' % (content_dispo, filename_enc)
        request.headers['Content-Disposition'] = content_dispo_string

        # send data
        request.send_file(ci.get(filename))
コード例 #7
0
ファイル: database.py プロジェクト: 365zph/flask-website
 def to_json(self):
     return dict(author=self.author.to_json(),
                 title=self.title,
                 pub_date=http_date(self.pub_date),
                 text=unicode(self.rendered_text))
コード例 #8
0
 def to_json(self):
     return dict(author=self.author.to_json(),
                 title=self.title,
                 pub_date=http_date(self.pub_date),
                 text=unicode(self.rendered_text))
コード例 #9
0
ファイル: twitter.py プロジェクト: gmackie/umichdu
 def to_json(self):
     rv = vars(self).copy()
     rv['pub_date'] = http_date(rv['pub_date'])
     rv['via'] = unicode(rv['via'])
     return rv