#4862: Unicode canges break
-------------------------------------+--------------------------------------
Reporter:  [EMAIL PROTECTED]  |       Owner:  adrian         
  Status:  new                       |   Component:  Admin interface
 Version:  SVN                       |    Keywords:  unicode        
   Stage:  Unreviewed                |   Has_patch:  1              
-------------------------------------+--------------------------------------
 My application has models with a string as primary key.
 With the recent unicode changes this creates invalid javascript code for
 the popup windows. Because of the javascript error the popup window
 doesn't close any more.
 
 Invalid code:
 {{{
 <tr class="row2"><th><a href="product/"
    onclick="opener.dismissRelatedLookupPopup(window, u'product'); return
 false;">product</a></th>
   <td>None</td><td>None</td><td>None</td><td>(None)</td><td>(None)</td><td
 class="nowrap">July 12, 2007, 5:48 p.m.</td></tr>
 }}}
 Notice the "u'product'" part.
 
 Digging a bit deeper I found the lines 193-195 of the file
 django/contrib/admin/templatetags/admin_list.py to be the culprit.
 Original code:
 {{{
    result_id = smart_unicode(getattr(result, pk)) # conversion to string
 is needed in case of 23L (long ints)
    yield (u'<%s%s><a href="%s"%s>%s</a></%s>' % \
             (table_tag, row_class, url, (cl.is_popup and '
 onclick="opener.dismissRelatedLookupPopup(window, %r); return false;"'
                 % result_id or ''), result_repr, table_tag))
 }}}
 The revised code below fixes the problem in my case, but I am unsure
 whether this is a generic and complete fix:
 {{{
    result_id = smart_unicode(getattr(result, pk)) # conversion to string
 is needed in case of 23L (long ints)
    yield (u'<%s%s><a href="%s"%s>%s</a></%s>' % \
             (table_tag, row_class, url, (cl.is_popup and u'
 onclick="opener.dismissRelatedLookupPopup(window, \'%s\'); return false;"'
                 % result_id or ''), result_repr, table_tag))
 }}}

-- 
Ticket URL: <http://code.djangoproject.com/ticket/4862>
Django Code <http://code.djangoproject.com/>
The web framework for perfectionists with deadlines
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django updates" 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-updates?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to