Loading ...
Sorry, an error occurred while loading the content.

[Cheetahtemplate-discuss] getVar inconsistency

Expand Messages
  • Michał Żyliński
    After trying to unsuccesfuly use simplified form of getVar function (ie. $getVar( myvalue ) which is supposed to return empty string in case $myvalue is not
    Message 1 of 17 , Apr 26, 2005
    • 0 Attachment
      After trying to unsuccesfuly use simplified form of getVar function
      (ie. $getVar('myvalue') which is supposed to return empty string in
      case $myvalue is not present) I browsed through the sources and I'm
      wondering why there it is done like this:


      def getVar(self, varName, default=NoDefault, autoCall=True):

      """Get a variable from the searchList. If the variable can't be found
      in the searchList, it returns the default value if one was given, or
      raises NameMapper.NotFound."""

      try:
      return VFS(self.searchList(), varName.replace('$',''), autoCall)
      except NotFound:
      if default != NoDefault:
      return default
      else:
      raise

      instead of simply:

      def getVar(self, varName, default='', autoCall=True):
      try:
      return VFS(self.searchList(), varName.replace('$',''), autoCall)
      except NotFound
      return default

      The above, shorter version matches the functionality described in documentation.

      Michal


      -------------------------------------------------------
      SF.Net email is sponsored by: Tell us your software development plans!
      Take this survey and enter to win a one-year sub to SourceForge.net
      Plus IDC's 2005 look-ahead and a copy of this survey
      Click here to start! http://www.idcswdc.com/cgi-bin/survey?id5hix
      _______________________________________________
      Cheetahtemplate-discuss mailing list
      Cheetahtemplate-discuss@...
      https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss
    • Shannon -jj Behrens
      Yep, you have a point. The docs say it should return None in this case, but instead it raises an exception. In Python, dict.get returns None by default in
      Message 2 of 17 , Apr 26, 2005
      • 0 Attachment
        Yep, you have a point. The docs say it should return None in this
        case, but instead it raises an exception. In Python, dict.get returns
        None by default in this case, although gettattr raises an exception.
        I'd vote for the code being updated to return None.

        Best Regards,
        -jj

        On 4/26/05, Michał Żyliński <michal.zylinski@...> wrote:
        > After trying to unsuccesfuly use simplified form of getVar function
        > (ie. $getVar('myvalue') which is supposed to return empty string in
        > case $myvalue is not present) I browsed through the sources and I'm
        > wondering why there it is done like this:
        >
        > def getVar(self, varName, default=NoDefault, autoCall=True):
        >
        > """Get a variable from the searchList. If the variable can't be found
        > in the searchList, it returns the default value if one was given, or
        > raises NameMapper.NotFound."""
        >
        > try:
        > return VFS(self.searchList(), varName.replace('$',''), autoCall)
        > except NotFound:
        > if default != NoDefault:
        > return default
        > else:
        > raise
        >
        > instead of simply:
        >
        > def getVar(self, varName, default='', autoCall=True):
        > try:
        > return VFS(self.searchList(), varName.replace('$',''), autoCall)
        > except NotFound
        > return default
        >
        > The above, shorter version matches the functionality described in documentation.

        --
        I have decided to switch to Gmail, but messages to my Yahoo account will
        still get through.
      • mso@oz.net
        Unfortunately for Michal, the mistake is in the documentation. $getVar is patterned after getattr(), which returns a default or raises an error as the user
        Message 3 of 17 , Apr 26, 2005
        • 0 Attachment
          Unfortunately for Michal, the mistake is in the documentation. $getVar is
          patterned after getattr(), which returns a default or raises an error as
          the user desires. If we change it, there would be no way to look up a
          dynamically-calculated name with an exception if it's missing. We'd also
          have to see whether Cheetah uses .getVar internally.

          Michal is better off with a fixed ErrorCatcher. Alternatively, he could
          subclass or #extends Template and provide his own method.

          The reason people don't use ErrorCatcher is the exception-catching
          overhead. People try to avoid it and find they don't even need it most of
          the time.

          JJ, could you fix the documentation? Thanks.

          -- Mike Orr <mso@...>

          JJ wrote:
          > Yep, you have a point. The docs say it should return None in this
          > case, but instead it raises an exception. In Python, dict.get returns
          > None by default in this case, although gettattr raises an exception.
          > I'd vote for the code being updated to return None.
          >
          > Best Regards,
          > -jj
          >
          > On 4/26/05, Micha³ ¯yliñski <michal.zylinski@...> wrote:
          >> After trying to unsuccesfuly use simplified form of getVar function
          >> (ie. $getVar('myvalue') which is supposed to return empty string in
          >> case $myvalue is not present) I browsed through the sources and I'm
          >> wondering why there it is done like this:
          >>
          >> def getVar(self, varName, default=NoDefault, autoCall=True):
          >>
          >> """Get a variable from the searchList. If the variable can't be
          >> found
          >> in the searchList, it returns the default value if one was
          >> given, or
          >> raises NameMapper.NotFound."""
          >>
          >> try:
          >> return VFS(self.searchList(), varName.replace('$',''),
          >> autoCall)
          >> except NotFound:
          >> if default != NoDefault:
          >> return default
          >> else:
          >> raise
          >>
          >> instead of simply:
          >>
          >> def getVar(self, varName, default='', autoCall=True):
          >> try:
          >> return VFS(self.searchList(), varName.replace('$',''),
          >> autoCall)
          >> except NotFound
          >> return default
          >>
          >> The above, shorter version matches the functionality described in
          >> documentation.
          >
          > --
          > I have decided to switch to Gmail, but messages to my Yahoo account will
          > still get through.
          >




          -------------------------------------------------------
          SF.Net email is sponsored by: Tell us your software development plans!
          Take this survey and enter to win a one-year sub to SourceForge.net
          Plus IDC's 2005 look-ahead and a copy of this survey
          Click here to start! http://www.idcswdc.com/cgi-bin/survey?id=105hix
          _______________________________________________
          Cheetahtemplate-discuss mailing list
          Cheetahtemplate-discuss@...
          https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss
        • Shannon -jj Behrens
          Mike, Sure, I ll fix the documentation. Tavis, can you confirm that we should pattern this after getattr instead of dict.get? Thanks, -jj ... -- I have
          Message 4 of 17 , Apr 26, 2005
          • 0 Attachment
            Mike,

            Sure, I'll fix the documentation. Tavis, can you confirm that we
            should pattern this after getattr instead of dict.get?

            Thanks,
            -jj

            On 4/26/05, mso@... <mso@...> wrote:
            > Unfortunately for Michal, the mistake is in the documentation. $getVar is
            > patterned after getattr(), which returns a default or raises an error as
            > the user desires. If we change it, there would be no way to look up a
            > dynamically-calculated name with an exception if it's missing. We'd also
            > have to see whether Cheetah uses .getVar internally.
            >
            > Michal is better off with a fixed ErrorCatcher. Alternatively, he could
            > subclass or #extends Template and provide his own method.
            >
            > The reason people don't use ErrorCatcher is the exception-catching
            > overhead. People try to avoid it and find they don't even need it most of
            > the time.
            >
            > JJ, could you fix the documentation? Thanks.
            >
            > -- Mike Orr <mso@...>
            >
            > JJ wrote:
            > > Yep, you have a point. The docs say it should return None in this
            > > case, but instead it raises an exception. In Python, dict.get returns
            > > None by default in this case, although gettattr raises an exception.
            > > I'd vote for the code being updated to return None.
            > >
            > > Best Regards,
            > > -jj
            > >
            > > On 4/26/05, Micha³ ¯yliñski <michal.zylinski@...> wrote:
            > >> After trying to unsuccesfuly use simplified form of getVar function
            > >> (ie. $getVar('myvalue') which is supposed to return empty string in
            > >> case $myvalue is not present) I browsed through the sources and I'm
            > >> wondering why there it is done like this:
            > >>
            > >> def getVar(self, varName, default=NoDefault, autoCall=True):
            > >>
            > >> """Get a variable from the searchList. If the variable can't be
            > >> found
            > >> in the searchList, it returns the default value if one was
            > >> given, or
            > >> raises NameMapper.NotFound."""
            > >>
            > >> try:
            > >> return VFS(self.searchList(), varName.replace('$',''),
            > >> autoCall)
            > >> except NotFound:
            > >> if default != NoDefault:
            > >> return default
            > >> else:
            > >> raise
            > >>
            > >> instead of simply:
            > >>
            > >> def getVar(self, varName, default='', autoCall=True):
            > >> try:
            > >> return VFS(self.searchList(), varName.replace('$',''),
            > >> autoCall)
            > >> except NotFound
            > >> return default
            > >>
            > >> The above, shorter version matches the functionality described in
            > >> documentation.
            > >
            > > --
            > > I have decided to switch to Gmail, but messages to my Yahoo account will
            > > still get through.
            > >
            >
            >


            --
            I have decided to switch to Gmail, but messages to my Yahoo account will
            still get through.


            -------------------------------------------------------
            SF.Net email is sponsored by: Tell us your software development plans!
            Take this survey and enter to win a one-year sub to SourceForge.net
            Plus IDC's 2005 look-ahead and a copy of this survey
            Click here to start! http://www.idcswdc.com/cgi-bin/survey?id5hix
            _______________________________________________
            Cheetahtemplate-discuss mailing list
            Cheetahtemplate-discuss@...
            https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss
          • Tavis Rudd
            yep ... SF.Net email is sponsored by: Tell us your software development plans! Take this survey and enter to win a one-year sub to SourceForge.net Plus IDC s
            Message 5 of 17 , Apr 26, 2005
            • 0 Attachment
              yep
              On Tuesday 26 April 2005 16:20, Shannon -jj Behrens wrote:
              > Mike,
              >
              > Sure, I'll fix the documentation. Tavis, can you confirm that we
              > should pattern this after getattr instead of dict.get?
              >
              > Thanks,
              > -jj
              >
              > On 4/26/05, mso@... <mso@...> wrote:
              > > Unfortunately for Michal, the mistake is in the documentation. $getVar
              > > is patterned after getattr(), which returns a default or raises an error
              > > as the user desires. If we change it, there would be no way to look up a
              > > dynamically-calculated name with an exception if it's missing. We'd also
              > > have to see whether Cheetah uses .getVar internally.
              > >
              > > Michal is better off with a fixed ErrorCatcher. Alternatively, he could
              > > subclass or #extends Template and provide his own method.
              > >
              > > The reason people don't use ErrorCatcher is the exception-catching
              > > overhead. People try to avoid it and find they don't even need it most
              > > of the time.
              > >
              > > JJ, could you fix the documentation? Thanks.
              > >
              > > -- Mike Orr <mso@...>
              > >
              > > JJ wrote:
              > > > Yep, you have a point. The docs say it should return None in this
              > > > case, but instead it raises an exception. In Python, dict.get returns
              > > > None by default in this case, although gettattr raises an exception.
              > > > I'd vote for the code being updated to return None.
              > > >
              > > > Best Regards,
              > > > -jj
              > > >
              > > > On 4/26/05, Micha³ ¯yliñski <michal.zylinski@...> wrote:
              > > >> After trying to unsuccesfuly use simplified form of getVar function
              > > >> (ie. $getVar('myvalue') which is supposed to return empty string in
              > > >> case $myvalue is not present) I browsed through the sources and I'm
              > > >> wondering why there it is done like this:
              > > >>
              > > >> def getVar(self, varName, default=NoDefault, autoCall=True):
              > > >>
              > > >> """Get a variable from the searchList. If the variable can't
              > > >> be found
              > > >> in the searchList, it returns the default value if one was
              > > >> given, or
              > > >> raises NameMapper.NotFound."""
              > > >>
              > > >> try:
              > > >> return VFS(self.searchList(), varName.replace('$',''),
              > > >> autoCall)
              > > >> except NotFound:
              > > >> if default != NoDefault:
              > > >> return default
              > > >> else:
              > > >> raise
              > > >>
              > > >> instead of simply:
              > > >>
              > > >> def getVar(self, varName, default='', autoCall=True):
              > > >> try:
              > > >> return VFS(self.searchList(), varName.replace('$',''),
              > > >> autoCall)
              > > >> except NotFound
              > > >> return default
              > > >>
              > > >> The above, shorter version matches the functionality described in
              > > >> documentation.
              > > >
              > > > --
              > > > I have decided to switch to Gmail, but messages to my Yahoo account
              > > > will still get through.


              -------------------------------------------------------
              SF.Net email is sponsored by: Tell us your software development plans!
              Take this survey and enter to win a one-year sub to SourceForge.net
              Plus IDC's 2005 look-ahead and a copy of this survey
              Click here to start! http://www.idcswdc.com/cgi-bin/survey?id5hix
              _______________________________________________
              Cheetahtemplate-discuss mailing list
              Cheetahtemplate-discuss@...
              https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss
            • Shannon -jj Behrens
              Done. I m glad to have a chance to earn my keep ;) -jj ... -- I have decided to switch to Gmail, but messages to my Yahoo account will still get through. ...
              Message 6 of 17 , Apr 26, 2005
              • 0 Attachment
                Done. I'm glad to have a chance to earn my keep ;)

                -jj

                On 4/26/05, Tavis Rudd <tavis@...> wrote:
                > yep
                > On Tuesday 26 April 2005 16:20, Shannon -jj Behrens wrote:
                > > Mike,
                > >
                > > Sure, I'll fix the documentation. Tavis, can you confirm that we
                > > should pattern this after getattr instead of dict.get?
                > >
                > > Thanks,
                > > -jj
                > >
                > > On 4/26/05, mso@... <mso@...> wrote:
                > > > Unfortunately for Michal, the mistake is in the documentation. $getVar
                > > > is patterned after getattr(), which returns a default or raises an error
                > > > as the user desires. If we change it, there would be no way to look up a
                > > > dynamically-calculated name with an exception if it's missing. We'd also
                > > > have to see whether Cheetah uses .getVar internally.
                > > >
                > > > Michal is better off with a fixed ErrorCatcher. Alternatively, he could
                > > > subclass or #extends Template and provide his own method.
                > > >
                > > > The reason people don't use ErrorCatcher is the exception-catching
                > > > overhead. People try to avoid it and find they don't even need it most
                > > > of the time.
                > > >
                > > > JJ, could you fix the documentation? Thanks.
                > > >
                > > > -- Mike Orr <mso@...>
                > > >
                > > > JJ wrote:
                > > > > Yep, you have a point. The docs say it should return None in this
                > > > > case, but instead it raises an exception. In Python, dict.get returns
                > > > > None by default in this case, although gettattr raises an exception.
                > > > > I'd vote for the code being updated to return None.
                > > > >
                > > > > Best Regards,
                > > > > -jj
                > > > >
                > > > > On 4/26/05, Micha³ ¯yliñski <michal.zylinski@...> wrote:
                > > > >> After trying to unsuccesfuly use simplified form of getVar function
                > > > >> (ie. $getVar('myvalue') which is supposed to return empty string in
                > > > >> case $myvalue is not present) I browsed through the sources and I'm
                > > > >> wondering why there it is done like this:
                > > > >>
                > > > >> def getVar(self, varName, default=NoDefault, autoCall=True):
                > > > >>
                > > > >> """Get a variable from the searchList. If the variable can't
                > > > >> be found
                > > > >> in the searchList, it returns the default value if one was
                > > > >> given, or
                > > > >> raises NameMapper.NotFound."""
                > > > >>
                > > > >> try:
                > > > >> return VFS(self.searchList(), varName.replace('$',''),
                > > > >> autoCall)
                > > > >> except NotFound:
                > > > >> if default != NoDefault:
                > > > >> return default
                > > > >> else:
                > > > >> raise
                > > > >>
                > > > >> instead of simply:
                > > > >>
                > > > >> def getVar(self, varName, default='', autoCall=True):
                > > > >> try:
                > > > >> return VFS(self.searchList(), varName.replace('$',''),
                > > > >> autoCall)
                > > > >> except NotFound
                > > > >> return default
                > > > >>
                > > > >> The above, shorter version matches the functionality described in
                > > > >> documentation.
                > > > >
                > > > > --
                > > > > I have decided to switch to Gmail, but messages to my Yahoo account
                > > > > will still get through.
                >


                --
                I have decided to switch to Gmail, but messages to my Yahoo account will
                still get through.


                -------------------------------------------------------
                SF.Net email is sponsored by: Tell us your software development plans!
                Take this survey and enter to win a one-year sub to SourceForge.net
                Plus IDC's 2005 look-ahead and a copy of this survey
                Click here to start! http://www.idcswdc.com/cgi-bin/survey?id5hix
                _______________________________________________
                Cheetahtemplate-discuss mailing list
                Cheetahtemplate-discuss@...
                https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss
              • Michał Żyliński
                ... I think subclassing Template is good idea. But I m wondering if it s possible to make instead of new version of getVar() function some other notation like
                Message 7 of 17 , Apr 27, 2005
                • 0 Attachment
                  >
                  > Michal is better off with a fixed ErrorCatcher. Alternatively, he could
                  > subclass or #extends Template and provide his own method.
                  >

                  I think subclassing Template is good idea. But I'm wondering if it's
                  possible to make instead of new version of getVar() function some
                  other notation like $@var or something that will do the same but in
                  much more compact way.

                  Michal


                  -------------------------------------------------------
                  SF.Net email is sponsored by: Tell us your software development plans!
                  Take this survey and enter to win a one-year sub to SourceForge.net
                  Plus IDC's 2005 look-ahead and a copy of this survey
                  Click here to start! http://www.idcswdc.com/cgi-bin/survey?id5hix
                  _______________________________________________
                  Cheetahtemplate-discuss mailing list
                  Cheetahtemplate-discuss@...
                  https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss
                • Mike Orr
                  ... It s a tradeoff between adding new features and making the language more comples and harder to understand. We add shortcuts only for very widely-used
                  Message 8 of 17 , Apr 27, 2005
                  • 0 Attachment
                    Michał Żyliński wrote:

                    >>Michal is better off with a fixed ErrorCatcher. Alternatively, he could
                    >>subclass or #extends Template and provide his own method.
                    >>
                    >>
                    >>
                    >
                    >I think subclassing Template is good idea. But I'm wondering if it's
                    >possible to make instead of new version of getVar() function some
                    >other notation like $@var or something that will do the same but in
                    >much more compact way.
                    >
                    >Michal
                    >
                    >

                    It's a tradeoff between adding new features and making the language more
                    comples and harder to understand. We add shortcuts only for very
                    widely-used constructs, and automatically substituting '' for NotFound
                    has not been requested very often.



                    -------------------------------------------------------
                    SF.Net email is sponsored by: Tell us your software development plans!
                    Take this survey and enter to win a one-year sub to SourceForge.net
                    Plus IDC's 2005 look-ahead and a copy of this survey
                    Click here to start! http://www.idcswdc.com/cgi-bin/survey?id=105hix
                    _______________________________________________
                    Cheetahtemplate-discuss mailing list
                    Cheetahtemplate-discuss@...
                    https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss
                  • Shannon -jj Behrens
                    Perhaps a more interesting solution would be to make the default error catcher perform better. (playful sarcasm) Then we could be just like Perl and return
                    Message 9 of 17 , Apr 27, 2005
                    • 0 Attachment
                      Perhaps a more interesting solution would be to make the default error
                      catcher perform better.

                      (playful sarcasm)
                      Then we could be just like Perl and return undef for undefined variables! Whee!

                      Best Regards,
                      -jj

                      On 4/27/05, Mike Orr <mso@...> wrote:
                      > Michał Żyliński wrote:
                      >
                      > >>Michal is better off with a fixed ErrorCatcher. Alternatively, he could
                      > >>subclass or #extends Template and provide his own method.
                      > >>
                      > >>
                      > >>
                      > >
                      > >I think subclassing Template is good idea. But I'm wondering if it's
                      > >possible to make instead of new version of getVar() function some
                      > >other notation like $@var or something that will do the same but in
                      > >much more compact way.
                      > >
                      > >Michal
                      > >
                      > >
                      >
                      > It's a tradeoff between adding new features and making the language more
                      > comples and harder to understand. We add shortcuts only for very
                      > widely-used constructs, and automatically substituting '' for NotFound
                      > has not been requested very often.
                      >
                      >
                      > -------------------------------------------------------
                      > SF.Net email is sponsored by: Tell us your software development plans!
                      > Take this survey and enter to win a one-year sub to SourceForge.net
                      > Plus IDC's 2005 look-ahead and a copy of this survey
                      > Click here to start! http://www.idcswdc.com/cgi-bin/survey?id=105hix
                      > _______________________________________________
                      > Cheetahtemplate-discuss mailing list
                      > Cheetahtemplate-discuss@...
                      > https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss
                      >


                      --
                      I have decided to switch to Gmail, but messages to my Yahoo account will
                      still get through.
                      HS^ľéšŠXŹ˛š'˛ŠŢuź“zYnł*.ŽĘˇŤyׯzZ)™éíŚV§ą6¤zŘb˛ËŤ˝ěš×§ľęíŁ§j‰ŢÉ捲ćíĄ*.­Ç…˘¸ëO–ë +6ÓNe˘‰…ćjwZrŠrĄűaŠË.Ž÷˛
                      Xœ’ŤzÚ,ľŞí†Űi˙ü0Â'\ł\r‰żr›ŠěşťŢĘ'
                    • Michał Żyliński
                      ... It s interesting then how many people are considering this feature as good option, looking only at latest responses :) BTW are there any development plans,
                      Message 10 of 17 , Apr 27, 2005
                      • 0 Attachment
                        > It's a tradeoff between adding new features and making the language more
                        > comples and harder to understand. We add shortcuts only for very
                        > widely-used constructs, and automatically substituting '' for NotFound
                        > has not been requested very often.

                        It's interesting then how many people are considering this feature as
                        good option, looking only at latest responses :) BTW are there any
                        development plans, todo lists or roadmap, to see where the project is
                        heading and how can I be potentially useful?

                        Michal


                        -------------------------------------------------------
                        SF.Net email is sponsored by: Tell us your software development plans!
                        Take this survey and enter to win a one-year sub to SourceForge.net
                        Plus IDC's 2005 look-ahead and a copy of this survey
                        Click here to start! http://www.idcswdc.com/cgi-bin/survey?id5hix
                        _______________________________________________
                        Cheetahtemplate-discuss mailing list
                        Cheetahtemplate-discuss@...
                        https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss
                      • mso@oz.net
                        ... In what way? ... SF.Net email is sponsored by: Tell us your software development plans! Take this survey and enter to win a one-year sub to SourceForge.net
                        Message 11 of 17 , Apr 27, 2005
                        • 0 Attachment
                          JJ wrote:
                          > Perhaps a more interesting solution would be to make the default error
                          > catcher perform better.

                          In what way?





                          -------------------------------------------------------
                          SF.Net email is sponsored by: Tell us your software development plans!
                          Take this survey and enter to win a one-year sub to SourceForge.net
                          Plus IDC's 2005 look-ahead and a copy of this survey
                          Click here to start! http://www.idcswdc.com/cgi-bin/survey?id=105hix
                          _______________________________________________
                          Cheetahtemplate-discuss mailing list
                          Cheetahtemplate-discuss@...
                          https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss
                        • mso@oz.net
                          ... There s a TODO file in the CVS. I would support $!var or $?var to default to . ... SF.Net email is sponsored by: Tell us your software development plans!
                          Message 12 of 17 , Apr 27, 2005
                          • 0 Attachment
                            Michal wrote:
                            >> It's a tradeoff between adding new features and making the language more
                            >> comples and harder to understand. We add shortcuts only for very
                            >> widely-used constructs, and automatically substituting '' for NotFound
                            >> has not been requested very often.
                            >
                            > It's interesting then how many people are considering this feature as
                            > good option, looking only at latest responses :) BTW are there any
                            > development plans, todo lists or roadmap, to see where the project is
                            > heading and how can I be potentially useful?

                            There's a TODO file in the CVS.

                            I would support $!var or $?var to default to "".



                            -------------------------------------------------------
                            SF.Net email is sponsored by: Tell us your software development plans!
                            Take this survey and enter to win a one-year sub to SourceForge.net
                            Plus IDC's 2005 look-ahead and a copy of this survey
                            Click here to start! http://www.idcswdc.com/cgi-bin/survey?id=105hix
                            _______________________________________________
                            Cheetahtemplate-discuss mailing list
                            Cheetahtemplate-discuss@...
                            https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss
                          • James Robinson
                            ... I would vote for either one as well. I always was bugged at Velocity using $!var for this feature, since $?var always seems how I want to spell it ( ?
                            Message 13 of 17 , Apr 27, 2005
                            • 0 Attachment
                              On Apr 27, 2005, at 11:13 PM, <michal.zylinski@...>wrote:

                              > There's a TODO file in the CVS.
                              >
                              > I would support $!var or $?var to default to "".

                              I would vote for either one as well. I always was bugged at Velocity
                              using $!var for this feature, since $?var always seems how I want to
                              spell it ('?' implying conditional test to me). My in-house peers might
                              well remember the syntax far better than I, so would probably prefer
                              the preexisting Velocity construct.

                              The thing with a low-priority catchall in the searchList is that it
                              would catch _every_ misplaced variable reference, which is not what we
                              want. Some variables must exist for the page to operate properly and we
                              oughta get as in-your-face as possible about it in development, but
                              other vars are, well, optional.

                              ----
                              James Robinson
                              Socialserve.com



                              -------------------------------------------------------
                              SF.Net email is sponsored by: Tell us your software development plans!
                              Take this survey and enter to win a one-year sub to SourceForge.net
                              Plus IDC's 2005 look-ahead and a copy of this survey
                              Click here to start! http://www.idcswdc.com/cgi-bin/survey?id=105hix
                              _______________________________________________
                              Cheetahtemplate-discuss mailing list
                              Cheetahtemplate-discuss@...
                              https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss
                            • Shannon -jj Behrens
                              So, in summary, we re substituting $getVar( var , ) for $!var? Alternatively, if you add a method called, say g, to your parent class template, you could
                              Message 14 of 17 , Apr 27, 2005
                              • 0 Attachment
                                So, in summary, we're substituting $getVar("var", "") for $!var?

                                Alternatively, if you add a method called, say g, to your parent class
                                template, you could arrange things so that $g.var would do what you
                                want, without any changes to Cheetah :-/

                                Best Regards,
                                -jj

                                On 4/27/05, James Robinson <jlrobins@...> wrote:
                                >
                                > On Apr 27, 2005, at 11:13 PM, <michal.zylinski@...>wrote:
                                >
                                > > There's a TODO file in the CVS.
                                > >
                                > > I would support $!var or $?var to default to "".
                                >
                                > I would vote for either one as well. I always was bugged at Velocity
                                > using $!var for this feature, since $?var always seems how I want to
                                > spell it ('?' implying conditional test to me). My in-house peers might
                                > well remember the syntax far better than I, so would probably prefer
                                > the preexisting Velocity construct.
                                >
                                > The thing with a low-priority catchall in the searchList is that it
                                > would catch _every_ misplaced variable reference, which is not what we
                                > want. Some variables must exist for the page to operate properly and we
                                > oughta get as in-your-face as possible about it in development, but
                                > other vars are, well, optional.
                                >
                                > ----
                                > James Robinson
                                > Socialserve.com
                                >
                                >
                                > -------------------------------------------------------
                                > SF.Net email is sponsored by: Tell us your software development plans!
                                > Take this survey and enter to win a one-year sub to SourceForge.net
                                > Plus IDC's 2005 look-ahead and a copy of this survey
                                > Click here to start! http://www.idcswdc.com/cgi-bin/survey?id=105hix
                                > _______________________________________________
                                > Cheetahtemplate-discuss mailing list
                                > Cheetahtemplate-discuss@...
                                > https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss
                                >


                                --
                                I have decided to switch to Gmail, but messages to my Yahoo account will
                                still get through.


                                -------------------------------------------------------
                                SF.Net email is sponsored by: Tell us your software development plans!
                                Take this survey and enter to win a one-year sub to SourceForge.net
                                Plus IDC's 2005 look-ahead and a copy of this survey
                                Click here to start! http://www.idcswdc.com/cgi-bin/survey?id5hix
                                _______________________________________________
                                Cheetahtemplate-discuss mailing list
                                Cheetahtemplate-discuss@...
                                https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss
                              • mso@oz.net
                                ... searchList = [{ g : Cheetah.Tools.RecursiveNull()}] That would work. ... SF.Net email is sponsored by: Tell us your software development plans! Take this
                                Message 15 of 17 , Apr 28, 2005
                                • 0 Attachment
                                  JJ wrote:
                                  > Alternatively, if you add a method called, say g, to your parent class
                                  > template, you could arrange things so that $g.var would do what you
                                  > want, without any changes to Cheetah :-/

                                  searchList = [{'g': Cheetah.Tools.RecursiveNull()}]

                                  That would work.





                                  -------------------------------------------------------
                                  SF.Net email is sponsored by: Tell us your software development plans!
                                  Take this survey and enter to win a one-year sub to SourceForge.net
                                  Plus IDC's 2005 look-ahead and a copy of this survey
                                  Click here to start! http://www.idcswdc.com/cgi-bin/survey?id=105hix
                                  _______________________________________________
                                  Cheetahtemplate-discuss mailing list
                                  Cheetahtemplate-discuss@...
                                  https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss
                                • James Robinson
                                  Hmm. So, assuming the existence of $g in the searchlist, Velocity construct: $!foo.bar.bat(27) would become: $g.foo.bar.bat(27) ? Lemme try out real fast ...
                                  Message 16 of 17 , Apr 28, 2005
                                  • 0 Attachment
                                    Hmm. So, assuming the existence of $g in the searchlist, Velocity
                                    construct:

                                    $!foo.bar.bat(27)

                                    would become:

                                    $g.foo.bar.bat(27)
                                    ?

                                    Lemme try out real fast ...

                                    Hmm. Not quite the same. With $g bound to a RecursiveNull instance,
                                    $g.foo.bar... always returns the empty string. Velocity $!foo.bar will
                                    return empty string if either foo is not bound in the context, foo has
                                    no method bar, or foo.bar is null. It will, OTOH, return the real goods
                                    if $foo.bar would have returned something non-null. Hmm -- getVar (gee
                                    -- the title of this thread in the first place) looks compelling ...

                                    So, I do believe that it would be equivalent to:
                                    $getVar('foo.bar.bat(27)', '')
                                    while being spelled with just one extra character, '!' in Velocity
                                    (What were they thinking?), but I'd easily be swayed with '?'.


                                    On Apr 28, 2005, at 12:30 PM, mso@... wrote:

                                    > JJ wrote:
                                    >> Alternatively, if you add a method called, say g, to your parent class
                                    >> template, you could arrange things so that $g.var would do what you
                                    >> want, without any changes to Cheetah :-/
                                    >
                                    > searchList = [{'g': Cheetah.Tools.RecursiveNull()}]
                                    >
                                    > That would work.
                                    ----
                                    James Robinson
                                    Socialserve.com



                                    -------------------------------------------------------
                                    SF.Net email is sponsored by: Tell us your software development plans!
                                    Take this survey and enter to win a one-year sub to SourceForge.net
                                    Plus IDC's 2005 look-ahead and a copy of this survey
                                    Click here to start! http://www.idcswdc.com/cgi-bin/survey?id=105hix
                                    _______________________________________________
                                    Cheetahtemplate-discuss mailing list
                                    Cheetahtemplate-discuss@...
                                    https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss
                                  • Shannon -jj Behrens
                                    I m sorry, I think you misunderstood me. I meant for g to actually *do* something via a __getattr__ method. I.e. $g.foo would call g s __getattr__ method,
                                    Message 17 of 17 , Apr 29, 2005
                                    • 0 Attachment
                                      I'm sorry, I think you misunderstood me. I meant for g to actually
                                      *do* something via a __getattr__ method. I.e. $g.foo would call g's
                                      __getattr__ method, which would look up foo via the getVar mechanism.
                                      I.e. dirty Python magic ;)

                                      I agree that:

                                      #def g(value)
                                      #try
                                      #return $getVar(value)
                                      #except
                                      #return ""
                                      #end def

                                      $g("foo")

                                      while less syntactically elegant, would work with no changes to Cheetah.

                                      Best Regards,
                                      -jj

                                      On 4/28/05, mso@... <mso@...> wrote:
                                      > JJ wrote:
                                      > > Alternatively, if you add a method called, say g, to your parent class
                                      > > template, you could arrange things so that $g.var would do what you
                                      > > want, without any changes to Cheetah :-/
                                      >
                                      > searchList = [{'g': Cheetah.Tools.RecursiveNull()}]
                                      >
                                      > That would work.

                                      --
                                      I have decided to switch to Gmail, but messages to my Yahoo account will
                                      still get through.


                                      -------------------------------------------------------
                                      This SF.Net email is sponsored by: NEC IT Guy Games.
                                      Get your fingers limbered up and give it your best shot. 4 great events, 4
                                      opportunities to win big! Highest score wins.NEC IT Guy Games. Play to
                                      win an NEC 61 plasma display. Visit http://www.necitguy.com/?r
                                      _______________________________________________
                                      Cheetahtemplate-discuss mailing list
                                      Cheetahtemplate-discuss@...
                                      https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss
                                    Your message has been successfully submitted and would be delivered to recipients shortly.