Ticket #12746: key.diff
File key.diff, 5.5 KB (added by , 15 years ago) |
---|
-
django/forms/formsets.py
191 191 # A sort function to order things numerically ascending, but 192 192 # None should be sorted below anything else. Allowing None as 193 193 # a comparison value makes it so we can leave ordering fields 194 # blamk. 195 def compare_ordering_values(x, y): 196 if x[1] is None: 197 return 1 198 if y[1] is None: 199 return -1 200 return x[1] - y[1] 201 self._ordering.sort(compare_ordering_values) 194 # blank. 195 def compare_ordering_key(k): 196 if k[1] is None: 197 return (1, 0) # +infinity, larger than any number 198 return (0, k[1]) 199 self._ordering.sort(key=compare_ordering_key) 202 200 # Return a list of form.cleaned_data dicts in the order spcified by 203 201 # the form data. 204 202 return [self.forms[i[0]] for i in self._ordering] -
django/forms/forms.py
34 34 Also integrates any additional media definitions 35 35 """ 36 36 fields = [(field_name, attrs.pop(field_name)) for field_name, obj in attrs.items() if isinstance(obj, Field)] 37 fields.sort( lambda x, y: cmp(x[1].creation_counter, y[1].creation_counter))37 fields.sort(key=lambda x: x[1].creation_counter) 38 38 39 39 # If this class is subclassing another Form, add that Form's fields. 40 40 # Note that we loop over the bases in *reverse*. This is necessary in -
django/contrib/admin/options.py
498 498 499 499 # Convert the actions into a SortedDict keyed by name 500 500 # and sorted by description. 501 actions.sort( lambda a,b: cmp(a[2].lower(), b[2].lower()))501 actions.sort(key=lambda k: k[2].lower()) 502 502 actions = SortedDict([ 503 503 (name, (func, name, desc)) 504 504 for func, name, desc in actions -
django/contrib/admin/sites.py
378 378 379 379 # Sort the apps alphabetically. 380 380 app_list = app_dict.values() 381 app_list.sort( lambda x, y: cmp(x['name'], y['name']))381 app_list.sort(key=lambda x: x['name']) 382 382 383 383 # Sort the models alphabetically within each app. 384 384 for app in app_list: 385 app['models'].sort( lambda x, y: cmp(x['name'], y['name']))385 app['models'].sort(key=lambda x: x['name']) 386 386 387 387 context = { 388 388 'title': _('Site administration'), … … 442 442 if not app_dict: 443 443 raise http.Http404('The requested admin page does not exist.') 444 444 # Sort the models alphabetically within each app. 445 app_dict['models'].sort( lambda x, y: cmp(x['name'], y['name']))445 app_dict['models'].sort(key=lambda x: x['name']) 446 446 context = { 447 447 'title': _('%s administration') % capfirst(app_label), 448 448 'app_list': [app_dict], -
django/contrib/databrowse/plugins/calendars.py
60 60 def homepage_view(self, request): 61 61 easy_model = EasyModel(self.site, self.model) 62 62 field_list = self.fields.values() 63 field_list.sort( lambda x, y: cmp(x.verbose_name, y.verbose_name))63 field_list.sort(key=lambda k:k.verbose_name) 64 64 return render_to_response('databrowse/calendar_homepage.html', {'root_url': self.site.root_url, 'model': easy_model, 'field_list': field_list}) 65 65 66 66 def calendar_view(self, request, field, year=None, month=None, day=None): -
django/contrib/databrowse/plugins/fieldchoices.py
61 61 def homepage_view(self, request): 62 62 easy_model = EasyModel(self.site, self.model) 63 63 field_list = self.fields.values() 64 field_list.sort( lambda x, y: cmp(x.verbose_name, y.verbose_name))64 field_list.sort(key=lambda k: k.verbose_name) 65 65 return render_to_response('databrowse/fieldchoice_homepage.html', {'root_url': self.site.root_url, 'model': easy_model, 'field_list': field_list}) 66 66 67 67 def field_view(self, request, field, value=None): -
django/utils/translation/trans_real.py
507 507 return [] 508 508 priority = priority and float(priority) or 1.0 509 509 result.append((lang, priority)) 510 result.sort( lambda x, y: -cmp(x[1], y[1]))510 result.sort(key=lambda k: k[1], reverse=True) 511 511 return result 512 512 513 513 # get_date_formats and get_partial_date_formats aren't used anymore by Django