def download(self, request, db, chunk_size=DEFAULT_CHUNK_SIZE, attachment=True, download_filename=None):
        """
        Example of usage in controller::

            def download():
                return response.download(request, db)

        Downloads from http://..../download/filename
        """

        current.session.forget(current.response)

        if not request.args:
            raise HTTP(404)
        name = request.args[-1]
        items = re.compile('(?P<table>.*?)\.(?P<field>.*?)\..*').match(name)
        if not items:
            raise HTTP(404)
        (t, f) = (items.group('table'), items.group('field'))
        try:
            field = db[t][f]
        except AttributeError:
            raise HTTP(404)
        try:
            (filename, stream) = field.retrieve(name,nameonly=True)
        except IOError:
            raise HTTP(404)
        headers = self.headers
        headers['Content-Type'] = contenttype(name)
        if download_filename == None:
            download_filename = filename
        if attachment:
            headers['Content-Disposition'] = \
                download_filename.replace('"','\"') % 'attachment; filename="%s"'
        return self.stream(stream, chunk_size=chunk_size, request=request)
dataset/ETHPy150Open uwdata/termite-data-server/web2py/gluon/globals.py/Response.download/swapped operands of `%`