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

Re: [Cheetahtemplate-discuss] #super directive for blocks

Expand Messages
  • Mailing list subscriptions
    ... Yes, I think that s the only way it could be done. ... Which I think would be useful, and a strong argument in favor of the user of $super . ... True. I
    Message 1 of 14 , Oct 18, 2006
    • 0 Attachment
      El 17/10/2006, a las 23:53, Mike Orr escribió:

      > If #super outputs whatever the parent method returns, this would work.

      Yes, I think that's the only way it could be done.

      > But if it were $super instead then you could also assign the value to
      > a variable or use it in an expression.

      Which I think would be useful, and a strong argument in favor of the
      user of "$super".

      > But having a $super that has
      > different arguments than Python's 'super' function would be confusing.

      True. I proposed it in "#directive" format rather than "$placeholder"
      format because it just seemed to be more a "directive thing"... True,
      it is inserting something in the same way as you'd insert a
      placeholder, but it is also more of an instruction to Cheetah to do
      something during compilation (like #block or #def themselves).

      By the way, I proposed "super" because it's the first word that came
      to my mind, but an alternative might be possible... $parent? #parent?

      > (I would like to see it just take the parent method's arguments
      > rather than having to pass "class, self".)

      Yes, I think that the template author should be shielded from having
      to worry about passing (class, self). Cheetah should handle that
      automatically.

      For ease of use I think the ideal case would be to automatically pass
      the arguments to the current method, but with the possibility of
      explicitly passing (different) arguments as well. In other words,
      either of these:

      #super
      $super

      Would just call the method on the parent class of the same name,
      passing the same arguments that were passed into the current block.
      But one of these:

      #super arg1, arg2
      $super(arg1, arg2)

      Could be used to pass in different, modified arguments.

      > On the other hand, $super(arg1, arg2) looks better than #super arg1,
      > arg2 . if the method requires arguments.

      Agreed, it does look better. I would be happy though just to have it
      in either form.

      I've come to Cheetah from an object-oriented programming background,
      and *the* most important element of Cheetah, the only reason I've
      switched to it, is the power of template inheritance. But as an
      object-oriented programmer I am very, very accustomed to working with
      this pattern (in psuedo-code):

      function(arg1, arg2)
      {
      super(arg1, arg2);
      do_some_extra_stuff();
      }

      And so for me the idea of #super (or $super) in Cheetah was just a
      natural fit. In fact, I am very surprised it isn't in there already!



      -------------------------------------------------------------------------
      Using Tomcat but need to do more? Need to support web services, security?
      Get stuff done quickly with pre-integrated technology to make your job easier
      Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
      http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
      _______________________________________________
      Cheetahtemplate-discuss mailing list
      Cheetahtemplate-discuss@...
      https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss
    • tavis@redonions.net
      I m in favour of adding #super as a shortcut for super(baseclass, self).currentMethodName() . We can allow optional arguments as well: #super(arg1, arg2)
      Message 2 of 14 , Oct 20, 2006
      • 0 Attachment
        I'm in favour of adding #super as a shortcut for 'super(baseclass,
        self).currentMethodName()'. We can allow optional arguments as well:
        #super(arg1, arg2)

        $super is not an option because of the clash with Python's builtin version.

        Cheers,
        Tavis

        On Wed, 18 Oct 2006, Mailing list subscriptions wrote:

        > El 17/10/2006, a las 23:53, Mike Orr escribió:
        >
        >> If #super outputs whatever the parent method returns, this would work.
        >
        > Yes, I think that's the only way it could be done.
        >
        >> But if it were $super instead then you could also assign the value to
        >> a variable or use it in an expression.
        >
        > Which I think would be useful, and a strong argument in favor of the
        > user of "$super".
        >
        >> But having a $super that has
        >> different arguments than Python's 'super' function would be confusing.
        >
        > True. I proposed it in "#directive" format rather than "$placeholder"
        > format because it just seemed to be more a "directive thing"... True,
        > it is inserting something in the same way as you'd insert a
        > placeholder, but it is also more of an instruction to Cheetah to do
        > something during compilation (like #block or #def themselves).
        >
        > By the way, I proposed "super" because it's the first word that came
        > to my mind, but an alternative might be possible... $parent? #parent?
        >
        >> (I would like to see it just take the parent method's arguments
        >> rather than having to pass "class, self".)
        >
        > Yes, I think that the template author should be shielded from having
        > to worry about passing (class, self). Cheetah should handle that
        > automatically.
        >
        > For ease of use I think the ideal case would be to automatically pass
        > the arguments to the current method, but with the possibility of
        > explicitly passing (different) arguments as well. In other words,
        > either of these:
        >
        > #super
        > $super
        >
        > Would just call the method on the parent class of the same name,
        > passing the same arguments that were passed into the current block.
        > But one of these:
        >
        > #super arg1, arg2
        > $super(arg1, arg2)
        >
        > Could be used to pass in different, modified arguments.
        >
        >> On the other hand, $super(arg1, arg2) looks better than #super arg1,
        >> arg2 . if the method requires arguments.
        >
        > Agreed, it does look better. I would be happy though just to have it
        > in either form.
        >
        > I've come to Cheetah from an object-oriented programming background,
        > and *the* most important element of Cheetah, the only reason I've
        > switched to it, is the power of template inheritance. But as an
        > object-oriented programmer I am very, very accustomed to working with
        > this pattern (in psuedo-code):
        >
        > function(arg1, arg2)
        > {
        > super(arg1, arg2);
        > do_some_extra_stuff();
        > }
        >
        > And so for me the idea of #super (or $super) in Cheetah was just a
        > natural fit. In fact, I am very surprised it isn't in there already!
        >
        >
        >
        > -------------------------------------------------------------------------
        > Using Tomcat but need to do more? Need to support web services, security?
        > Get stuff done quickly with pre-integrated technology to make your job easier
        > Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
        > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
        > _______________________________________________
        > Cheetahtemplate-discuss mailing list
        > Cheetahtemplate-discuss@...
        > https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss
        >
      • leenoori
        ... Sounds great. Anything I can do to help out with implementing this? ... Using Tomcat but need to do more? Need to support web services, security? Get stuff
        Message 3 of 14 , Oct 20, 2006
        • 0 Attachment
          El 21/10/2006, a las 1:58, tavis@... escribió:

          > I'm in favour of adding #super as a shortcut for 'super(baseclass,
          > self).currentMethodName()'. We can allow optional arguments as well:
          > #super(arg1, arg2)
          >
          > $super is not an option because of the clash with Python's builtin
          > version.

          Sounds great. Anything I can do to help out with implementing this?


          -------------------------------------------------------------------------
          Using Tomcat but need to do more? Need to support web services, security?
          Get stuff done quickly with pre-integrated technology to make your job easier
          Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
          http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
          _______________________________________________
          Cheetahtemplate-discuss mailing list
          Cheetahtemplate-discuss@...
          https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss
        • Mike Orr
          ... Would this be weird to have one directive with parenthesized arguments when the others don t? -- Mike Orr ... Using Tomcat but need
          Message 4 of 14 , Oct 20, 2006
          • 0 Attachment
            On 10/20/06, tavis@... <tavis@...> wrote:
            > I'm in favour of adding #super as a shortcut for 'super(baseclass,
            > self).currentMethodName()'. We can allow optional arguments as well:
            > #super(arg1, arg2)

            Would this be weird to have one directive with parenthesized arguments
            when the others don't?


            --
            Mike Orr <sluggoster@...>

            -------------------------------------------------------------------------
            Using Tomcat but need to do more? Need to support web services, security?
            Get stuff done quickly with pre-integrated technology to make your job easier
            Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
            http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
            _______________________________________________
            Cheetahtemplate-discuss mailing list
            Cheetahtemplate-discuss@...
            https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss
          • tavis@redonions.net
            possibly. It s also a bit weird the other way around. Let s try them both out and see what feels most natural. ... Using Tomcat but need to do more? Need to
            Message 5 of 14 , Oct 21, 2006
            • 0 Attachment
              possibly. It's also a bit weird the other way around. Let's try them both
              out and see what feels most natural.

              On Fri, 20 Oct 2006, Mike Orr wrote:

              > On 10/20/06, tavis@... <tavis@...> wrote:
              >> I'm in favour of adding #super as a shortcut for 'super(baseclass,
              >> self).currentMethodName()'. We can allow optional arguments as well:
              >> #super(arg1, arg2)
              >
              > Would this be weird to have one directive with parenthesized arguments
              > when the others don't?
              >
              >
              > --
              > Mike Orr <sluggoster@...>
              >
              > -------------------------------------------------------------------------
              > Using Tomcat but need to do more? Need to support web services, security?
              > Get stuff done quickly with pre-integrated technology to make your job easier
              > Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
              > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
              > _______________________________________________
              > Cheetahtemplate-discuss mailing list
              > Cheetahtemplate-discuss@...
              > https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss
              >

              -------------------------------------------------------------------------
              Using Tomcat but need to do more? Need to support web services, security?
              Get stuff done quickly with pre-integrated technology to make your job easier
              Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
              http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
              _______________________________________________
              Cheetahtemplate-discuss mailing list
              Cheetahtemplate-discuss@...
              https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss
            • tavis@redonions.net
              ... You could write up some test cases if you have time. See src/Tests/SyntaxAndOutput.py in the tarball. Cheers, Tavis ... Using Tomcat but need to do more?
              Message 6 of 14 , Oct 21, 2006
              • 0 Attachment
                On Sat, 21 Oct 2006, leenoori wrote:
                > Sounds great. Anything I can do to help out with implementing this?
                You could write up some test cases if you have time. See
                src/Tests/SyntaxAndOutput.py in the tarball.
                Cheers,
                Tavis

                -------------------------------------------------------------------------
                Using Tomcat but need to do more? Need to support web services, security?
                Get stuff done quickly with pre-integrated technology to make your job easier
                Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
                http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
                _______________________________________________
                Cheetahtemplate-discuss mailing list
                Cheetahtemplate-discuss@...
                https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss
              • leenoori
                ... Here is a diff against the current HEAD of the trunk in CVS. Not sure if these tests are acceptable as it s the first time I ve written tests for Cheetah.
                Message 7 of 14 , Oct 22, 2006
                • 0 Attachment
                  El 21/10/2006, a las 21:44, tavis@... escribió:

                  > On Sat, 21 Oct 2006, leenoori wrote:
                  >> Sounds great. Anything I can do to help out with implementing this?
                  > You could write up some test cases if you have time. See src/Tests/
                  > SyntaxAndOutput.py in the tarball.
                  > Cheers,
                  > Tavis

                  Here is a diff against the current HEAD of the trunk in CVS. Not sure
                  if these tests are acceptable as it's the first time I've written
                  tests for Cheetah. I've written them using the syntax that you
                  suggested in your first email in this thread, "#super(arg1, arg2)".
                  But this is at least a starting point...

                  Included tests:

                  * #super inside multi-line #block, no arguments
                  * #super inside single-line #block, no arguments
                  * #super inside multi-line #block, with arguments
                  * #super inside single-line #block, with arguments
                  * #super inside multi-line #def, no arguments
                  * #super inside single-line #def, no arguments
                  * #super inside multi-line #def, with arguments
                  * #super inside single-line #def, with arguments


                  Index: src/Tests/SyntaxAndOutput.py
                  ===================================================================
                  RCS file: /cvsroot/cheetahtemplate/Cheetah/src/Tests/
                  SyntaxAndOutput.py,v
                  retrieving revision 1.105
                  diff -r1.105 SyntaxAndOutput.py
                  2804a2805,2889
                  > class SuperDirective(OutputTest):
                  > def test1(self):
                  > """#super inside multi-line #block, no arguments"""
                  > self.verify("""#from Cheetah.Templates.SkeletonPage import
                  SkeletonPage
                  > #extends SkeletonPage
                  > #implements respond
                  > #block writeBody
                  > #super
                  > #end block writeBody
                  > """,
                  > 'This skeleton page has no flesh. Its body
                  needs to be implemented.')
                  >
                  > def test2(self):
                  > """#super inside single-line #block, no arguments"""
                  > self.verify("""#from Cheetah.Templates.SkeletonPage import
                  SkeletonPage
                  > #extends SkeletonPage
                  > #implements respond
                  > #block writeBody: #super
                  > """,
                  > 'This skeleton page has no flesh. Its body
                  needs to be implemented.')
                  >
                  > def test3(self):
                  > """#super inside multi-line #block, with arguments"""
                  > self.verify("""#from Cheetah.Templates._SkeletonPage
                  import _SkeletonPage
                  > #extends _SkeletonPage
                  > #implements respond
                  > #block spacer
                  > #super(100, 100)
                  > #end def spacer
                  > """,
                  > '<img src="spacer.gif" width="100"
                  height="100" alt="" />')
                  >
                  > def test4(self):
                  > """#super inside single-line #block, with arguments"""
                  > self.verify("""#from Cheetah.Templates._SkeletonPage
                  import _SkeletonPage
                  > #extends _SkeletonPage
                  > #implements respond
                  > #block spacer: #super(100, 100)
                  > """,
                  > '<img src="spacer.gif" width="100"
                  height="100" alt="" />')
                  >
                  > def test5(self):
                  > """#super inside multi-line #def, no arguments"""
                  > self.verify("""#from Cheetah.Templates._SkeletonPage
                  import _SkeletonPage
                  > #extends _SkeletonPage
                  > #implements respond
                  > #def spacer
                  > #super
                  > #end def spacer
                  > $spacer
                  > """,
                  > '<img src="spacer.gif" width="1" height="1"
                  alt="" />')
                  >
                  > def test6(self):
                  > """#super inside single-line #def, no arguments"""
                  > self.verify("""#from Cheetah.Templates._SkeletonPage
                  import _SkeletonPage
                  > #extends _SkeletonPage
                  > #implements respond
                  > #def spacer: #super
                  > $spacer
                  > """,
                  > '<img src="spacer.gif" width="1" height="1"
                  alt="" />')
                  >
                  > def test7(self):
                  > """#super inside multi-line #def, with arguments"""
                  > self.verify("""#from Cheetah.Templates._SkeletonPage
                  import _SkeletonPage
                  > #extends _SkeletonPage
                  > #implements respond
                  > #def spacer
                  > #super(100, 100)
                  > #end def spacer
                  > $spacer
                  > """,
                  > '<img src="spacer.gif" width="100"
                  height="100" alt="" />')
                  >
                  > def test8(self):
                  > """#super inside single-line #def, with arguments"""
                  > self.verify("""#from Cheetah.Templates._SkeletonPage
                  import _SkeletonPage
                  > #extends _SkeletonPage
                  > #implements respond
                  > #def spacer: #super(100, 100)
                  > $spacer
                  > """,
                  > '<img src="spacer.gif" width="100"
                  height="100" alt="" />')
                  >
                  -------------------------------------------------------------------------
                  Using Tomcat but need to do more? Need to support web services, security?
                  Get stuff done quickly with pre-integrated technology to make your job easier
                  Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
                  http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
                  _______________________________________________
                  Cheetahtemplate-discuss mailing list
                  Cheetahtemplate-discuss@...
                  https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss
                • leenoori
                  ... Has any progress been made towards implementing the #super directive? If only I knew more about Python I would have a try myself! ... Take Surveys. Earn
                  Message 8 of 14 , Jan 5, 2007
                  • 0 Attachment
                    El 22/10/2006, a las 16:00, leenoori escribió:

                    > Here is a diff against the current HEAD of the trunk in CVS. Not sure
                    > if these tests are acceptable as it's the first time I've written
                    > tests for Cheetah. I've written them using the syntax that you
                    > suggested in your first email in this thread, "#super(arg1, arg2)".
                    > But this is at least a starting point...

                    Has any progress been made towards implementing the #super directive?
                    If only I knew more about Python I would have a try myself!




                    -------------------------------------------------------------------------
                    Take Surveys. Earn Cash. Influence the Future of IT
                    Join SourceForge.net's Techsay panel and you'll get the chance to share your
                    opinions on IT & business topics through brief surveys - and earn cash
                    http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
                    _______________________________________________
                    Cheetahtemplate-discuss mailing list
                    Cheetahtemplate-discuss@...
                    https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss
                  • Mike Orr
                    ... Not that I know of. -- Mike Orr ... Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net s Techsay panel and
                    Message 9 of 14 , Jan 5, 2007
                    • 0 Attachment
                      On 1/5/07, leenoori <leenoori@...> wrote:
                      > Has any progress been made towards implementing the #super directive?

                      Not that I know of.

                      --
                      Mike Orr <sluggoster@...>

                      -------------------------------------------------------------------------
                      Take Surveys. Earn Cash. Influence the Future of IT
                      Join SourceForge.net's Techsay panel and you'll get the chance to share your
                      opinions on IT & business topics through brief surveys - and earn cash
                      http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
                      _______________________________________________
                      Cheetahtemplate-discuss mailing list
                      Cheetahtemplate-discuss@...
                      https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss
                    • Tavis Rudd
                      I ve just implemented it as we discussed. ... Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net s Techsay panel and you ll get the
                      Message 10 of 14 , Apr 3, 2007
                      • 0 Attachment
                        I've just implemented it as we discussed.

                        On Friday 20 October 2006 5:14 pm, leenoori wrote:
                        > El 21/10/2006, a las 1:58, tavis@... escribió:
                        > > I'm in favour of adding #super as a shortcut for 'super(baseclass,
                        > > self).currentMethodName()'. We can allow optional arguments as well:
                        > > #super(arg1, arg2)
                        > >
                        > > $super is not an option because of the clash with Python's builtin
                        > > version.

                        -------------------------------------------------------------------------
                        Take Surveys. Earn Cash. Influence the Future of IT
                        Join SourceForge.net's Techsay panel and you'll get the chance to share your
                        opinions on IT & business topics through brief surveys-and earn cash
                        http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
                        _______________________________________________
                        Cheetahtemplate-discuss mailing list
                        Cheetahtemplate-discuss@...
                        https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss
                      • Mike Orr
                        ... Is the syntax the same as this? ... Are parentheses required or optional or not allowed if there are no arguments? -- Mike Orr ...
                        Message 11 of 14 , Apr 3, 2007
                        • 0 Attachment
                          On 4/3/07, Tavis Rudd <tavis@...> wrote:
                          > I've just implemented it as we discussed.

                          Is the syntax the same as this?

                          On 10/20/06, tavis@... <tavis@...> wrote:
                          > I'm in favour of adding #super as a shortcut for 'super(baseclass,
                          > self).currentMethodName()'. We can allow optional arguments as well:
                          > #super(arg1, arg2)

                          > $super is not an option because of the clash with Python's builtin version.

                          Are parentheses required or optional or not allowed if there are no arguments?

                          --
                          Mike Orr <sluggoster@...>

                          -------------------------------------------------------------------------
                          Take Surveys. Earn Cash. Influence the Future of IT
                          Join SourceForge.net's Techsay panel and you'll get the chance to share your
                          opinions on IT & business topics through brief surveys-and earn cash
                          http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
                          _______________________________________________
                          Cheetahtemplate-discuss mailing list
                          Cheetahtemplate-discuss@...
                          https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss
                        • Tavis Rudd
                          ... Yes. ... They are required if there are arguments to be passed. Otherwise they are optional. ... Take Surveys. Earn Cash. Influence the Future of IT Join
                          Message 12 of 14 , Apr 3, 2007
                          • 0 Attachment
                            On Tuesday 03 April 2007 6:00 pm, Mike Orr wrote:
                            > On 4/3/07, Tavis Rudd <tavis@...> wrote:
                            > > I've just implemented it as we discussed.
                            >
                            > Is the syntax the same as this?
                            Yes.

                            > On 10/20/06, tavis@... <tavis@...> wrote:
                            > > I'm in favour of adding #super as a shortcut for 'super(baseclass,
                            > > self).currentMethodName()'. We can allow optional arguments as well:
                            > > #super(arg1, arg2)
                            > >
                            > > $super is not an option because of the clash with Python's builtin
                            > > version.
                            >
                            > Are parentheses required or optional or not allowed if there are no
                            > arguments?

                            They are required if there are arguments to be passed. Otherwise they are
                            optional.

                            -------------------------------------------------------------------------
                            Take Surveys. Earn Cash. Influence the Future of IT
                            Join SourceForge.net's Techsay panel and you'll get the chance to share your
                            opinions on IT & business topics through brief surveys-and earn cash
                            http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
                            _______________________________________________
                            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.