Django

Code

Changeset 7004

Show
Ignore:
Timestamp:
01/09/08 00:08:40 (9 months ago)
Author:
mtredinnick
Message:

queryset-refactor: Merged from trunk up to [7002].

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/branches/queryset-refactor/django/contrib/admin/media/js/urlify.js

    r6954 r7004  
    66    'Ý': 'Y', 'Þ': 'TH', 'ß': 'ss', 'à':'a', 'á':'a', 'â': 'a', 'ã': 'a', 'ä': 
    77    'a', 'å': 'a', 'æ': 'ae', 'ç': 'c', 'è': 'e', 'é': 'e', 'ê': 'e', 'ë': 'e', 
    8     'ì': 'i', 'í': 'i', 'î': 'i', 'ï': 'i', 'ð': 'o', 'ñ': 'n', 'ò': 'o', 'ó': 
     8    'ì': 'i', 'í': 'i', 'î': 'i', 'ï': 'i', 'ð': 'd', 'ñ': 'n', 'ò': 'o', 'ó': 
    99    'o', 'ô': 'o', 'õ': 'o', 'ö': 'o', 'ő': 'o', 'ø': 'o', 'ù': 'u', 'ú': 'u', 
    1010    'û': 'u', 'ü': 'u', 'ű': 'u', 'ý': 'y', 'þ': 'th', 'ÿ': 'y' 
  • django/branches/queryset-refactor/django/contrib/localflavor/ca/forms.py

    r6954 r7004  
    8181    Checks the following rules to determine whether the number is valid: 
    8282 
    83         * Conforms to the XXX-XXX-XXXX format. 
     83        * Conforms to the XXX-XXX-XXX format. 
    8484        * Passes the check digit process "Luhn Algorithm" 
    8585             See: http://en.wikipedia.org/wiki/Social_Insurance_Number 
    8686    """ 
    8787    default_error_messages = { 
    88         'invalid': ugettext('Enter a valid Canadian Social Insurance number in XXX-XXX-XXXX format.'), 
     88        'invalid': ugettext('Enter a valid Canadian Social Insurance number in XXX-XXX-XXX format.'), 
    8989    } 
    9090 
  • django/branches/queryset-refactor/django/contrib/sessions/backends/db.py

    r6341 r7004  
    1111    def __init__(self, session_key=None): 
    1212        super(SessionStore, self).__init__(session_key) 
    13      
     13 
    1414    def load(self): 
    1515        try: 
    1616            s = Session.objects.get( 
    17                 session_key = self.session_key,  
     17                session_key = self.session_key, 
    1818                expire_date__gt=datetime.datetime.now() 
    1919            ) 
    2020            return self.decode(s.session_data) 
    2121        except (Session.DoesNotExist, SuspiciousOperation): 
    22              
     22 
    2323            # Create a new session_key for extra security. 
    2424            self.session_key = self._get_new_session_key() 
     
    2727            # Save immediately to minimize collision 
    2828            self.save() 
     29            # Ensure the user is notified via a new cookie. 
     30            self.modified = True 
    2931            return {} 
    30              
     32 
    3133    def exists(self, session_key): 
    3234        try: 
     
    3537            return False 
    3638        return True 
    37              
     39 
    3840    def save(self): 
    3941        Session.objects.create( 
     
    4244            expire_date = datetime.datetime.now() + datetime.timedelta(seconds=settings.SESSION_COOKIE_AGE) 
    4345        ) 
    44      
     46 
    4547    def delete(self, session_key): 
    4648        try: 
  • django/branches/queryset-refactor/django/contrib/sessions/backends/file.py

    r6954 r7004  
    1111    def __init__(self, session_key=None): 
    1212        self.storage_path = getattr(settings, "SESSION_FILE_PATH", tempfile.gettempdir()) 
    13          
     13 
    1414        # Make sure the storage path is valid. 
    1515        if not os.path.isdir(self.storage_path): 
     
    1818                                       "to an existing directory in which Django "\ 
    1919                                       "can store session data." % self.storage_path) 
    20          
    21         self.file_prefix = settings.SESSION_COOKIE_NAME     
     20 
     21        self.file_prefix = settings.SESSION_COOKIE_NAME 
    2222        super(SessionStore, self).__init__(session_key) 
    23      
     23 
    2424    def _key_to_file(self, session_key=None): 
    2525        """ 
     
    2828        if session_key is None: 
    2929            session_key = self.session_key 
    30          
     30 
    3131        # Make sure we're not vulnerable to directory traversal. Session keys 
    3232        # should always be md5s, so they should never contain directory components. 
    3333        if os.path.sep in session_key: 
    3434            raise SuspiciousOperation("Invalid characters (directory components) in session key") 
    35              
     35 
    3636        return os.path.join(self.storage_path, self.file_prefix + session_key) 
    37              
     37 
    3838    def load(self): 
    3939        session_data = {} 
     
    4747                    self._session_cache = {} 
    4848                    self.save() 
     49                    # Ensure the user is notified via a new cookie. 
     50                    self.modified = True 
    4951            finally: 
    5052                session_file.close() 
     
    6769            return True 
    6870        return False 
    69          
     71 
    7072    def delete(self, session_key): 
    7173        try: 
     
    7375        except OSError: 
    7476            pass 
    75              
     77 
    7678    def clean(self): 
    7779        pass 
  • django/branches/queryset-refactor/django/core/mail.py

    r6954 r7004  
    6868    pass 
    6969 
     70def forbid_multi_line_headers(name, val): 
     71    "Forbids multi-line headers, to prevent header injection." 
     72    if '\n' in val or '\r' in val: 
     73        raise BadHeaderError("Header values can't contain newlines (got %r for header %r)" % (val, name)) 
     74    try: 
     75        val = force_unicode(val).encode('ascii') 
     76    except UnicodeEncodeError: 
     77        if name.lower() in ('to', 'from', 'cc'): 
     78            result = [] 
     79            for item in val.split(', '): 
     80                nm, addr = parseaddr(item) 
     81                nm = str(Header(nm, settings.DEFAULT_CHARSET)) 
     82                result.append(formataddr((nm, str(addr)))) 
     83            val = ', '.join(result) 
     84        else: 
     85            val = Header(force_unicode(val), settings.DEFAULT_CHARSET) 
     86    return name, val 
     87 
    7088class SafeMIMEText(MIMEText): 
    7189    def __setitem__(self, name, val): 
    72         "Forbids multi-line headers, to prevent header injection." 
    73         if '\n' in val or '\r' in val: 
    74             raise BadHeaderError, "Header values can't contain newlines (got %r for header %r)" % (val, name) 
    75         try: 
    76             val = force_unicode(val).encode('ascii') 
    77         except UnicodeEncodeError: 
    78             if name.lower() in ('to', 'from', 'cc'): 
    79                 result = [] 
    80                 for item in val.split(', '): 
    81                     nm, addr = parseaddr(item) 
    82                     nm = str(Header(nm, settings.DEFAULT_CHARSET)) 
    83                     result.append(formataddr((nm, str(addr)))) 
    84                 val = ', '.join(result) 
    85             else: 
    86                 val = Header(force_unicode(val), settings.DEFAULT_CHARSET) 
     90        name, val = forbid_multi_line_headers(name, val) 
    8791        MIMEText.__setitem__(self, name, val) 
    8892 
    8993class SafeMIMEMultipart(MIMEMultipart): 
    9094    def __setitem__(self, name, val): 
    91         "Forbids multi-line headers, to prevent header injection." 
    92         if '\n' in val or '\r' in val: 
    93             raise BadHeaderError, "Header values can't contain newlines (got %r for header %r)" % (val, name) 
    94         try: 
    95             val = force_unicode(val).encode('ascii') 
    96         except UnicodeEncodeError: 
    97             if name.lower() in ('to', 'from', 'cc'): 
    98                 result = [] 
    99                 for item in val.split(', '): 
    100                     nm, addr = parseaddr(item) 
    101                     nm = str(Header(nm, settings.DEFAULT_CHARSET)) 
    102                     result.append(formataddr((nm, str(addr)))) 
    103                 val = ', '.join(result) 
    104             else: 
    105                 val = Header(force_unicode(val), settings.DEFAULT_CHARSET) 
     95        name, val = forbid_multi_line_headers(name, val) 
    10696        MIMEMultipart.__setitem__(self, name, val) 
    10797 
  • django/branches/queryset-refactor/django/core/management/sql.py

    r6954 r7004  
    294294    for field_constraints in opts.unique_together: 
    295295        table_output.append(style.SQL_KEYWORD('UNIQUE') + ' (%s)' % \ 
    296             ", ".join([qn(style.SQL_FIELD(opts.get_field(f).column)) for f in field_constraints])) 
     296            ", ".join([style.SQL_FIELD(qn(opts.get_field(f).column)) for f in field_constraints])) 
    297297 
    298298    full_statement = [style.SQL_KEYWORD('CREATE TABLE') + ' ' + style.SQL_TABLE(qn(opts.db_table)) + ' ('] 
  • django/branches/queryset-refactor/django/db/backends/oracle/base.py

    r6954 r7004  
    414414 
    415415    def _cursor(self, settings): 
     416        cursor = None 
    416417        if not self._valid_connection(): 
    417418            if len(settings.DATABASE_HOST.strip()) == 0: 
     
    423424                conn_string = "%s/%s@%s" % (settings.DATABASE_USER, settings.DATABASE_PASSWORD, settings.DATABASE_NAME) 
    424425                self.connection = Database.connect(conn_string, **self.options) 
     426            cursor = FormatStylePlaceholderCursor(self.connection) 
     427            # Set oracle date to ansi date format.  This only needs to execute 
     428            # once when we create a new connection. 
     429            cursor.execute("ALTER SESSION SET NLS_DATE_FORMAT = 'YYYY-MM-DD' " 
     430                           "NLS_TIMESTAMP_FORMAT = 'YYYY-MM-DD HH24:MI:SS.FF'") 
    425431            try: 
    426432                self.oracle_version = int(self.connection.version.split('.')[0]) 
    427433            except ValueError: 
    428434                pass 
    429         cursor = FormatStylePlaceholderCursor(self.connection) 
     435            try: 
     436                self.connection.stmtcachesize = 20 
     437            except: 
     438                # Django docs specify cx_Oracle version 4.3.1 or higher, but 
     439                # stmtcachesize is available only in 4.3.2 and up. 
     440                pass 
     441        if not cursor: 
     442            cursor = FormatStylePlaceholderCursor(self.connection) 
    430443        # Default arraysize of 1 is highly sub-optimal. 
    431444        cursor.arraysize = 100 
    432         # Set oracle date to ansi date format. 
    433         cursor.execute("ALTER SESSION SET NLS_DATE_FORMAT = 'YYYY-MM-DD'") 
    434         cursor.execute("ALTER SESSION SET NLS_TIMESTAMP_FORMAT = 'YYYY-MM-DD HH24:MI:SS.FF'") 
    435445        return cursor 
    436446 
     
    507517 
    508518    def fetchone(self): 
    509         return to_unicode(Database.Cursor.fetchone(self)) 
     519        row = Database.Cursor.fetchone(self) 
     520        if row is None: 
     521            return row 
     522        return tuple([to_unicode(e) for e in row]) 
    510523 
    511524    def fetchmany(self, size=None): 
  • django/branches/queryset-refactor/django/template/context.py

    r6857 r7004  
    1010class Context(object): 
    1111    "A stack container for variable context" 
    12  
    1312    def __init__(self, dict_=None, autoescape=True): 
    1413        dict_ = dict_ or {} 
     
    7978                mod = __import__(module, {}, {}, [attr]) 
    8079            except ImportError, e: 
    81                 raise ImproperlyConfigured, 'Error importing request processor module %s: "%s"' % (module, e
     80                raise ImproperlyConfigured('Error importing request processor module %s: "%s"' % (module, e)
    8281            try: 
    8382                func = getattr(mod, attr) 
    8483            except AttributeError: 
    85                 raise ImproperlyConfigured, 'Module "%s" does not define a "%s" callable request processor' % (module, attr
     84                raise ImproperlyConfigured('Module "%s" does not define a "%s" callable request processor' % (module, attr)
    8685            processors.append(func) 
    8786        _standard_context_processors = tuple(processors) 
     
    103102        for processor in get_standard_processors() + processors: 
    104103            self.update(processor(request)) 
    105  
  • django/branches/queryset-refactor/django/template/defaultfilters.py

    r6954 r7004  
    434434    except IndexError: 
    435435        return u'' 
    436 first.is_safe = Tru
     436first.is_safe = Fals
    437437 
    438438def join(value, arg): 
     
    449449        return data 
    450450join.is_safe = True 
     451 
     452def last(value): 
     453    "Returns the last item in a list" 
     454    try: 
     455        return value[-1] 
     456    except IndexError: 
     457        return u'' 
     458last.is_safe = True 
    451459 
    452460def length(value): 
     
    801809register.filter(iriencode) 
    802810register.filter(join) 
     811register.filter(last) 
    803812register.filter(length) 
    804813register.filter(length_is) 
  • django/branches/queryset-refactor/django/template/defaulttags.py

    r6954 r7004  
    8585 
    8686class ForNode(Node): 
    87     def __init__(self, loopvars, sequence, reversed, nodelist_loop): 
     87    def __init__(self, loopvars, sequence, is_reversed, nodelist_loop): 
    8888        self.loopvars, self.sequence = loopvars, sequence 
    89         self.reversed = reversed 
     89        self.is_reversed = is_reversed 
    9090        self.nodelist_loop = nodelist_loop 
    9191 
    9292    def __repr__(self): 
    93         if self.reversed: 
    94             reversed = ' reversed' 
    95         else: 
    96             reversed = '' 
     93        reversed_text = self.is_reversed and ' reversed' or '' 
    9794        return "<For Node: for %s in %s, tail_len: %d%s>" % \ 
    9895            (', '.join(self.loopvars), self.sequence, len(self.nodelist_loop), 
    99              reversed
     96             reversed_text
    10097 
    10198    def __iter__(self): 
     
    126123            values = list(values) 
    127124        len_values = len(values) 
    128         if self.reversed: 
     125        if self.is_reversed: 
    129126            values = reversed(values) 
    130127        unpack = len(self.loopvars) > 1 
     128        # Create a forloop value in the context.  We'll update counters on each 
     129        # iteration just below. 
     130        loop_dict = context['forloop'] = {'parentloop': parentloop} 
    131131        for i, item in enumerate(values): 
    132             context['forloop'] = { 
    133                 # Shortcuts for current loop iteration number. 
    134                 'counter0': i, 
    135                 'counter': i+1, 
    136                 # Reverse counter iteration numbers. 
    137                 'revcounter': len_values - i, 
    138                 'revcounter0': len_values - i - 1, 
    139                 # Boolean values designating first and last times through loop. 
    140                 'first': (i == 0), 
    141                 'last': (i == len_values - 1), 
    142                 'parentloop': parentloop, 
    143             } 
     132            # Shortcuts for current loop iteration number. 
     133            loop_dict['counter0'] = i 
     134            loop_dict['counter'] = i+1 
     135            # Reverse counter iteration numbers. 
     136            loop_dict['revcounter'] = len_values - i 
     137            loop_dict['revcounter0'] = len_values - i - 1 
     138            # Boolean values designating first and last times through loop. 
     139            loop_dict['first'] = (i == 0) 
     140            loop_dict['last'] = (i == len_values - 1) 
     141 
    144142            if unpack: 
    145143                # If there are multiple loop variables, unpack the item into 
     
    620618                                  " words: %s" % token.contents) 
    621619 
    622     reversed = bits[-1] == 'reversed' 
    623     in_index = reversed and -3 or -2 
     620    is_reversed = bits[-1] == 'reversed' 
     621    in_index = is_reversed and -3 or -2 
    624622    if bits[in_index] != 'in': 
    625623        raise TemplateSyntaxError("'for' statements should use the format" 
     
    635633    nodelist_loop = parser.parse(('endfor',)) 
    636634    parser.delete_first_token() 
    637     return ForNode(loopvars, sequence, reversed, nodelist_loop) 
     635    return ForNode(loopvars, sequence, is_reversed, nodelist_loop) 
    638636do_for = register.tag("for", do_for) 
    639637 
  • django/branches/queryset-refactor/django/template/__init__.py

    r6857 r7004  
    155155class Template(object): 
    156156    def __init__(self, template_string, origin=None, name='<Unknown Template>'): 
    157         "Compilation stage" 
    158157        try: 
    159158            template_string = smart_unicode(template_string) 
    160159        except UnicodeDecodeError: 
    161160            raise TemplateEncodingError("Templates can only be constructed from unicode or UTF-8 strings.") 
    162         if settings.TEMPLATE_DEBUG and origin == None: 
     161        if settings.TEMPLATE_DEBUG and origin is None: 
    163162            origin = StringOrigin(template_string) 
    164             # Could do some crazy stack-frame stuff to record where this string 
    165             # came from... 
    166163        self.nodelist = compile_string(template_string, origin) 
    167164        self.name = name 
     
    178175def compile_string(template_string, origin): 
    179176    "Compiles template_string into NodeList ready for rendering" 
    180     lexer = lexer_factory(template_string, origin) 
    181     parser = parser_factory(lexer.tokenize()) 
     177    if settings.TEMPLATE_DEBUG: 
     178        from debug import DebugLexer, DebugParser 
     179        lexer_class, parser_class = DebugLexer, DebugParser 
     180    else: 
     181        lexer_class, parser_class = Lexer, Parser 
     182    lexer = lexer_class(template_string, origin) 
     183    parser = parser_class(lexer.tokenize()) 
    182184    return parser.parse() 
    183185 
    184186class Token(object): 
    185187    def __init__(self, token_type, contents): 
    186         "The token_type must be TOKEN_TEXT, TOKEN_VAR, TOKEN_BLOCK or TOKEN_COMMENT" 
     188        # token_type must be TOKEN_TEXT, TOKEN_VAR, TOKEN_BLOCK or TOKEN_COMMENT. 
    187189        self.token_type, self.contents = token_type, contents 
    188190 
     
    201203 
    202204    def tokenize(self): 
    203         "Return a list of tokens from a given template_string
     205        "Return a list of tokens from a given template_string.
    204206        in_tag = False 
    205207        result = [] 
     
    225227        else: 
    226228            token = Token(TOKEN_TEXT, token_string) 
    227         return token 
    228  
    229 class DebugLexer(Lexer): 
    230     def __init__(self, template_string, origin): 
    231         super(DebugLexer, self).__init__(template_string, origin) 
    232  
    233     def tokenize(self): 
    234         "Return a list of tokens from a given template_string" 
    235         result, upto = [], 0 
    236         for match in tag_re.finditer(self.template_string): 
    237             start, end = match.span() 
    238             if start > upto: 
    239                 result.append(self.create_token(self.template_string[upto:start], (upto, start), False)) 
    240                 upto = start 
    241             result.append(self.create_token(self.template_string[start:end], (start, end), True)) 
    242             upto = end 
    243         last_bit = self.template_string[upto:] 
    244         if last_bit: 
    245             result.append(self.create_token(last_bit, (upto, upto + len(last_bit)), False)) 
    246         return result 
    247  
    248     def create_token(self, token_string, source, in_tag): 
    249         token = super(DebugLexer, self).create_token(token_string, in_tag) 
    250         token.source = self.origin, source 
    251229        return token 
    252230 
     
    320298        pass 
    321299 
    322     def error(self, token, msg ): 
     300    def error(self, token, msg): 
    323301        return TemplateSyntaxError(msg) 
    324302 
    325303    def empty_variable(self, token): 
    326         raise self.error( token, "Empty variable tag") 
     304        raise self.error(token, "Empty variable tag") 
    327305 
    328306    def empty_block_tag(self, token): 
    329         raise self.error( token, "Empty block tag") 
     307        raise self.error(token, "Empty block tag") 
    330308 
    331309    def invalid_block_tag(self, token, command): 
    332         raise self.error( token, "Invalid block tag: '%s'" % command) 
     310        raise self.error(token, "Invalid block tag: '%s'" % command) 
    333311 
    334312    def unclosed_block_tag(self, parse_until): 
     
    359337            return self.filters[filter_name] 
    360338        else: 
    361             raise TemplateSyntaxError, "Invalid filter: '%s'" % filter_name 
    362  
    363 class DebugParser(Parser): 
    364     def __init__(self, lexer): 
    365         super(DebugParser, self).__init__(lexer) 
    366         self.command_stack = [] 
    367  
    368     def enter_command(self, command, token): 
    369         self.command_stack.append( (command, token.source) ) 
    370  
    371     def exit_command(self): 
    372         self.command_stack.pop() 
    373  
    374     def error(self, token, msg): 
    375         return self.source_error(token.source, msg) 
    376  
    377     def source_error(self, source,msg): 
    378         e = TemplateSyntaxError(msg) 
    379         e.source = source 
    380         return e 
    381  
    382     def create_nodelist(self): 
    383         return DebugNodeList() 
    384  
    385     def create_variable_node(self, contents): 
    386         return DebugVariableNode(contents) 
    387  
    388     def extend_nodelist(self, nodelist, node, token): 
    389         node.source = token.source 
    390         super(DebugParser, self).extend_nodelist(nodelist, node, token) 
    391  
    392     def unclosed_block_tag(self, parse_until): 
    393         command, source = self.command_stack.pop() 
    394         msg = "Unclosed tag '%s'. Looking for one of: %s " % (command, ', '.join(parse_until)) 
    395         raise self.source_error( source, msg) 
    396  
    397     def compile_function_error(self, token, e): 
    398         if not hasattr(e, 'source'): 
    399             e.source = token.source 
    400  
    401 def lexer_factory(*args, **kwargs): 
    402     if settings.TEMPLATE_DEBUG: 
    403         return DebugLexer(*args, **kwargs) 
    404     else: 
    405         return Lexer(*args, **kwargs) 
    406  
    407 def parser_factory(*args, **kwargs): 
    408     if settings.TEMPLATE_DEBUG: 
    409         return DebugParser(*args, **kwargs) 
    410     else: 
    411         return Parser(*args, **kwargs) 
     339            raise TemplateSyntaxError("Invalid filter: '%s'" % filter_name) 
    412340 
    413341class TokenParser(object): 
     
    427355    def top(self): 
    428356        "Overload this method to do the actual parsing and return the result." 
    429         raise NotImplemented 
     357        raise NotImplementedError() 
    430358 
    431359    def more(self): 
     
    436364        "Undoes the last microparser. Use this for lookahead and backtracking." 
    437365        if not len(self.backout): 
    438             raise TemplateSyntaxError, "back called without some previous parsing" 
     366            raise TemplateSyntaxError("back called without some previous parsing") 
    439367        self.pointer = self.backout.pop() 
    440368 
     
    444372        i = self.pointer 
    445373        if i >= len(subject): 
    446             raise TemplateSyntaxError, "expected another tag, found end of string: %s" % subject 
     374            raise TemplateSyntaxError("expected another tag, found end of string: %s" % subject) 
    447375        p = i 
    448376        while i < len(subject) and subject[i] not in (' ', '\t'): 
     
    460388        i = self.pointer 
    461389        if i >= len(subject): 
    462             raise TemplateSyntaxError, "Searching for value. Expected another value but found end of string: %s" % subject 
     390            raise TemplateSyntaxError("Searching for value. Expected another value but found end of string: %s" % subject) 
    463391        if subject[i] in ('"', "'"): 
    464392            p = i 
     
    467395                i += 1 
    468396            if i >= len(subject): 
    469                 raise TemplateSyntaxError, "Searching for value. Unexpected end of string in column %d: %s" % (i, subject
     397                raise TemplateSyntaxError("Searching for value. Unexpected end of string in column %d: %s" % (i, subject)
    470398            i += 1 
    471399            res = subject[p:i] 
     
    484412                        i += 1 
    485413                    if i >= len(subject): 
    486                         raise TemplateSyntaxError, "Searching for value. Unexpected end of string in column %d: %s" % (i, subject
     414                        raise TemplateSyntaxError("Searching for value. Unexpected end of string in column %d: %s" % (i, subject)
    487415                i += 1 
    488416            s = subject[p:i] 
     
    543471            start = match.start() 
    544472            if upto != start: 
    545                 raise TemplateSyntaxError, "Could not parse some characters: %s|%s|%s"  % \ 
    546                                            (token[:upto], token[upto:start], token[start:]) 
     473                raise TemplateSyntaxError("Could not parse some characters: %s|%s|%s"  % \ 
     474                                           (token[:upto], token[upto:start], token[start:])) 
    547475            if var == None: 
    548476                var, constant, i18n_constant = match.group("var", "constant", "i18n_constant") 
     
    553481                upto = match.end() 
    554482                if var == None: 
    555                     raise TemplateSyntaxError, "Could not find variable at start of %s" % token 
     483                    raise TemplateSyntaxError("Could not find variable at start of %s" % token) 
    556484                elif var.find(VARIABLE_ATTRIBUTE_SEPARATOR + '_') > -1 or var[0] == '_': 
    557                     raise TemplateSyntaxError, "Variables and attributes may not begin with underscores: '%s'" % var 
     485                    raise TemplateSyntaxError("Variables and attributes may not begin with underscores: '%s'" % var) 
    558486            else: 
    559487                filter_name = match.group("filter_name") 
     
    571499                upto = match.end() 
    572500        if upto != len(token): 
    573             raise TemplateSyntaxError, "Could not parse the remainder: '%s' from '%s'" % (token[upto:], token
     501            raise TemplateSyntaxError("Could not parse the remainder: '%s' from '%s'" % (token[upto:], token)
    574502        self.filters = filters 
    575503        self.var = Variable(var) 
     
    628556        except IndexError: 
    629557            # Not enough 
    630             raise TemplateSyntaxError, "%s requires %d arguments, %d provided" % (name, len(nondefs), plen
     558            raise TemplateSyntaxError("%s requires %d arguments, %d provided" % (name, len(nondefs), plen)
    631559 
    632560        # Defaults can be overridden. 
     
    637565        except IndexError: 
    638566            # Too many. 
    639             raise TemplateSyntaxError, "%s requires %d arguments, %d provided" % (name, len(nondefs), plen
     567            raise TemplateSyntaxError("%s requires %d arguments, %d provided" % (name, len(nondefs), plen)
    640568 
    641569        return True 
     
    817745        return node.render(context) 
    818746 
    819 class DebugNodeList(NodeList): 
    820     def render_node(self, node, context): 
    821         try: 
    822             result = node.render(context) 
    823         except TemplateSyntaxError, e: 
    824             if not hasattr(e, 'source'): 
    825                 e.source = node.source 
    826             raise 
    827         except Exception, e: 
    828             from sys import exc_info 
    829             wrapped = TemplateSyntaxError('Caught an exception while rendering: %s' % e) 
    830             wrapped.source = node.source 
    831             wrapped.exc_info = exc_info() 
    832             raise wrapped 
    833         return result 
    834  
    835747class TextNode(Node): 
    836748    def __init__(self, s): 
     
    862774            return force_unicode(output) 
    863775 
    864 class DebugVariableNode(VariableNode): 
    865     def render(self, context): 
    866         try: 
    867             output = force_unicode(self.filter_expression.resolve(context)) 
    868         except TemplateSyntaxError, e: 
    869             if not hasattr(e, 'source'): 
    870                 e.source = self.source 
    871             raise 
    872         except UnicodeDecodeError: 
    873             return '' 
    874         if (context.autoescape and not isinstance(output, SafeData)) or isinstance(output, EscapeData): 
    875             return escape(output) 
    876         else: 
    877             return output 
    878  
    879776def generic_tag_compiler(params, defaults, name, node_class, parser, token): 
    880777    "Returns a template.Node subclass." 
     
    888785        else: 
    889786            message = "%s takes between %s and %s arguments" % (name, bmin, bmax) 
    890         raise TemplateSyntaxError, message 
     787        raise TemplateSyntaxError(message) 
    891788    return node_class(bits) 
    892789 
     
    914811            return compile_function 
    915812        else: 
    916             raise InvalidTemplateLibrary, "Unsupported arguments to Library.tag: (%r, %r)", (name, compile_function
     813            raise InvalidTemplateLibrary("Unsupported arguments to Library.tag: (%r, %r)", (name, compile_function)
    917814 
    918815    def tag_function(self,func): 
     
    938835            return filter_func 
    939836        else: 
    940             raise InvalidTemplateLibrary, "Unsupported arguments to Library.filter: (%r, %r)", (name, filter_func
     837            raise InvalidTemplateLibrary("Unsupported arguments to Library.filter: (%r, %r)", (name, filter_func)
    941838 
    942839    def filter_function(self, func): 
     
    967864                    params = params[1:] 
    968865                else: 
    969                     raise TemplateSyntaxError, "Any tag function decorated with takes_context=True must have a first argument of 'context'" 
     866                    raise TemplateSyntaxError("Any tag function decorated with takes_context=True must have a first argument of 'context'") 
    970867 
    971868            class InclusionNode(Node): 
     
    1004901            mod = __import__(module_name, {}, {}, ['']) 
    1005902        except ImportError, e: 
    1006             raise InvalidTemplateLibrary, "Could not load template library from %s, %s" % (module_name, e
     903            raise InvalidTemplateLibrary("Could not load template library from %s, %s" % (module_name, e)
    1007904        try: 
    1008905            lib = mod.register 
    1009906            libraries[module_name] = lib 
    1010907        except AttributeError: 
    1011             raise InvalidTemplateLibrary, "Template library %s does not have a variable named 'register'" % module_name 
     908            raise InvalidTemplateLibrary("Template library %s does not have a variable named 'register'" % module_name) 
    1012909    return lib 
    1013910 
  • django/branches/queryset-refactor/django/views/debug.py

    r6954 r7004  
    508508</textarea> 
    509509  <br><br> 
    510   <input type="submit" value="Share this traceback on public Web site"> 
     510  <input type="submit" value="Share this traceback on a public Web site"> 
    511511  </div> 
    512512</form> 
  • django/branches/queryset-refactor/docs/django-admin.txt

    r6954 r7004  
    717717variable. 
    718718 
    719 Note that this option is unnecessary in ``manage.py``, because it takes care of 
    720 setting ``DJANGO_SETTINGS_MODULE`` for you. 
     719Note that this option is unnecessary in ``manage.py``, because it uses 
     720``settings.py`` from the current project by default.  
    721721 
    722722Extra niceties 
  • django/branches/queryset-refactor/docs/localflavor.txt

    r6954 r7004  
    182182 
    183183A form field that validates input as a Canadian Social Insurance Number (SIN). 
    184 A valid number must have the format XXX-XXX-XXXX and pass a `Luhn mod-10 
     184A valid number must have the format XXX-XXX-XXX and pass a `Luhn mod-10 
    185185checksum`_. 
    186186 
  • django/branches/queryset-refactor/docs/middleware.txt

    r6954 r7004  
    154154 
    155155.. _Authentication in Web requests: ../authentication/#authentication-in-web-requests 
     156 
     157django.contrib.csrf.middleware.CsrfMiddleware 
     158--------------------------------------------- 
     159 
     160**New in Django development version** 
     161 
     162Adds protection against Cross Site Request Forgeries by adding hidden form 
     163fields to POST forms and checking requests for the correct value. See the 
     164`Cross Site Request Forgery protection documentation`_. 
     165 
     166.. _`Cross Site Request Forgery protection documentation`: ../csrf/ 
    156167 
    157168django.middleware.transaction.TransactionMiddleware 
  • django/branches/queryset-refactor/docs/sites.txt

    r6334 r7004  
    9898 
    9999On a lower level, you can use the sites framework in your Django views to do 
    100 particular things based on what site in which the view is being called. 
     100particular things based on the site in which the view is being called. 
    101101For example:: 
    102102 
     
    331331 
    332332    * In the `syndication framework`_, the templates for ``title`` and 
    333       ``description`` automatically have access to a variable ``{{{ site }}}``, 
     333      ``description`` automatically have access to a variable ``{{ site }}``, 
    334334      which is the ``Site`` object representing the current site. Also, the 
    335335      hook for providing item URLs will use the ``domain`` from the current 
     
    337337 
    338338    * In the `authentication framework`_, the ``django.contrib.auth.views.login`` 
    339       view passes the current ``Site`` name to the template as ``{{{ site_name }}}``. 
     339      view passes the current ``Site`` name to the template as ``{{ site_name }}``. 
    340340 <