print "</div>"
send_footer()
- def send_raw(self, mimetype='text/plain'):
- if self.can_read():
- body = self.get_raw_body()
- emit_header(mimetype)
- print body
- else:
+ def send_raw(self, mimetype='text/plain', args=[]):
+ if not self.can_read():
send_title(None, msg_text='Read access denied by ACLs', msg_type='notice')
+ return
- def send_image(self, mimetype, args=[]):
if 'maxwidth' in args:
import subprocess
emit_header(mimetype)
subprocess.check_call(['gm', 'convert', self._filename(),
'-scale', args['maxwidth'].value + ' >', '-'])
else:
- self.send_raw(mimetype)
+ body = self.get_raw_body()
+ emit_header(mimetype)
+ print body
def _write_file(self, data):
tmp_filename = self._tmp_filename()
else:
query = query_string()
if file_re.match(query):
- if word_re.match(query):
- Page(query).format()
+ # FIMXE: this is all bullshit, MimeTypes bases its guess on the extension!
+ from mimetypes import MimeTypes
+ mimetype, encoding = MimeTypes().guess_type(query)
+ if mimetype:
+ Page(query).send_raw(mimetype=mimetype, args=form)
else:
- from mimetypes import MimeTypes
- mimetype, encoding = MimeTypes().guess_type(query)
- if mimetype:
- if mimetype.startswith('image/'):
- Page(query).send_image(mimetype=mimetype, args=form)
- else:
- Page(query).send_raw(mimetype=mimetype)
- else:
- Page(query).format()
+ Page(query).format()
else:
send_httperror("403 Forbidden", query)