Changeset 5874
- Timestamp:
- 08/12/07 07:02:08 (1 year ago)
- Files:
-
- django/trunk/AUTHORS (modified) (1 diff)
- django/trunk/django/http/__init__.py (modified) (2 diffs)
- django/trunk/django/utils/datastructures.py (modified) (1 diff)
- django/trunk/tests/regressiontests/datastructures/tests.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/trunk/AUTHORS
r5868 r5874 102 102 Andy Dustman <farcepest@gmail.com> 103 103 Clint Ecker 104 eibaan@gmail.com 104 105 enlight 105 106 Enrico <rico.bl@gmail.com> django/trunk/django/http/__init__.py
r5873 r5874 3 3 from pprint import pformat 4 4 from urllib import urlencode 5 from django.utils.datastructures import MultiValueDict 5 from django.utils.datastructures import MultiValueDict, FileDict 6 6 from django.utils.encoding import smart_str, iri_to_uri, force_unicode 7 7 … … 89 89 # client's one.) 90 90 filename = name_dict['filename'][name_dict['filename'].rfind("\\")+1:] 91 FILES.appendlist(name_dict['name'], {91 FILES.appendlist(name_dict['name'], FileDict({ 92 92 'filename': filename, 93 93 'content-type': 'Content-Type' in submessage and submessage['Content-Type'] or None, 94 94 'content': submessage.get_payload(), 95 }) 95 })) 96 96 else: 97 97 POST.appendlist(name_dict['name'], submessage.get_payload()) django/trunk/django/utils/datastructures.py
r5091 r5874 268 268 except TypeError: # Special-case if current isn't a dict. 269 269 current = {bits[-1] : v} 270 271 class FileDict(dict): 272 """ 273 A dictionary used to hold uploaded file contents. The only special feature 274 here is that repr() of this object won't dump the entire contents of the 275 file to the output. A handy safeguard for a large file upload. 276 """ 277 def __repr__(self): 278 if 'content' in self: 279 d = dict(self, content='<omitted>') 280 return dict.__repr__(d) 281 return dict.__repr__(self) 282 django/trunk/tests/regressiontests/datastructures/tests.py
r5069 r5874 65 65 >>> d['person']['2']['firstname'] 66 66 ['Adrian'] 67 68 ### FileDict ################################################################ 69 70 >>> d = FileDict({'content': 'once upon a time...'}) 71 >>> repr(d) 72 "{'content': '<omitted>'}" 73 >>> d = FileDict({'other-key': 'once upon a time...'}) 74 >>> repr(d) 75 "{'other-key': 'once upon a time...'}" 67 76 """
