Am 20.07.2008 um 21:48 schrieb Malcolm Tredinnick:
>> Especially unquoted non-ascii strings (as in test url05) are ugly
>
> Subjective; not a technical reason. Non-ASCII strings look just the
> same
> as ASCII strings. In fact, many non-Latin scripts are much prettier
> than
> the Latin alphabet (just as subjective as your opinion, of
> course :-)).
Of course that's subjective, everything is.
>> and
>> would require hacks or re.LOCALE in my approach in #7806.
>
> That would suggest a problem in the approach in that patch. :-)
>
> There's more than one template tag in Django that treats unquoted
> strings of characters as non-literals, although the url tag may be the
> only one at the moment where non-ASCII strings are fairly natural. We
> shouldn't rule them out, though. That needs to be handled by any
> template parsing code. Non-ASCII strings are just as easy to handle as
> ASCII strings in code. If you're at the point of thinking you need to
> use re.LOCALE, it suggests you're trying to be too strict in the error
> checking and loosening that up a bit would be faster, lead to
> easier to
> read code and avoid difficulties like this.
Afaics the only other tag that would accept an arbitrary unquoted
literal is {% ssi %}.
Are there more?
Variables are currently matched with [\w.] (at least in filter
expressions) and that's what I use to match keywords and vars.
bit_re = re.compile(r"""
(?P<string_literal>"(?:[^"\\]*(?:\\.[^"\\]*)*)"|'(?:[^'\\]*(?:\\.
[^'\\]*)*)')
|(?P<numeric_literal>\b[+-]?\.?\d[\d\.e]*\b)
|(?P<name>[\w.]+) # keyword or variable
|(?P<char>\S) # punctuation
""", re.VERBOSE)
tokens = [(bit.lastgroup, bit.group(0)) for bit in bit_re.finditer
(contents)]
Seems like I have to rethink this then.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-developers?hl=en
-~----------~----~----~----~------~----~------~--~---