Ticket #12070: patch-12070.diff

File patch-12070.diff, 2.1 KB (added by alexdutton, 15 years ago)

Patch (Unindented '...'s to match style in other doctests)

  • django/template/__init__.py

     
    538538                        var_obj = None
    539539                elif var is None:
    540540                    raise TemplateSyntaxError("Could not find variable at start of %s." % token)
    541                 elif var.find(VARIABLE_ATTRIBUTE_SEPARATOR + '_') > -1 or var[0] == '_':
    542                     raise TemplateSyntaxError("Variables and attributes may not begin with underscores: '%s'" % var)
    543541                else:
    544542                    var_obj = Variable(var)
    545543            else:
     
    698696            except ValueError:
    699697                # Otherwise we'll set self.lookups so that resolve() knows we're
    700698                # dealing with a bonafide variable
     699                if var.find(VARIABLE_ATTRIBUTE_SEPARATOR + '_') > -1 or var[0] == '_':
     700                    raise TemplateSyntaxError("Variables and attributes may not begin with underscores: '%s'" % var)
    701701                self.lookups = tuple(var.split(VARIABLE_ATTRIBUTE_SEPARATOR))
    702702
    703703    def resolve(self, context):
  • tests/regressiontests/templates/parser.py

     
    7676[]
    7777>>> fe.var
    7878u'Some "Good" News'
     79
     80Filtered variables should reject access of attributes beginning with underscores.
     81
     82>>> FilterExpression('article._hidden|upper', p)
     83Traceback (most recent call last):
     84...
     85TemplateSyntaxError: Variables and attributes may not begin with underscores: 'article._hidden'
    7986"""
    8087
    8188variable_parsing = r"""
     
    105112>>> Variable(ur"'Some \'Better\' News'").resolve(c)
    106113u"Some 'Better' News"
    107114
     115Variables should reject access of attributes beginning with underscores.
     116
     117>>> Variable('article._hidden')
     118Traceback (most recent call last):
     119...
     120TemplateSyntaxError: Variables and attributes may not begin with underscores: 'article._hidden'
    108121"""
Back to Top