Django

Code

Changeset 5062

Show
Ignore:
Timestamp:
04/23/07 11:16:27 (1 year ago)
Author:
bouldersprinters
Message:

boulder-oracle-sprint: Merged to [5061]

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/branches/boulder-oracle-sprint/AUTHORS

    r5047 r5062  
    7979    Alex Dedul 
    8080    deric@monowerks.com 
     81    Max Derkachev <mderk@yandex.ru> 
    8182    dne@mayonnaise.net 
    8283    Maximillian Dornseif <md@hudora.de> 
     
    114115    Baurzhan Ismagulov <ibr@radix50.net> 
    115116    jcrasta@gmail.com 
     117    Zak Johnson <zakj@nox.cx> 
    116118    Michael Josephson <http://www.sdjournal.com/> 
    117119    jpellerin@gmail.com 
     
    181183    remco@diji.biz 
    182184    rhettg@gmail.com 
     185    Armin Ronacher 
    183186    Oliver Rutherfurd <http://rutherfurd.net/> 
    184187    Ivan Sagalaev (Maniac) <http://www.softwaremaniacs.org/> 
  • django/branches/boulder-oracle-sprint/django/contrib/auth/models.py

    r4990 r5062  
    274274 
    275275    def __str__(self): 
    276         return 'AnonymousUser' 
     276        return _('AnonymousUser') 
    277277 
    278278    def __eq__(self, other): 
  • django/branches/boulder-oracle-sprint/django/newforms/fields.py

    r4935 r5062  
    333333 
    334334class 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): 
    336338        super(ChoiceField, self).__init__(required, widget, label, initial, help_text) 
    337339        self.choices = choices 
     
    365367class MultipleChoiceField(ChoiceField): 
    366368    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 
    370370 
    371371    def clean(self, value): 
  • django/branches/boulder-oracle-sprint/django/template/defaultfilters.py

    r4722 r5062  
    33from django.template import resolve_variable, Library 
    44from django.conf import settings 
    5 from django.utils.translation import gettext 
     5from django.utils.translation import gettext, ngettext 
    66import re 
    77import random as random_module 
     
    518518         
    519519    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} 
    521521    if bytes < 1024 * 1024: 
    522         return "%.1f KB" % (bytes / 1024) 
     522        return gettext("%.1f KB") % (bytes / 1024) 
    523523    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)) 
    526526 
    527527def pluralize(value, arg='s'): 
  • django/branches/boulder-oracle-sprint/django/template/defaulttags.py

    r4935 r5062  
    4242        output = self.nodelist.render(context) 
    4343        # 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 
    4548 
    4649class FirstOfNode(Node): 
     
    991994    Add a value to the context (inside of this block) for caching and easy 
    992995    access. 
    993      
     996 
    994997    For example:: 
    995998 
     
    10001003    bits = list(token.split_contents()) 
    10011004    if len(bits) != 4 or bits[2] != "as": 
    1002         raise TemplateSyntaxError, "%r expected format is 'value as name'" % tagname 
     1005        raise TemplateSyntaxError, "%r expected format is 'value as name'" % bits[0] 
    10031006    var = parser.compile_filter(bits[1]) 
    10041007    name = bits[3] 
  • django/branches/boulder-oracle-sprint/django/utils/datastructures.py

    r4755 r5062  
    212212        "update() extends rather than replaces existing key lists. Also accepts keyword args." 
    213213        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) 
    215215        if args: 
    216216            other_dict = args[0] 
  • django/branches/boulder-oracle-sprint/django/views/debug.py

    r4990 r5062  
    9191    frames = [] 
    9292    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 
    9398        filename = tb.tb_frame.f_code.co_filename 
    9499        function = tb.tb_frame.f_code.co_name 
    95100        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: 
    98105            frames.append({ 
    99106                'tb': tb, 
     
    162169    return HttpResponseNotFound(t.render(c), mimetype='text/html') 
    163170 
    164 def _get_lines_from_file(filename, lineno, context_lines): 
     171def _get_lines_from_file(filename, lineno, context_lines, loader=None, module_name=None): 
    165172    """ 
    166173    Returns context_lines before and after lineno from file. 
    167174    Returns (pre_context_lineno, pre_context, context_line, post_context). 
    168175    """ 
    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: 
    180189        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 
    181199 
    182200# 
     
    315333    <tr> 
    316334      <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> 
    318336    </tr> 
    319337  </table> 
     
    362380      {% for frame in frames %} 
    363381        <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> 
    365383 
    366384          {% if frame.context_line %} 
  • django/branches/boulder-oracle-sprint/docs/distributions.txt

    r4755 r5062  
    4848 
    4949A 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``. 
     50repository. The `current Fedora package`_ is based on Django 0.96, and can be 
     51installed by typing ``yum install Django``. The previous link is for the i386 
     52binary. Users of other architectures should be able to use that as a starting 
     53point to find their preferred version. 
    5254 
    5355.. _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.html 
     56.. _current Fedora package: http://download.fedora.redhat.com/pub/fedora/linux/extras/6/i386/repoview/Django.html 
    5557 
    5658Gentoo 
    5759------ 
    5860 
    59 A Django build is available for `Gentoo Linux`_, and is based on Django 0.95.1
     61A Django build is available for `Gentoo Linux`_, and is based on Django 0.96
    6062The `current Gentoo build`_ can be installed by typing ``emerge django``. 
    6163 
  • django/branches/boulder-oracle-sprint/docs/generic_views.txt

    r4906 r5062  
    4545       (r'^(?P<year>\d{4})/(?P<month>[a-z]{3})/$',                                'archive_month', info_dict), 
    4646       (r'^(?P<year>\d{4})/$',                                                    'archive_year',  info_dict), 
    47        (r'^/?$',                                                                  'archive_index', info_dict), 
     47       (r'^$',                                                                    'archive_index', info_dict), 
    4848    ) 
    4949 
  • django/branches/boulder-oracle-sprint/tests/regressiontests/templates/tests.py

    r4906 r5062  
    260260            'filter02': ('{% filter upper %}django{% endfilter %}', {}, 'DJANGO'), 
    261261            'filter03': ('{% filter upper|lower %}django{% endfilter %}', {}, 'django'), 
     262            'filter04': ('{% filter cut:remove %}djangospam{% endfilter %}', {'remove': 'spam'}, 'django'), 
    262263 
    263264            ### FIRSTOF TAG ########################################################### 
     
    655656            'with02': ('{{ key }}{% with dict.key as key %}{{ key }}-{{ dict.key }}-{{ key }}{% endwith %}{{ key }}', {'dict': {'key':50}}, ('50-50-50', 'INVALID50-50-50INVALID')), 
    656657 
     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 
    657661            ### NOW TAG ######################################################## 
    658662            # Simple case