Ticket #6897: newstyle.diff

File newstyle.diff, 9.0 KB (added by Brodie Rao, 17 years ago)

Patch replacing old-style classes with new-style classes

  • django/test/client.py

     
    9595    ])
    9696    return '\r\n'.join(lines)
    9797
    98 class Client:
     98class Client(object):
    9999    """
    100100    A class that can act as a client for testing purposes.
    101101
  • django/db/models/fields/__init__.py

     
    2121from django.utils.encoding import smart_unicode, force_unicode, smart_str
    2222from django.utils.maxlength import LegacyMaxlength
    2323
    24 class NOT_PROVIDED:
     24class NOT_PROVIDED(object):
    2525    pass
    2626
    2727# Values for filter_interface.
  • django/db/backends/mysql_old/base.py

     
    3939
    4040# This is an extra debug layer over MySQL queries, to display warnings.
    4141# It's only used when DEBUG=True.
    42 class MysqlDebugWrapper:
     42class MysqlDebugWrapper(object):
    4343    def __init__(self, cursor):
    4444        self.cursor = cursor
    4545
     
    5858            raise Database.Warning("%s: %s" % (w, self.cursor.fetchall()))
    5959
    6060    def __getattr__(self, attr):
    61         if attr in self.__dict__:
    62             return self.__dict__[attr]
    63         else:
    64             return getattr(self.cursor, attr)
     61        return getattr(self.cursor, attr)
    6562
    6663class DatabaseFeatures(BaseDatabaseFeatures):
    6764    autoindexes_primary_keys = False
  • django/db/backends/sqlite3/introspection.py

     
    7474# This light wrapper "fakes" a dictionary interface, because some SQLite data
    7575# types include variables in them -- e.g. "varchar(30)" -- and can't be matched
    7676# as a simple dictionary lookup.
    77 class FlexibleFieldLookupDict:
     77class FlexibleFieldLookupDict(object):
    7878    def __getitem__(self, key):
    7979        key = key.lower()
    8080        try:
  • django/oldforms/__init__.py

     
    549549                {{ option.field }} {{ option.label }}<br />
    550550            {% endfor %}
    551551        """
    552         class RadioFieldRenderer:
     552        class RadioFieldRenderer(object):
    553553            def __init__(self, datalist, ul_class):
    554554                self.datalist, self.ul_class = datalist, ul_class
    555555            def __unicode__(self):
  • django/core/management/validation.py

     
    22from django.core.management.color import color_style
    33from django.utils.itercompat import is_iterable
    44
    5 class ModelErrorCollection:
     5class ModelErrorCollection(object):
    66    def __init__(self, outfile=sys.stdout):
    77        self.errors = []
    88        self.outfile = outfile
  • django/core/management/color.py

     
    2323    """Returns a Style object with the Django color scheme."""
    2424    if not supports_color():
    2525        return no_style()
    26     class dummy: pass
     26    class dummy(object):
     27        pass
    2728    style = dummy()
    2829    style.ERROR = termcolors.make_style(fg='red', opts=('bold',))
    2930    style.ERROR_OUTPUT = termcolors.make_style(fg='red', opts=('bold',))
     
    3637
    3738def no_style():
    3839    """Returns a Style object that has no colors."""
    39     class dummy:
     40    class dummy(object):
    4041        def __getattr__(self, attr):
    4142            return lambda x: x
    4243    return dummy()
  • django/dispatch/saferef.py

     
    174174    is equally fast, but not 100% reliable because functions can be stored on an
    175175    attribute named differenty than the function's name such as in:
    176176
    177     class A: pass
     177    class A(object): pass
    178178    def foo(self): return "foo"
    179179    A.bar = foo
    180180
  • django/dispatch/dispatcher.py

     
    3333__version__ = "$Revision: 1.9 $"[11:-2]
    3434
    3535
    36 class _Parameter:
     36class _Parameter(object):
    3737    """Used to represent default parameter values."""
    3838    def __repr__(self):
    3939        return self.__class__.__name__
  • django/utils/_decimal.py

     
    392392except ImportError:
    393393    # Python was compiled without threads; create a mock object instead
    394394    import sys
    395     class MockThreading:
     395    class MockThreading(object):
    396396        def local(self, sys=sys):
    397397            return sys.modules[__name__]
    398398    threading = MockThreading()
  • django/utils/daemonize.py

     
    5151        else:
    5252            sys.stdout = NullDevice()
    5353
    54     class NullDevice:
     54    class NullDevice(object):
    5555        "A writeable object that writes to nowhere -- like /dev/null."
    5656        def write(self, s):
    5757            pass
  • django/utils/synch.py

     
    1111except ImportError:
    1212    import dummy_threading as threading
    1313
    14 class RWLock:
     14class RWLock(object):
    1515    """
    1616    Classic implementation of reader-writer lock with preference to writers.
    1717
  • django/contrib/comments/templatetags/comments.py

     
    136136        context[self.var_name] = comment_list
    137137        return ''
    138138
    139 class DoCommentForm:
     139class DoCommentForm(object):
    140140    """
    141141    Displays a comment form for the given params.
    142142
     
    211211                    raise template.TemplateSyntaxError, "%r tag got invalid parameter '%s'" % (tokens[0], option)
    212212        return CommentFormNode(content_type, obj_id_lookup_var, obj_id, self.free, **kwargs)
    213213
    214 class DoCommentCount:
     214class DoCommentCount(object):
    215215    """
    216216    Gets comment count for the given params and populates the template context
    217217    with a variable containing that value, whose name is defined by the 'as'
     
    261261            raise template.TemplateSyntaxError, "Fourth argument in %r must be 'as'" % tokens[0]
    262262        return CommentCountNode(package, module, var_name, obj_id, tokens[5], self.free)
    263263
    264 class DoGetCommentList:
     264class DoGetCommentList(object):
    265265    """
    266266    Gets comments for the given params and populates the template context with a
    267267    special comment_package variable, whose name is defined by the ``as``
  • django/contrib/sitemaps/__init__.py

     
    3333    params = urllib.urlencode({'sitemap':url})
    3434    urllib.urlopen("%s?%s" % (ping_url, params))
    3535
    36 class Sitemap:
     36class Sitemap(object):
    3737    def __get(self, name, obj, default=None):
    3838        try:
    3939            attr = getattr(self, name)
  • django/contrib/admin/templatetags/log.py

     
    1919            context[self.varname] = LogEntry.objects.filter(user__id__exact=self.user).select_related()[:self.limit]
    2020        return ''
    2121
    22 class DoGetAdminLog:
     22class DoGetAdminLog(object):
    2323    """
    2424    Populates a template variable with the admin log for the given criteria.
    2525
  • django/template/defaulttags.py

     
    252252                    return self.nodelist_false.render(context)
    253253            return self.nodelist_true.render(context)
    254254
    255     class LinkTypes:
     255    class LinkTypes(object):
    256256        and_ = 0,
    257257        or_ = 1
    258258
Back to Top