Django

Code

Show
Ignore:
Timestamp:
07/16/08 14:21:15 (6 months ago)
Author:
brosner
Message:

newforms-admin: Fixed #5490 -- Properly quote special characters in primary keys in the admin. Added tests to ensure functionality. This also moves quote and unquote to django/contrib/admin/util.py. Thanks jdetaeye and shanx for all your help.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/branches/newforms-admin/django/contrib/admin/views/main.py

    r7881 r7935  
    11from django.contrib.admin.filterspecs import FilterSpec 
    22from django.contrib.admin.options import IncorrectLookupParameters 
     3from django.contrib.admin.util import quote 
    34from django.core.paginator import Paginator, InvalidPage 
    45from django.db import models 
     
    3031# Text to display within change-list table cells if the value is blank. 
    3132EMPTY_CHANGELIST_VALUE = '(None)' 
    32  
    33 def quote(s): 
    34     """ 
    35     Ensure that primary key values do not confuse the admin URLs by escaping 
    36     any '/', '_' and ':' characters. Similar to urllib.quote, except that the 
    37     quoting is slightly different so that it doesn't get automatically 
    38     unquoted by the Web browser. 
    39     """ 
    40     if type(s) != type(''): 
    41         return s 
    42     res = list(s) 
    43     for i in range(len(res)): 
    44         c = res[i] 
    45         if c in ':/_': 
    46             res[i] = '_%02X' % ord(c) 
    47     return ''.join(res) 
    4833 
    4934class ChangeList(object):