From 93eebd95cb59f4c54779db1dc8c2c166a36400fa Mon Sep 17 00:00:00 2001 From: Adrian Holovaty Date: Sat, 20 Jan 2007 20:33:23 +0000 Subject: [PATCH] newforms: Moved flatatt function from widgets.py to util.py git-svn-id: http://code.djangoproject.com/svn/django/trunk@4370 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/newforms/forms.py | 4 ++-- django/newforms/util.py | 5 +++++ django/newforms/widgets.py | 6 +----- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/django/newforms/forms.py b/django/newforms/forms.py index 5964c9cc5e..1724a5a69f 100644 --- a/django/newforms/forms.py +++ b/django/newforms/forms.py @@ -5,8 +5,8 @@ Form classes from django.utils.datastructures import SortedDict, MultiValueDict from django.utils.html import escape from fields import Field -from widgets import flatatt, TextInput, Textarea, HiddenInput, MultipleHiddenInput -from util import StrAndUnicode, ErrorDict, ErrorList, ValidationError +from widgets import TextInput, Textarea, HiddenInput, MultipleHiddenInput +from util import flatatt, StrAndUnicode, ErrorDict, ErrorList, ValidationError __all__ = ('BaseForm', 'Form') diff --git a/django/newforms/util.py b/django/newforms/util.py index a78623a17b..2fec9e4e2e 100644 --- a/django/newforms/util.py +++ b/django/newforms/util.py @@ -1,4 +1,9 @@ from django.conf import settings +from django.utils.html import escape + +# Converts a dictionary to a single string with key="value", XML-style with +# a leading space. Assumes keys do not need to be XML-escaped. +flatatt = lambda attrs: u''.join([u' %s="%s"' % (k, escape(v)) for k, v in attrs.items()]) def smart_unicode(s): if not isinstance(s, basestring): diff --git a/django/newforms/widgets.py b/django/newforms/widgets.py index 4bbd02dc63..e18026485e 100644 --- a/django/newforms/widgets.py +++ b/django/newforms/widgets.py @@ -8,7 +8,7 @@ __all__ = ( 'Select', 'SelectMultiple', 'RadioSelect', 'CheckboxSelectMultiple', ) -from util import StrAndUnicode, smart_unicode +from util import flatatt, StrAndUnicode, smart_unicode from django.utils.datastructures import MultiValueDict from django.utils.html import escape from itertools import chain @@ -18,10 +18,6 @@ try: except NameError: from sets import Set as set # Python 2.3 fallback -# Converts a dictionary to a single string with key="value", XML-style with -# a leading space. Assumes keys do not need to be XML-escaped. -flatatt = lambda attrs: u''.join([u' %s="%s"' % (k, escape(v)) for k, v in attrs.items()]) - class Widget(object): is_hidden = False # Determines whether this corresponds to an .