Changeset 5062
- Timestamp:
- 04/23/07 11:16:27 (1 year ago)
- Files:
-
- django/branches/boulder-oracle-sprint/AUTHORS (modified) (3 diffs)
- django/branches/boulder-oracle-sprint/django/contrib/auth/models.py (modified) (1 diff)
- django/branches/boulder-oracle-sprint/django/newforms/fields.py (modified) (2 diffs)
- django/branches/boulder-oracle-sprint/django/template/defaultfilters.py (modified) (2 diffs)
- django/branches/boulder-oracle-sprint/django/template/defaulttags.py (modified) (3 diffs)
- django/branches/boulder-oracle-sprint/django/utils/datastructures.py (modified) (1 diff)
- django/branches/boulder-oracle-sprint/django/views/debug.py (modified) (4 diffs)
- django/branches/boulder-oracle-sprint/docs/distributions.txt (modified) (1 diff)
- django/branches/boulder-oracle-sprint/docs/generic_views.txt (modified) (1 diff)
- django/branches/boulder-oracle-sprint/tests/regressiontests/templates/tests.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/branches/boulder-oracle-sprint/AUTHORS
r5047 r5062 79 79 Alex Dedul 80 80 deric@monowerks.com 81 Max Derkachev <mderk@yandex.ru> 81 82 dne@mayonnaise.net 82 83 Maximillian Dornseif <md@hudora.de> … … 114 115 Baurzhan Ismagulov <ibr@radix50.net> 115 116 jcrasta@gmail.com 117 Zak Johnson <zakj@nox.cx> 116 118 Michael Josephson <http://www.sdjournal.com/> 117 119 jpellerin@gmail.com … … 181 183 remco@diji.biz 182 184 rhettg@gmail.com 185 Armin Ronacher 183 186 Oliver Rutherfurd <http://rutherfurd.net/> 184 187 Ivan Sagalaev (Maniac) <http://www.softwaremaniacs.org/> django/branches/boulder-oracle-sprint/django/contrib/auth/models.py
r4990 r5062 274 274 275 275 def __str__(self): 276 return 'AnonymousUser'276 return _('AnonymousUser') 277 277 278 278 def __eq__(self, other): django/branches/boulder-oracle-sprint/django/newforms/fields.py
r4935 r5062 333 333 334 334 class ChoiceField(Field): 335 def __init__(self, choices=(), required=True, widget=Select, label=None, initial=None, help_text=None): 335 widget = Select 336 337 def __init__(self, choices=(), required=True, widget=None, label=None, initial=None, help_text=None): 336 338 super(ChoiceField, self).__init__(required, widget, label, initial, help_text) 337 339 self.choices = choices … … 365 367 class MultipleChoiceField(ChoiceField): 366 368 hidden_widget = MultipleHiddenInput 367 368 def __init__(self, choices=(), required=True, widget=SelectMultiple, label=None, initial=None, help_text=None): 369 super(MultipleChoiceField, self).__init__(choices, required, widget, label, initial, help_text) 369 widget = SelectMultiple 370 370 371 371 def clean(self, value): django/branches/boulder-oracle-sprint/django/template/defaultfilters.py
r4722 r5062 3 3 from django.template import resolve_variable, Library 4 4 from django.conf import settings 5 from django.utils.translation import gettext 5 from django.utils.translation import gettext, ngettext 6 6 import re 7 7 import random as random_module … … 518 518 519 519 if bytes < 1024: 520 return "%d byte%s" % (bytes, bytes != 1 and 's' or '')520 return ngettext("%(size)d byte", "%(size)d bytes", bytes) % {'size': bytes} 521 521 if bytes < 1024 * 1024: 522 return "%.1f KB"% (bytes / 1024)522 return gettext("%.1f KB") % (bytes / 1024) 523 523 if bytes < 1024 * 1024 * 1024: 524 return "%.1f MB"% (bytes / (1024 * 1024))525 return "%.1f GB"% (bytes / (1024 * 1024 * 1024))524 return gettext("%.1f MB") % (bytes / (1024 * 1024)) 525 return gettext("%.1f GB") % (bytes / (1024 * 1024 * 1024)) 526 526 527 527 def pluralize(value, arg='s'): django/branches/boulder-oracle-sprint/django/template/defaulttags.py
r4935 r5062 42 42 output = self.nodelist.render(context) 43 43 # apply filters 44 return self.filter_expr.resolve(Context({'var': output})) 44 context.update({'var': output}) 45 filtered = self.filter_expr.resolve(context) 46 context.pop() 47 return filtered 45 48 46 49 class FirstOfNode(Node): … … 991 994 Add a value to the context (inside of this block) for caching and easy 992 995 access. 993 996 994 997 For example:: 995 998 … … 1000 1003 bits = list(token.split_contents()) 1001 1004 if len(bits) != 4 or bits[2] != "as": 1002 raise TemplateSyntaxError, "%r expected format is 'value as name'" % tagname1005 raise TemplateSyntaxError, "%r expected format is 'value as name'" % bits[0] 1003 1006 var = parser.compile_filter(bits[1]) 1004 1007 name = bits[3] django/branches/boulder-oracle-sprint/django/utils/datastructures.py
r4755 r5062 212 212 "update() extends rather than replaces existing key lists. Also accepts keyword args." 213 213 if len(args) > 1: 214 raise TypeError, "update expected at most 1 arguments, got %d" ,len(args)214 raise TypeError, "update expected at most 1 arguments, got %d" % len(args) 215 215 if args: 216 216 other_dict = args[0] django/branches/boulder-oracle-sprint/django/views/debug.py
r4990 r5062 91 91 frames = [] 92 92 while tb is not None: 93 # support for __traceback_hide__ which is used by a few libraries 94 # to hide internal frames. 95 if tb.tb_frame.f_locals.get('__traceback_hide__'): 96 tb = tb.tb_next 97 continue 93 98 filename = tb.tb_frame.f_code.co_filename 94 99 function = tb.tb_frame.f_code.co_name 95 100 lineno = tb.tb_lineno - 1 96 pre_context_lineno, pre_context, context_line, post_context = _get_lines_from_file(filename, lineno, 7) 97 if pre_context_lineno: 101 loader = tb.tb_frame.f_globals.get('__loader__') 102 module_name = tb.tb_frame.f_globals.get('__name__') 103 pre_context_lineno, pre_context, context_line, post_context = _get_lines_from_file(filename, lineno, 7, loader, module_name) 104 if pre_context_lineno is not None: 98 105 frames.append({ 99 106 'tb': tb, … … 162 169 return HttpResponseNotFound(t.render(c), mimetype='text/html') 163 170 164 def _get_lines_from_file(filename, lineno, context_lines ):171 def _get_lines_from_file(filename, lineno, context_lines, loader=None, module_name=None): 165 172 """ 166 173 Returns context_lines before and after lineno from file. 167 174 Returns (pre_context_lineno, pre_context, context_line, post_context). 168 175 """ 169 try: 170 source = open(filename).readlines() 171 lower_bound = max(0, lineno - context_lines) 172 upper_bound = lineno + context_lines 173 174 pre_context = [line.strip('\n') for line in source[lower_bound:lineno]] 175 context_line = source[lineno].strip('\n') 176 post_context = [line.strip('\n') for line in source[lineno+1:upper_bound]] 177 178 return lower_bound, pre_context, context_line, post_context 179 except (OSError, IOError): 176 source = None 177 if loader is not None: 178 source = loader.get_source(module_name).splitlines() 179 else: 180 try: 181 f = open(filename) 182 try: 183 source = f.readlines() 184 finally: 185 f.close() 186 except (OSError, IOError): 187 pass 188 if source is None: 180 189 return None, [], None, [] 190 191 lower_bound = max(0, lineno - context_lines) 192 upper_bound = lineno + context_lines 193 194 pre_context = [line.strip('\n') for line in source[lower_bound:lineno]] 195 context_line = source[lineno].strip('\n') 196 post_context = [line.strip('\n') for line in source[lineno+1:upper_bound]] 197 198 return lower_bound, pre_context, context_line, post_context 181 199 182 200 # … … 315 333 <tr> 316 334 <th>Exception Location:</th> 317 <td>{{ lastframe.filename }} in {{ lastframe.function}}, line {{ lastframe.lineno }}</td>335 <td>{{ lastframe.filename|escape }} in {{ lastframe.function|escape }}, line {{ lastframe.lineno }}</td> 318 336 </tr> 319 337 </table> … … 362 380 {% for frame in frames %} 363 381 <li class="frame"> 364 <code>{{ frame.filename }}</code> in <code>{{ frame.function}}</code>382 <code>{{ frame.filename|escape }}</code> in <code>{{ frame.function|escape }}</code> 365 383 366 384 {% if frame.context_line %} django/branches/boulder-oracle-sprint/docs/distributions.txt
r4755 r5062 48 48 49 49 A Django package is available for `Fedora Linux`_, in the "Fedora Extras" 50 repository. The `current Fedora package`_ is based on Django 0.95.1, and can be 51 installed by typing ``yum install Django``. 50 repository. The `current Fedora package`_ is based on Django 0.96, and can be 51 installed by typing ``yum install Django``. The previous link is for the i386 52 binary. Users of other architectures should be able to use that as a starting 53 point to find their preferred version. 52 54 53 55 .. _Fedora Linux: http://fedora.redhat.com/ 54 .. _current Fedora package: http:// fedoraproject.org/extras/6/i386/repodata/repoview/Django-0-0.95.1-1.fc6.html56 .. _current Fedora package: http://download.fedora.redhat.com/pub/fedora/linux/extras/6/i386/repoview/Django.html 55 57 56 58 Gentoo 57 59 ------ 58 60 59 A Django build is available for `Gentoo Linux`_, and is based on Django 0.9 5.1.61 A Django build is available for `Gentoo Linux`_, and is based on Django 0.96. 60 62 The `current Gentoo build`_ can be installed by typing ``emerge django``. 61 63 django/branches/boulder-oracle-sprint/docs/generic_views.txt
r4906 r5062 45 45 (r'^(?P<year>\d{4})/(?P<month>[a-z]{3})/$', 'archive_month', info_dict), 46 46 (r'^(?P<year>\d{4})/$', 'archive_year', info_dict), 47 (r'^ /?$','archive_index', info_dict),47 (r'^$', 'archive_index', info_dict), 48 48 ) 49 49 django/branches/boulder-oracle-sprint/tests/regressiontests/templates/tests.py
r4906 r5062 260 260 'filter02': ('{% filter upper %}django{% endfilter %}', {}, 'DJANGO'), 261 261 'filter03': ('{% filter upper|lower %}django{% endfilter %}', {}, 'django'), 262 'filter04': ('{% filter cut:remove %}djangospam{% endfilter %}', {'remove': 'spam'}, 'django'), 262 263 263 264 ### FIRSTOF TAG ########################################################### … … 655 656 'with02': ('{{ key }}{% with dict.key as key %}{{ key }}-{{ dict.key }}-{{ key }}{% endwith %}{{ key }}', {'dict': {'key':50}}, ('50-50-50', 'INVALID50-50-50INVALID')), 656 657 658 'with-error01': ('{% with dict.key xx key %}{{ key }}{% endwith %}', {'dict': {'key':50}}, template.TemplateSyntaxError), 659 'with-error02': ('{% with dict.key as %}{{ key }}{% endwith %}', {'dict': {'key':50}}, template.TemplateSyntaxError), 660 657 661 ### NOW TAG ######################################################## 658 662 # Simple case
