Changeset 6211
- Timestamp:
- 09/14/07 14:55:24 (8 months ago)
- Files:
-
- django/trunk/AUTHORS (modified) (1 diff)
- django/trunk/django/core/management/validation.py (modified) (2 diffs)
- django/trunk/django/http/__init__.py (modified) (1 diff)
- django/trunk/django/template/__init__.py (modified) (2 diffs)
- django/trunk/django/test/client.py (modified) (2 diffs)
- django/trunk/django/utils/itercompat.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/trunk/AUTHORS
r6202 r6211 264 264 smurf@smurf.noris.de 265 265 sopel 266 Leo Soto <leo.soto@gmail.com> 266 267 Wiliam Alves de Souza <wiliamsouza83@gmail.com> 267 268 Georgi Stanojevski <glisha@gmail.com> django/trunk/django/core/management/validation.py
r5898 r6211 1 1 import sys 2 2 from django.core.management.color import color_style 3 from django.utils.itercompat import is_iterable 3 4 4 5 class ModelErrorCollection: … … 52 53 e.add(opts, '"%s": prepopulate_from should be a list or tuple.' % f.name) 53 54 if f.choices: 54 if not hasattr(f.choices, '__iter__'): 55 if isinstance(f.choices, basestring) or \ 56 not is_iterable(f.choices): 55 57 e.add(opts, '"%s": "choices" should be iterable (e.g., a tuple or list).' % f.name) 56 58 else: django/trunk/django/http/__init__.py
r6167 r6211 305 305 306 306 def __iter__(self): 307 self._iterator = self._container.__iter__()307 self._iterator = iter(self._container) 308 308 return self 309 309 django/trunk/django/template/__init__.py
r5630 r6211 59 59 from django.conf import settings 60 60 from django.template.context import Context, RequestContext, ContextPopException 61 from django.utils.itercompat import is_iterable 61 62 from django.utils.functional import curry, Promise 62 63 from django.utils.text import smart_split … … 901 902 if not getattr(self, 'nodelist', False): 902 903 from django.template.loader import get_template, select_template 903 if hasattr(file_name, '__iter__'):904 if not isinstance(file_name, basestring) and is_iterable(file_name): 904 905 t = select_template(file_name) 905 906 else: django/trunk/django/test/client.py
r6039 r6211 17 17 from django.utils.encoding import smart_str 18 18 from django.utils.http import urlencode 19 from django.utils.itercompat import is_iterable 19 20 20 21 BOUNDARY = 'BoUnDaRyStRiNg' … … 75 76 value.read() 76 77 ]) 77 elif hasattr(value, '__iter__'): 78 for item in value: 78 else: 79 if not isinstance(value, basestring) and is_iterable(value): 80 for item in value: 81 lines.extend([ 82 '--' + boundary, 83 'Content-Disposition: form-data; name="%s"' % to_str(key), 84 '', 85 to_str(item) 86 ]) 87 else: 79 88 lines.extend([ 80 89 '--' + boundary, 81 90 'Content-Disposition: form-data; name="%s"' % to_str(key), 82 91 '', 83 to_str( item)92 to_str(value) 84 93 ]) 85 else:86 lines.extend([87 '--' + boundary,88 'Content-Disposition: form-data; name="%s"' % to_str(key),89 '',90 to_str(value)91 ])92 94 93 95 lines.extend([ django/trunk/django/utils/itercompat.py
r5526 r6211 58 58 if hasattr(itertools, 'groupby'): 59 59 groupby = itertools.groupby 60 61 def is_iterable(x): 62 "A implementation independent way of checking for iterables" 63 try: 64 iter(x) 65 except TypeError: 66 return False 67 else: 68 return True 69
