Ticket #7020: lists-to-tuples.diff

File lists-to-tuples.diff, 4.3 KB (added by Piotr Lewandowski <django@…>, 16 years ago)
  • django/oldforms/__init__.py

     
    953953        if match is not None:
    954954            import re
    955955            match_re = re.compile(match)
    956         choices = not is_required and BLANK_CHOICE_DASH[:] or []
     956        choices = not is_required and [BLANK_CHOICE_DASH] or []
    957957        if recursive:
    958958            for root, dirs, files in os.walk(path):
    959959                for f in files:
  • django/db/models/fields/__init__.py

     
    2828HORIZONTAL, VERTICAL = 1, 2
    2929
    3030# The values to use for "blank" in SelectFields. Will be appended to the start of most "choices" lists.
    31 BLANK_CHOICE_DASH = [("", "---------")]
    32 BLANK_CHOICE_NONE = [("", "None")]
     31BLANK_CHOICE_DASH = ("", "---------")
     32BLANK_CHOICE_NONE = ("", "None")
    3333
    3434# prepares a value for use in a LIKE query
    3535prep_for_like_query = lambda x: smart_unicode(x).replace("\\", "\\\\").replace("%", "\%").replace("_", "\_")
     
    345345            val = None
    346346        return val
    347347
    348     def get_choices(self, include_blank=True, blank_choice=BLANK_CHOICE_DASH):
     348    def get_choices(self, include_blank=True, blank_choice=[BLANK_CHOICE_DASH]):
    349349        "Returns a list of tuples used as SelectField choices for this field."
    350350        first_choice = include_blank and blank_choice or []
    351351        if self.choices:
     
    359359
    360360    def get_choices_default(self):
    361361        if self.radio_admin:
    362             return self.get_choices(include_blank=self.blank, blank_choice=BLANK_CHOICE_NONE)
     362            return self.get_choices(include_blank=self.blank, blank_choice=[BLANK_CHOICE_NONE])
    363363        else:
    364364            return self.get_choices()
    365365
  • django/utils/_decimal.py

     
    370370    """
    371371
    372372# List of public traps and flags
    373 _signals = [Clamped, DivisionByZero, Inexact, Overflow, Rounded,
    374            Underflow, InvalidOperation, Subnormal]
     373_signals = (Clamped, DivisionByZero, Inexact, Overflow, Rounded,
     374           Underflow, InvalidOperation, Subnormal)
    375375
    376376# Map conditions (per the spec) to signals
    377377_condition_map = {ConversionSyntax:InvalidOperation,
     
    21642164
    21652165
    21662166# get rounding method function:
    2167 rounding_functions = [name for name in Decimal.__dict__.keys() if name.startswith('_round_')]
    2168 for name in rounding_functions:
     2167for name in Decimal.__dict__.iterkeys():
     2168    if not name.startswith('_round_'):
     2169        continue
    21692170    #name is like _round_half_even, goes to the global ROUND_HALF_EVEN value.
    21702171    globalname = name[1:].upper()
    21712172    val = globals()[globalname]
    21722173    Decimal._pick_rounding_function[val] = name
    21732174
    2174 del name, val, globalname, rounding_functions
     2175del name, val, globalname
    21752176
    21762177class Context(object):
    21772178    """Contains the context for a Decimal instance.
  • django/utils/html.py

     
    99from django.utils.http import urlquote
    1010
    1111# Configuration for urlize() function.
    12 LEADING_PUNCTUATION  = ['(', '<', '&lt;']
    13 TRAILING_PUNCTUATION = ['.', ',', ')', '>', '\n', '&gt;']
     12LEADING_PUNCTUATION  = ('(', '<', '&lt;')
     13TRAILING_PUNCTUATION = ('.', ',', ')', '>', '\n', '&gt;')
    1414
    1515# List of possible strings used for bullets in bulleted lists.
    16 DOTS = ['&middot;', '*', '\xe2\x80\xa2', '&#149;', '&bull;', '&#8226;']
     16DOTS = ('&middot;', '*', '\xe2\x80\xa2', '&#149;', '&bull;', '&#8226;')
    1717
    1818unencoded_ampersands_re = re.compile(r'&(?!(\w+|#\d+);)')
    1919word_split_re = re.compile(r'(\s+)')
  • django/utils/simplejson/decoder.py

     
    183183    return values, end
    184184pattern(r'\[')(JSONArray)
    185185 
    186 ANYTHING = [
     186ANYTHING = (
    187187    JSONObject,
    188188    JSONArray,
    189189    JSONString,
    190190    JSONConstant,
    191191    JSONNumber,
    192 ]
     192)
    193193
    194194JSONScanner = Scanner(ANYTHING)
    195195
Back to Top