Django

Code

Changeset 3113

Show
Ignore:
Timestamp:
06/08/06 00:00:13 (2 years ago)
Author:
adrian
Message:

Fixed #2109 -- Convert old-style classes to new-style classes throughout Django. Thanks, Nicola Larosa

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/django/conf/__init__.py

    r2929 r3113  
    1313ENVIRONMENT_VARIABLE = "DJANGO_SETTINGS_MODULE" 
    1414 
    15 class LazySettings
     15class LazySettings(object)
    1616    """ 
    1717    A lazy proxy for either global Django settings or a custom settings object. 
     
    6868        self._target = holder 
    6969 
    70 class Settings
     70class Settings(object)
    7171    def __init__(self, settings_module): 
    7272        # update this dict from global settings (but only for ALL_CAPS settings) 
     
    113113        return dir(self) 
    114114 
    115 class UserSettingsHolder
     115class UserSettingsHolder(object)
    116116    """ 
    117117    Holder for user configured settings. 
  • django/trunk/django/contrib/auth/middleware.py

    r2809 r3113  
    1313        return self._user 
    1414 
    15 class AuthenticationMiddleware
     15class AuthenticationMiddleware(object)
    1616    def process_request(self, request): 
    1717        assert hasattr(request, 'session'), "The Django authentication middleware requires session middleware to be installed. Edit your MIDDLEWARE_CLASSES setting to insert 'django.contrib.sessions.middleware.SessionMiddleware'." 
  • django/trunk/django/contrib/flatpages/middleware.py

    r2809 r3113  
    33from django.conf import settings 
    44 
    5 class FlatpageFallbackMiddleware
     5class FlatpageFallbackMiddleware(object)
    66    def process_response(self, request, response): 
    77        if response.status_code != 404: 
  • django/trunk/django/contrib/redirects/middleware.py

    r2809 r3113  
    33from django.conf import settings 
    44 
    5 class RedirectFallbackMiddleware
     5class RedirectFallbackMiddleware(object)
    66    def process_response(self, request, response): 
    77        if response.status_code != 404: 
  • django/trunk/django/contrib/sessions/middleware.py

    r3049 r3113  
    6565    _session = property(_get_session) 
    6666 
    67 class SessionMiddleware
     67class SessionMiddleware(object)
    6868    def process_request(self, request): 
    6969        request.session = SessionWrapper(request.COOKIES.get(settings.SESSION_COOKIE_NAME, None)) 
  • django/trunk/django/contrib/syndication/feeds.py

    r2809 r3113  
    1313    pass 
    1414 
    15 class Feed
     15class Feed(object)
    1616    item_pubdate = None 
    1717    item_enclosure_url = None 
  • django/trunk/django/core/cache/backends/base.py

    r2378 r3113  
    66    pass 
    77 
    8 class BaseCache
     8class BaseCache(object)
    99    def __init__(self, params): 
    1010        timeout = params.get('timeout', 300) 
  • django/trunk/django/core/context_processors.py

    r3091 r3113  
    3737    else: 
    3838        context_extras['LANGUAGE_CODE'] = settings.LANGUAGE_CODE 
    39      
     39 
    4040    from django.utils import translation 
    4141    context_extras['LANGUAGE_BIDI'] = translation.get_language_bidi() 
     
    4949# the template system can understand. 
    5050 
    51 class PermLookupDict
     51class PermLookupDict(object)
    5252    def __init__(self, user, module_name): 
    5353        self.user, self.module_name = user, module_name 
     
    5959        return self.user.has_module_perms(self.module_name) 
    6060 
    61 class PermWrapper
     61class PermWrapper(object)
    6262    def __init__(self, user): 
    6363        self.user = user 
  • django/trunk/django/core/handlers/base.py

    r2990 r3113  
    44import sys 
    55 
    6 class BaseHandler
     6class BaseHandler(object)
    77    def __init__(self): 
    88        self._request_middleware = self._view_middleware = self._response_middleware = self._exception_middleware = None 
  • django/trunk/django/core/paginator.py

    r3040 r3113  
    55    pass 
    66 
    7 class ObjectPaginator
     7class ObjectPaginator(object)
    88    """ 
    99    This class makes pagination easy. Feed it a QuerySet, plus the number of 
  • django/trunk/django/core/servers/basehttp.py

    r2809 r3113  
    2222    pass 
    2323 
    24 class FileWrapper
     24class FileWrapper(object)
    2525    """Wrapper to convert file-like objects to iterables""" 
    2626 
     
    6464        return param 
    6565 
    66 class Headers
     66class Headers(object)
    6767    """Manage a collection of HTTP response headers""" 
    6868    def __init__(self,headers): 
     
    219219    return _hoppish(header_name.lower()) 
    220220 
    221 class ServerHandler
     221class ServerHandler(object)
    222222    """Manage the invocation of a WSGI application""" 
    223223 
     
    592592        sys.stderr.write("[%s] %s\n" % (self.log_date_time_string(), format % args)) 
    593593 
    594 class AdminMediaHandler
     594class AdminMediaHandler(object)
    595595    """ 
    596596    WSGI middleware that intercepts calls to the admin media directory, as 
  • django/trunk/django/core/urlresolvers.py

    r3057 r3113  
    8484        return str(value) # TODO: Unicode? 
    8585 
    86 class RegexURLPattern
     86class RegexURLPattern(object)
    8787    def __init__(self, regex, callback, default_args=None): 
    8888        # regex is a string representing a regular expression. 
  • django/trunk/django/core/validators.py

    r3070 r3113  
    238238            get_text_list(['"%s%s%s"' % (i[0], '-'*(len(i)-2), i[-1]) for i in words_seen], 'and') 
    239239 
    240 class AlwaysMatchesOtherField
     240class AlwaysMatchesOtherField(object)
    241241    def __init__(self, other_field_name, error_message=None): 
    242242        self.other = other_field_name 
     
    248248            raise ValidationError, self.error_message 
    249249 
    250 class ValidateIfOtherFieldEquals
     250class ValidateIfOtherFieldEquals(object)
    251251    def __init__(self, other_field, other_value, validator_list): 
    252252        self.other_field, self.other_value = other_field, other_value 
     
    259259                v(field_data, all_data) 
    260260 
    261 class RequiredIfOtherFieldNotGiven
     261class RequiredIfOtherFieldNotGiven(object)
    262262    def __init__(self, other_field_name, error_message=gettext_lazy("Please enter something for at least one field.")): 
    263263        self.other, self.error_message = other_field_name, error_message 
     
    268268            raise ValidationError, self.error_message 
    269269 
    270 class RequiredIfOtherFieldsGiven
     270class RequiredIfOtherFieldsGiven(object)
    271271    def __init__(self, other_field_names, error_message=gettext_lazy("Please enter both fields or leave them both empty.")): 
    272272        self.other, self.error_message = other_field_names, error_message 
     
    283283        RequiredIfOtherFieldsGiven.__init__(self, [other_field_name], error_message) 
    284284 
    285 class RequiredIfOtherFieldEquals
     285class RequiredIfOtherFieldEquals(object)
    286286    def __init__(self, other_field, other_value, error_message=None): 
    287287        self.other_field = other_field 
     
    295295            raise ValidationError(self.error_message) 
    296296 
    297 class RequiredIfOtherFieldDoesNotEqual
     297class RequiredIfOtherFieldDoesNotEqual(object)
    298298    def __init__(self, other_field, other_value, error_message=None): 
    299299        self.other_field = other_field 
     
    307307            raise ValidationError(self.error_message) 
    308308 
    309 class IsLessThanOtherField
     309class IsLessThanOtherField(object)
    310310    def __init__(self, other_field_name, error_message): 
    311311        self.other, self.error_message = other_field_name, error_message 
     
    315315            raise ValidationError, self.error_message 
    316316 
    317 class UniqueAmongstFieldsWithPrefix
     317class UniqueAmongstFieldsWithPrefix(object)
    318318    def __init__(self, field_name, prefix, error_message): 
    319319        self.field_name, self.prefix = field_name, prefix 
     
    325325                raise ValidationError, self.error_message 
    326326 
    327 class IsAPowerOf
     327class IsAPowerOf(object)
    328328    """ 
    329329    >>> v = IsAPowerOf(2) 
     
    343343            raise ValidationError, gettext("This value must be a power of %s.") % self.power_of 
    344344 
    345 class IsValidFloat
     345class IsValidFloat(object)
    346346    def __init__(self, max_digits, decimal_places): 
    347347        self.max_digits, self.decimal_places = max_digits, decimal_places 
     
    360360                "Please enter a valid decimal number with at most %s decimal places.", self.decimal_places) % self.decimal_places 
    361361 
    362 class HasAllowableSize
     362class HasAllowableSize(object)
    363363    """ 
    364364    Checks that the file-upload field data is a certain size. min_size and 
     
    380380            raise ValidationError, self.max_error_message 
    381381 
    382 class MatchesRegularExpression
     382class MatchesRegularExpression(object)
    383383    """ 
    384384    Checks that the field matches the given regular-expression. The regex 
     
    393393            raise ValidationError(self.error_message) 
    394394 
    395 class AnyValidator
     395class AnyValidator(object)
    396396    """ 
    397397    This validator tries all given validators. If any one of them succeeds, 
     
    417417        raise ValidationError(self.error_message) 
    418418 
    419 class URLMimeTypeCheck
     419class URLMimeTypeCheck(object)
    420420    "Checks that the provided URL points to a document with a listed mime type" 
    421421    class CouldNotRetrieve(ValidationError): 
     
    442442                'url': field_data, 'contenttype': content_type} 
    443443 
    444 class RelaxNGCompact
     444class RelaxNGCompact(object)
    445445    "Validate against a Relax NG compact schema" 
    446446    def __init__(self, schema_path, additional_root_element=None): 
  • django/trunk/django/db/backends/util.py

    r3038 r3113  
    22from time import time 
    33 
    4 class CursorDebugWrapper
     4class CursorDebugWrapper(object)
    55    def __init__(self, cursor, db): 
    66        self.cursor = cursor 
  • django/trunk/django/db/models/fields/__init__.py

    r3073 r3113  
    536536            if rel: 
    537537                # This validator makes sure FileFields work in a related context. 
    538                 class RequiredFileField
     538                class RequiredFileField(object)
    539539                    def __init__(self, other_field_names, other_file_field_name): 
    540540                        self.other_field_names = other_field_names 
  • django/trunk/django/db/models/fields/related.py

    r3075 r3113  
    668668        pass 
    669669 
    670 class ManyToOneRel
     670class ManyToOneRel(object)
    671671    def __init__(self, to, field_name, num_in_admin=3, min_num_in_admin=None, 
    672672        max_num_in_admin=None, num_extra_on_change=1, edit_inline=False, 
     
    705705        self.multiple = False 
    706706 
    707 class ManyToManyRel
     707class ManyToManyRel(object)
    708708    def __init__(self, to, num_in_admin=0, related_name=None, 
    709709        filter_interface=None, limit_choices_to=None, raw_id_admin=False, symmetrical=True): 
  • django/trunk/django/db/models/__init__.py

    r3089 r3113  
    1616ADD, CHANGE, BOTH = 1, 2, 3 
    1717 
    18 class LazyDate
     18class LazyDate(object)
    1919    """ 
    2020    Use in limit_choices_to to compare the field to dates calculated at run time 
  • django/trunk/django/db/models/options.py

    r2909 r3113  
    1616                 'order_with_respect_to', 'app_label') 
    1717 
    18 class Options
     18class Options(object)
    1919    def __init__(self, meta): 
    2020        self.fields, self.many_to_many = [], [] 
     
    196196        return self._field_types[field_type] 
    197197 
    198 class AdminOptions
     198class AdminOptions(object)
    199199    def __init__(self, fields=None, js=None, list_display=None, list_filter=None, 
    200200        date_hierarchy=None, save_as=False, ordering=None, search_fields=None, 
  • django/trunk/django/db/models/query.py

    r3092 r3113  
    547547        return c 
    548548 
    549 class QOperator
     549class QOperator(object)
    550550    "Base class for QAnd and QOr" 
    551551    def __init__(self, *args): 
  • django/trunk/django/forms/__init__.py

    r3110 r3113  
    102102            field.convert_post_data(new_data) 
    103103 
    104 class FormWrapper
     104class FormWrapper(object)
    105105    """ 
    106106    A wrapper linking a Manipulator to the template system. 
     
    151151    fields = property(_get_fields) 
    152152 
    153 class FormFieldWrapper
     153class FormFieldWrapper(object)
    154154    "A bridge between the template system and an individual form field. Used by FormWrapper." 
    155155    def __init__(self, formfield, data, error_list): 
     
    212212        return ''.join([field.html_error_list() for field in self.formfield_dict.values() if hasattr(field, 'errors')]) 
    213213 
    214 class InlineObjectCollection
     214class InlineObjectCollection(object)
    215215    "An object that acts like a sparse list of form field collections." 
    216216    def __init__(self, parent_manipulator, rel_obj, data, errors): 
     
    270270 
    271271 
    272 class FormField
     272class FormField(object)
    273273    """Abstract class representing a form field. 
    274274 
  • django/trunk/django/middleware/cache.py

    r2809 r3113  
    44from django.http import HttpResponseNotModified 
    55 
    6 class CacheMiddleware
     6class CacheMiddleware(object)
    77    """ 
    88    Cache middleware. If this is enabled, each Django-powered page will be 
  • django/trunk/django/middleware/common.py

    r3109 r3113  
    44import md5, os 
    55 
    6 class CommonMiddleware
     6class CommonMiddleware(object)
    77    """ 
    88    "Common" middleware for taking care of some basic operations: 
  • django/trunk/django/middleware/doc.py

    r2809 r3113  
    22from django import http 
    33 
    4 class XViewMiddleware
     4class XViewMiddleware(object)
    55    """ 
    66    Adds an X-View header to internal HEAD requests -- used by the documentation system. 
  • django/trunk/django/middleware/gzip.py

    r810 r3113  
    55re_accepts_gzip = re.compile(r'\bgzip\b') 
    66 
    7 class GZipMiddleware
     7class GZipMiddleware(object)
    88    """ 
    99    This middleware compresses content if the browser allows gzip compression. 
  • django/trunk/django/middleware/http.py

    r810 r3113  
    11import datetime 
    22 
    3 class ConditionalGetMiddleware
     3class ConditionalGetMiddleware(object)
    44    """ 
    55    Handles conditional GET operations. If the response has a ETag or 
  • django/trunk/django/middleware/locale.py

    r2843 r3113  
    44from django.utils import translation 
    55 
    6 class LocaleMiddleware
     6class LocaleMiddleware(object)
    77    """ 
    88    This is a very simple middleware that parses a request 
  • django/trunk/django/middleware/transaction.py

    r2809 r3113  
    22from django.db import transaction 
    33 
    4 class TransactionMiddleware
     4class TransactionMiddleware(object)
    55    """ 
    66    Transaction middleware. If this is enabled, each view function will be run 
  • django/trunk/django/template/context.py

    r2809 r3113  
    88    pass 
    99 
    10 class Context
     10class Context(object)
    1111    "A stack container for variable context" 
    1212    def __init__(self, dict_=None): 
  • django/trunk/django/template/__init__.py

    r3112 r3113  
    135135        return self.source 
    136136 
    137 class Template
     137class Template(object)
    138138    def __init__(self, template_string, origin=None): 
    139139        "Compilation stage" 
     
    159159    return parser.parse() 
    160160 
    161 class Token
     161class Token(object)
    162162    def __init__(self, token_type, contents): 
    163163        "The token_type must be TOKEN_TEXT, TOKEN_VAR or TOKEN_BLOCK" 
     
    377377        return Parser(*args, **kwargs) 
    378378 
    379 class TokenParser
     379class TokenParser(object)
    380380    """ 
    381381    Subclass this and implement the top() method to parse a template line. When 
     
    655655    return current 
    656656 
    657 class Node
     657class Node(object)
    658658    def render(self, context): 
    659659        "Return the node rendered as a string" 
  • django/trunk/django/utils/datastructures.py

    r3081 r3113  
    1 class MergeDict
     1class MergeDict(object)
    22    """ 
    33    A simple class for creating new "virtual" dictionaries that actualy look 
  • django/trunk/django/utils/dateformat.py

    r1116 r3113  
    2020re_escaped = re.compile(r'\\(.)') 
    2121 
    22 class Formatter
     22class Formatter(object)
    2323    def format(self, formatstr): 
    2424        pieces = [] 
  • django/trunk/django/utils/feedgenerator.py

    r3004 r3113  
    3737    return 'tag:' + tag 
    3838 
    39 class SyndicationFeed
     39class SyndicationFeed(object)
    4040    "Base class for all syndication feeds. Subclasses should provide write()" 
    4141    def __init__(self, title, link, description, language=None, author_email=None, 
     
    109109            return datetime.datetime.now() 
    110110 
    111 class Enclosure
     111class Enclosure(object)
    112112    "Represents an RSS enclosure" 
    113113    def __init__(self, url, length, mime_type): 
  • django/trunk/tests/othertests/templates.py

    r3112 r3113  
    170170 
    171171    ### CYCLE TAG ############################################################# 
    172     #'cycleXX': ('', {}, ''), 
    173     'cycle01': ('{% cycle a, %}', {}, 'a'), 
     172    'cycle01': ('{% cycle a %}', {}, template.TemplateSyntaxError), 
    174173    'cycle02': ('{% cycle a,b,c as abc %}{% cycle abc %}', {}, 'ab'), 
    175174    'cycle03': ('{% cycle a,b,c as abc %}{% cycle abc %}{% cycle abc %}', {}, 'abc'),