# HG changeset patch # User paulb # Date 1193520424 0 # Node ID 6fba3c12b7b02b6cbe32be5ddd2dc942947df0db # Parent 8493f3954a9c1a4847d4f8db60a2e3be81419153 [project @ 2007-10-27 21:27:04 by paulb] Show only the first few bytes in uploaded files. diff -r 8493f3954a9c -r 6fba3c12b7b0 examples/Common/Form/__init__.py --- a/examples/Common/Form/__init__.py Sat Oct 27 21:26:46 2007 +0000 +++ b/examples/Common/Form/__init__.py Sat Oct 27 21:27:04 2007 +0000 @@ -136,9 +136,17 @@ # Detect uploads. if type(value) not in (type(""), type(u"")): - value = "%s: %s" % (value.headers.get("content-type") or "No content type", repr(str(value))) + value.stream.reset() + details = "%s of length %s: %s" % ( + value.headers.get("content-type") or "No content type", + value.headers.get("content-length") or "Unknown", + repr(value.stream.read(20)) + ) + else: + details = value - l2.append("
  • %s
  • " % (value.replace("&", "&").replace("<", "<").replace(">", ">") or "empty")) + l2.append("
  • %s
  • " % (details.replace("&", "&").replace("<", "<").replace(">", ">") or "empty")) + return "".join(l2) # vim: tabstop=4 expandtab shiftwidth=4