#12104: Object->object lookup fails in blocktrans
-------------------------------------------+--------------------------------
          Reporter:  philipn               |         Owner:  nobody
            Status:  reopened              |     Milestone:        
         Component:  Internationalization  |       Version:  1.1   
        Resolution:                        |      Keywords:        
             Stage:  Unreviewed            |     Has_patch:  1     
        Needs_docs:  0                     |   Needs_tests:  0     
Needs_better_patch:  0                     |  
-------------------------------------------+--------------------------------
Changes (by philipn):

  * status:  closed => reopened
  * resolution:  invalid =>

Comment:

 If this is to keep translations simple then that makes sense, especially
 considering blocktrans doesn't allow for other blocks inside it.

 Adding support for other block tags inside of blocktrans seems easy enough
 to add, though (using the same idea as my patch -- executing a template
 rendering).

 But, unlike other blocks in blocktrans, this kind of variable access
 doesn't trigger an error message.

 I've attached a patch that causes an error to be displayed when you try
 and use complex variable lookups inside a blocktrans block.

 If we did decide to allow for variable.attr syntax then it would probably
 be better to use django.template's Variable class to look up the
 variable's values rather than the context-dictionary-key approach used in
 the code currently.

 I guess it's also worth noting that the current blocktrans variable lookup
 behaviour will throw a keyerror for{{{ {{ variable_that_isnt_in_context }}
 }}}when templates normally do not.  With this in mind it really seems like
 the right thing to do is to replace the lookup behaviour with
 {{{Variable(..).resolve()}}}.  I've attached a patch that does this, as
 well.

-- 
Ticket URL: <http://code.djangoproject.com/ticket/12104#comment:2>
Django <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