You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@shindig.apache.org by Mat Mannion <M....@warwick.ac.uk> on 2010/04/20 11:17:35 UTC

Nested substitution of "hangman" variables

Hi all,

I am having issues getting a couple of Google's gadgets to display
properly where there is nested substitution of "hangman" variables in
(Java) shindig.

The basic issue is using hangman substitution in an attribute to
ModulePrefs (generally the title attribute), where the default_value
of the user pref is __MSG_ substitution. There is an example of this
in action here: http://www.google.com/ig/modules/todo.xml or you can
consider the pathological case:

<Module>
  <ModulePrefs title="__UP_title__">
   <Locale>
    <msg name="title">Gadget title</msg>
   </Locale>
  </ModulePrefs>
  <UserPref name="title" default_value="__MSG_title__" />
  <Content>__MSG_title__</Content>
</Module>

My expected behaviour would be for the title to be displayed as
"Gadget title". The UserPref itself has the default value replaced, so
when it is rendered the value of the title pref is correctly
displayed. Looking through the source at
org.apache.shindig.gadgets.spec.GadgetSpec#substitute(Substitutions
substituter) and the related code in
org.apache.shindig.gadgets.variables.VariableSubstituter it would seem
that this is (at least partially) intentional to avoid infinite
recursion (for example in the case where the default_value of the
UserPref is __UP_title__ or points to some other user pref that points
back to the title one).

iGoogle handles the case correctly (as you'd expect) and we'd quite
like it to be handled as well. We use a custom GadgetSpecParser to
inject an extra UserPref at the top of all gadgets and then rewrite
the title attribute to be __UP_WARWICK_title__", which allows all our
gadgets to have custom titles, but at the moment this is breaking all
internationalised gadgets because the title is appearing as
__MSG_title__ instead of the internationalised string.

I'm not even sure this is a bug - could someone confirm? It's
relatively easy to reproduce in a unit test in VariableSubstituterTest
simply by adding something like the gadget spec I've written above and
looking for spec.getModulePrefs().getTitle() in an assertion.

Many thanks,

Mat

-- 
Mat Mannion
Web Developer
e-lab, IT Services
University of Warwick
Coventry
CV4 7AL

Tel: 024 765 74433
Email: M.Mannion@warwick.ac.uk

Re: Nested substitution of "hangman" variables

Posted by John Hjelmstad <fa...@google.com>.
This sounds familiar, though I can't recall the specific discussions on it
way back. It does sound like unimplemented behavior to me... I'd be happy to
look at a patch implementing a fix.

--j

On Tue, Apr 20, 2010 at 2:17 AM, Mat Mannion <M....@warwick.ac.uk>wrote:

> Hi all,
>
> I am having issues getting a couple of Google's gadgets to display
> properly where there is nested substitution of "hangman" variables in
> (Java) shindig.
>
> The basic issue is using hangman substitution in an attribute to
> ModulePrefs (generally the title attribute), where the default_value
> of the user pref is __MSG_ substitution. There is an example of this
> in action here: http://www.google.com/ig/modules/todo.xml or you can
> consider the pathological case:
>
> <Module>
>  <ModulePrefs title="__UP_title__">
>   <Locale>
>    <msg name="title">Gadget title</msg>
>   </Locale>
>  </ModulePrefs>
>  <UserPref name="title" default_value="__MSG_title__" />
>  <Content>__MSG_title__</Content>
> </Module>
>
> My expected behaviour would be for the title to be displayed as
> "Gadget title". The UserPref itself has the default value replaced, so
> when it is rendered the value of the title pref is correctly
> displayed. Looking through the source at
> org.apache.shindig.gadgets.spec.GadgetSpec#substitute(Substitutions
> substituter) and the related code in
> org.apache.shindig.gadgets.variables.VariableSubstituter it would seem
> that this is (at least partially) intentional to avoid infinite
> recursion (for example in the case where the default_value of the
> UserPref is __UP_title__ or points to some other user pref that points
> back to the title one).
>
> iGoogle handles the case correctly (as you'd expect) and we'd quite
> like it to be handled as well. We use a custom GadgetSpecParser to
> inject an extra UserPref at the top of all gadgets and then rewrite
> the title attribute to be __UP_WARWICK_title__", which allows all our
> gadgets to have custom titles, but at the moment this is breaking all
> internationalised gadgets because the title is appearing as
> __MSG_title__ instead of the internationalised string.
>
> I'm not even sure this is a bug - could someone confirm? It's
> relatively easy to reproduce in a unit test in VariableSubstituterTest
> simply by adding something like the gadget spec I've written above and
> looking for spec.getModulePrefs().getTitle() in an assertion.
>
> Many thanks,
>
> Mat
>
> --
> Mat Mannion
> Web Developer
> e-lab, IT Services
> University of Warwick
> Coventry
> CV4 7AL
>
> Tel: 024 765 74433
> Email: M.Mannion@warwick.ac.uk
>