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

[Cheetahtemplate-discuss] Some good ideas in Mighty Template, too.

Expand Messages
  • Olivier Favre-Simon
    Cheetah is great tool, and I m very satisfied with my current use and knowledge of it. Anyway I was looking at Mighty Template for fun, and even if the
    Message 1 of 13 , Aug 25, 2005
    • 0 Attachment
      Cheetah is great tool, and I'm very satisfied with my current use and
      knowledge of it.

      Anyway I was looking at Mighty Template for fun, and even if the <%
      syntax is giving me eczema there are good ideas too in this framework:

      example:
      http://www.myghty.org/source/htdocs/examples/template_step2/layout.myt

      ---------------------------------------------------
      <%doc>
      layout.myt, regular layout
      </%doc>

      <%args>
      title
      header
      leftnav
      body
      footer
      </%args>

      <html>
      <head>
      <title><% title %></title>
      <link rel="stylesheet" href="style.css"></link>
      </head>

      <body>
      <div class="header">
      <% header %>
      </div>

      <div class="left-column">
      <% leftnav %>
      </div>

      <div class="content-body">
      <% body %>
      </div>


      <div class="footer">
      <% footer %>
      </div>
      </body>

      </html>
      ---------------------------------------------------


      The <%args> to summarize template args is very useful. find & grep are
      wonderful CLI utils but may be Cheetah could have an equivalent #args
      construct.

      The <%doc> to have information/introspection/alike data is good too.
      Cheetah could have a #doc construct, far better than ## comments at the
      start of the file, because the compiler would know that its' made for
      inclusion into say introspection data.

      0.9.x is probably not the time for introducing new constructs, because
      1.0 release may be a priority, and these 2 constructs are sugar not
      fixes, but why not in a 1.1 or so ?
    • Shannon -jj Behrens
      ... Myghty is based on Mason from the Perl world. I ve used it a lot, and I really liked it. My absolute favorite part was $m- callnext which passes
      Message 2 of 13 , Aug 26, 2005
      • 0 Attachment
        On 8/25/05, Olivier Favre-Simon <olivier.favre-simon@...> wrote:
        > Cheetah is great tool, and I'm very satisfied with my current use and
        > knowledge of it.
        >
        > Anyway I was looking at Mighty Template for fun, and even if the <%
        > syntax is giving me eczema there are good ideas too in this framework:

        Myghty is based on Mason from the Perl world. I've used it a lot, and
        I really liked it. My absolute favorite part was "$m->callnext" which
        passes control from the parent class to the child class. I liked this
        feature so much that it's now one of the core parts of Aquarium
        <http://aquarium.sourceforge.net/api/public/aquarium.util.InternalLibrary.InternalLibrary-class.html#inverseExtend>.

        > example:
        > http://www.myghty.org/source/htdocs/examples/template_step2/layout.myt
        >
        > ---------------------------------------------------
        > <%doc>
        > layout.myt, regular layout
        > </%doc>
        >
        > <%args>
        > title
        > header
        > leftnav
        > body
        > footer
        > </%args>
        >
        > <html>
        > <head>
        > <title><% title %></title>
        > <link rel="stylesheet" href="style.css"></link>
        > </head>
        >
        > <body>
        > <div class="header">
        > <% header %>
        > </div>
        >
        > <div class="left-column">
        > <% leftnav %>
        > </div>
        >
        > <div class="content-body">
        > <% body %>
        > </div>
        >
        >
        > <div class="footer">
        > <% footer %>
        > </div>
        > </body>
        >
        > </html>
        > ---------------------------------------------------
        >
        >
        > The <%args> to summarize template args is very useful. find & grep are
        > wonderful CLI utils but may be Cheetah could have an equivalent #args
        > construct.

        <%args> is important in Mason because Perl doesn't have nearly the
        argument processing that Python has. <%args> is used in Mason as
        special support for a library that comes from CPAN to add better
        argument processing. Yes, perhaps <%args> is nice to grep for, but
        by and large, Python doesn't really need it like Perl does.

        > The <%doc> to have information/introspection/alike data is good too.
        > Cheetah could have a #doc construct, far better than ## comments at the
        > start of the file, because the compiler would know that its' made for
        > inclusion into say introspection data.

        Cheetah has #*doc-method *# and #*doc-class *# that work just like
        Python doc strings.

        > 0.9.x is probably not the time for introducing new constructs, because
        > 1.0 release may be a priority, and these 2 constructs are sugar not
        > fixes, but why not in a 1.1 or so ?

        The one feature in Mason that you didn't mention was <&| /foo:bar
        &>pass this to foo.bar</&>. This came up on this mailing list
        recently. If I get some free time, I'll probably submit a patch to
        add this to Cheetah. On the other hand, since my third baby is due
        next month, getting free time is unlikely ;)

        Thanks for your comments!

        Best Regards,
        -jj

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


        -------------------------------------------------------
        SF.Net email is Sponsored by the Better Software Conference & EXPO
        September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
        Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
        Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
        _______________________________________________
        Cheetahtemplate-discuss mailing list
        Cheetahtemplate-discuss@...
        https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss
      • Shannon -jj Behrens
        ... Hmm, I suspect there s a disconnect here. Did you know that you can embed multiple methods in the same Cheetah template? #def foo(a, b, c= d , **kargs):
        Message 3 of 13 , Aug 26, 2005
        • 0 Attachment
          > >>example:
          > >> http://www.myghty.org/source/htdocs/examples/template_step2/layout.myt
          > >>
          > >>---------------------------------------------------
          > >><%doc>
          > >> layout.myt, regular layout
          > >></%doc>
          > >>
          > >><%args>
          > >> title
          > >> header
          > >> leftnav
          > >> body
          > >> footer
          > >></%args>
          > >>
          > >><html>
          > >><head>
          > >> <title><% title %></title>
          > >> <link rel="stylesheet" href="style.css"></link>
          > >></head>
          > >>
          > >><body>
          > >> <div class="header">
          > >> <% header %>
          > >> </div>
          > >>
          > >> <div class="left-column">
          > >> <% leftnav %>
          > >> </div>
          > >>
          > >> <div class="content-body">
          > >> <% body %>
          > >> </div>
          > >>
          > >>
          > >> <div class="footer">
          > >> <% footer %>
          > >> </div>
          > >></body>
          > >>
          > >></html>
          > >>---------------------------------------------------
          > >>
          > >>
          > >>The <%args> to summarize template args is very useful. find & grep are
          > >>wonderful CLI utils but may be Cheetah could have an equivalent #args
          > >>construct.
          > >>
          > >>
          > >
          > ><%args> is important in Mason because Perl doesn't have nearly the
          > >argument processing that Python has. <%args> is used in Mason as
          > >special support for a library that comes from CPAN to add better
          > >argument processing. Yes, perhaps <%args> is nice to grep for, but
          > >by and large, Python doesn't really need it like Perl does.
          > >
          > >
          > >
          > I don't know perl :-( so I'll trust you about the language/syntax reason.
          >
          > What I was thinking about is Design By Contract: if an argument is not
          > present an error is emited *at start* of the processing.

          Hmm, I suspect there's a disconnect here. Did you know that you can
          embed multiple methods in the same Cheetah template?

          #def foo(a, b, c="d", **kargs):
          hi!
          #end def

          It's just like normal Python. It *is* design by contract. The stuff
          that isn't in any method is in the default method. You can change the
          default method name by using "#implements name". However, in almost
          all of my code, I don't use the default method at all. I put
          everything in explicit methods:

          #def __call__(count)
          #*doc-method: Print out the count.*##slurp
          Count: $count
          #end def

          > How many times are people bitten by NotFound / AttributeError when the
          > control flow reach an intricate #else statement, because of a prior
          > error or some special use case (e.g. empty db table or xml file and you
          > wan't to output custom message instead of table and bang! the $msg is
          > missing)
          >
          > Sure test coverage is meant to go in every possible path but I find DBC
          > better : control flow wouldn't even enter the template before error is reach
          > reached.
          >
          > I'm found of bash+vi so find+grep is cool for me, but netherless
          > grouping well defined interface at template head seems great to me.
          >
          > #args wouldn't mean that this _is_ the interface, but that these are
          > _required_ arguments. You may still pass additionnal ones...
          >
          > (added bonus: we could get rid of the $ sign on these because it would
          > be clear that these are template args)

          > Congrats! and happy time with your family JJ.

          Thanks!

          Best Regards,
          -jj

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


          -------------------------------------------------------
          SF.Net email is Sponsored by the Better Software Conference & EXPO
          September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
          Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
          Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
          _______________________________________________
          Cheetahtemplate-discuss mailing list
          Cheetahtemplate-discuss@...
          https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss
        • Olivier Favre-Simon
          ... I saw the thread about this in the Aquarium ML, and found it to be very practical (in some cases you really need to go backward in the hierarchy) ... I
          Message 4 of 13 , Aug 26, 2005
          • 0 Attachment
            Shannon -jj Behrens wrote:

            >On 8/25/05, Olivier Favre-Simon <olivier.favre-simon@...> wrote:
            >
            >
            >>Cheetah is great tool, and I'm very satisfied with my current use and
            >>knowledge of it.
            >>
            >>Anyway I was looking at Mighty Template for fun, and even if the <%
            >>syntax is giving me eczema there are good ideas too in this framework:
            >>
            >>
            >
            >Myghty is based on Mason from the Perl world. I've used it a lot, and
            >I really liked it. My absolute favorite part was "$m->callnext" which
            >passes control from the parent class to the child class. I liked this
            >feature so much that it's now one of the core parts of Aquarium
            ><http://aquarium.sourceforge.net/api/public/aquarium.util.InternalLibrary.InternalLibrary-class.html#inverseExtend>.
            >
            >
            I saw the thread about this in the Aquarium ML, and found it to be very
            practical (in some cases you really need to go backward in the hierarchy)

            >>example:
            >> http://www.myghty.org/source/htdocs/examples/template_step2/layout.myt
            >>
            >>---------------------------------------------------
            >><%doc>
            >> layout.myt, regular layout
            >></%doc>
            >>
            >><%args>
            >> title
            >> header
            >> leftnav
            >> body
            >> footer
            >></%args>
            >>
            >><html>
            >><head>
            >> <title><% title %></title>
            >> <link rel="stylesheet" href="style.css"></link>
            >></head>
            >>
            >><body>
            >> <div class="header">
            >> <% header %>
            >> </div>
            >>
            >> <div class="left-column">
            >> <% leftnav %>
            >> </div>
            >>
            >> <div class="content-body">
            >> <% body %>
            >> </div>
            >>
            >>
            >> <div class="footer">
            >> <% footer %>
            >> </div>
            >></body>
            >>
            >></html>
            >>---------------------------------------------------
            >>
            >>
            >>The <%args> to summarize template args is very useful. find & grep are
            >>wonderful CLI utils but may be Cheetah could have an equivalent #args
            >>construct.
            >>
            >>
            >
            ><%args> is important in Mason because Perl doesn't have nearly the
            >argument processing that Python has. <%args> is used in Mason as
            >special support for a library that comes from CPAN to add better
            >argument processing. Yes, perhaps <%args> is nice to grep for, but
            >by and large, Python doesn't really need it like Perl does.
            >
            >
            >
            I don't know perl :-( so I'll trust you about the language/syntax reason.

            What I was thinking about is Design By Contract: if an argument is not
            present an error is emited *at start* of the processing.

            How many times are people bitten by NotFound / AttributeError when the
            control flow reach an intricate #else statement, because of a prior
            error or some special use case (e.g. empty db table or xml file and you
            wan't to output custom message instead of table and bang! the $msg is
            missing)

            Sure test coverage is meant to go in every possible path but I find DBC
            better : control flow wouldn't even enter the template before error is reach
            reached.

            I'm found of bash+vi so find+grep is cool for me, but netherless
            grouping well defined interface at template head seems great to me.

            #args wouldn't mean that this _is_ the interface, but that these are
            _required_ arguments. You may still pass additionnal ones...

            (added bonus: we could get rid of the $ sign on these because it would
            be clear that these are template args)

            >>The <%doc> to have information/introspection/alike data is good too.
            >>Cheetah could have a #doc construct, far better than ## comments at the
            >>start of the file, because the compiler would know that its' made for
            >>inclusion into say introspection data.
            >>
            >>
            >
            >Cheetah has #*doc-method *# and #*doc-class *# that work just like
            >Python doc strings.
            >
            >
            >
            I should re-re-read the online doc :-)

            >>0.9.x is probably not the time for introducing new constructs, because
            >>1.0 release may be a priority, and these 2 constructs are sugar not
            >>fixes, but why not in a 1.1 or so ?
            >>
            >>
            >
            >The one feature in Mason that you didn't mention was <&| /foo:bar
            >&>pass this to foo.bar</&>. This came up on this mailing list
            >recently. If I get some free time, I'll probably submit a patch to
            >add this to Cheetah.
            >
            I'm trying to find spare time to sneek around on other frameworks :
            Paste for sure, but Mighty because of the design that is both clear and
            complete. I like the components idea, and the scope parameterization to
            search for arguments upward to top of hierarchy.

            I probably missed lot of other features, but I'll try to report
            interesting concepts I find in Mighty, at least those that wouldn't need
            huge work/rewrite to add to Cheetah... #args would be preconditon in DBC
            terminology, so in wouldn't be too intrusive in the engine (but I have
            to think about #extends and #block implications)

            An evidence that Mighty is really interesting me is that I meat some
            success at overcoming pythonic repulsion for % & | that perlmongers
            really are crazy found of :-))

            > On the other hand, since my third baby is due
            >next month, getting free time is unlikely ;)
            >Thanks for your comments!
            >
            >Best Regards,
            >-jj
            >
            >
            >
            Congrats! and happy time with your family JJ.
          • mso@oz.net
            ... You can change a couple compiler settings to prevent it from recognizing the Python escapes. #compiler PSPStartToken = //= #compiler PSPEndToken = //-
            Message 5 of 13 , Aug 26, 2005
            • 0 Attachment
              Shannon -jj Behrens wrote:
              > On 8/25/05, Olivier Favre-Simon <olivier.favre-simon@...>
              > wrote:
              >> Cheetah is great tool, and I'm very satisfied with my current use and
              >> knowledge of it.
              >>
              >> Anyway I was looking at Mighty Template for fun, and even if the <%
              >> syntax is giving me eczema there are good ideas too in this framework:

              You can change a couple compiler settings to prevent it from recognizing
              the Python escapes.

              #compiler PSPStartToken = '//='
              #compiler PSPEndToken = '//-'
              <% foo %>

              If you don't like these directives in the template there's a Template
              constructor arg for them too.

              Maybe we should have another compiler directive to disable the Python
              escapes. It's a rarely used feature, and choosing an obscure string to
              set them to can be inconvenient.

              --
              -- Mike Orr <mso@...>



              -------------------------------------------------------
              SF.Net email is Sponsored by the Better Software Conference & EXPO
              September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
              Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
              Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
              _______________________________________________
              Cheetahtemplate-discuss mailing list
              Cheetahtemplate-discuss@...
              https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss
            • mso@oz.net
              ... One *should* put a module docstring at the top of the template listing all the placeholder values required, but it s so inconvenient to look for them all
              Message 6 of 13 , Aug 26, 2005
              • 0 Attachment
                Olivier Favre-Simon wrote:
                >
                > Shannon -jj Behrens wrote:
                >
                >>>>>example:
                >>>>>http://www.myghty.org/source/htdocs/examples/template_step2/layout.myt
                >>>>>
                >>>>>---------------------------------------------------
                >>>>><%doc>
                >>>>> layout.myt, regular layout
                >>>>></%doc>
                >>>>>
                >>>>><%args>
                >>>>> title
                >>>>> header
                >>>>> leftnav
                >>>>> body
                >>>>> footer
                >>>>></%args>
                >>>>>
                >>>>><html>
                >>>>><head>
                >>>>> <title><% title %></title>
                >>>>> <link rel="stylesheet" href="style.css"></link>
                >>>>></head>
                >>>>>
                >>>>><body>
                >>>>> <div class="header">
                >>>>> <% header %>
                >>>>> </div>
                >>>>>
                >>>>> <div class="left-column">
                >>>>> <% leftnav %>
                >>>>> </div>
                >>>>>
                >>>>> <div class="content-body">
                >>>>> <% body %>
                >>>>> </div>
                >>>>>
                >>>>>
                >>>>> <div class="footer">
                >>>>> <% footer %>
                >>>>> </div>
                >>>>></body>
                >>>>>
                >>>>></html>
                >>>>>---------------------------------------------------
                >>>>>
                >>>>>
                >>>>>The <%args> to summarize template args is very useful. find & grep are
                >>>>>wonderful CLI utils but may be Cheetah could have an equivalent #args
                >>>>>construct.
                >>>>>
                >>>>>
                >>>>>
                >>>>>
                >>>><%args> is important in Mason because Perl doesn't have nearly the
                >>>>argument processing that Python has. <%args> is used in Mason as
                >>>>special support for a library that comes from CPAN to add better
                >>>>argument processing. Yes, perhaps <%args> is nice to grep for, but
                >>>>by and large, Python doesn't really need it like Perl does.
                >>>>
                >>>>
                >>>>
                >>>>
                >>>>
                >>>I don't know perl :-( so I'll trust you about the language/syntax
                >>> reason.
                >>>
                >>>What I was thinking about is Design By Contract: if an argument is not
                >>>present an error is emited *at start* of the processing.
                >>>
                >>>
                >>
                >>Hmm, I suspect there's a disconnect here. Did you know that you can
                >>embed multiple methods in the same Cheetah template?
                >>
                >>#def foo(a, b, c="d", **kargs):
                >> hi!
                >>#end def
                >>
                >>It's just like normal Python. It *is* design by contract. The stuff
                >>that isn't in any method is in the default method. You can change the
                >>default method name by using "#implements name". However, in almost
                >>all of my code, I don't use the default method at all. I put
                >>everything in explicit methods:
                >>
                >>#def __call__(count)
                >>#*doc-method: Print out the count.*##slurp
                >>Count: $count
                >>#end def
                >>
                >>
                > Yes, you can do this.
                >
                > But I'm thinking about interface at large. I find that for example:
                >
                > #args
                > username
                > email
                > subscription_date
                > #end args
                >
                > at template head is much more expressive than any particular python
                > construct (in your example a python method or magic method): It doesn't
                > care wether the args will be used in #for, #if, #def or wathever... they
                > just have to all be present in the searchList.

                One *should* put a module docstring at the top of the template listing all
                the placeholder values required, but it's so inconvenient to look for them
                all and write up a description that I rarely bother. Using #def methods
                to provide a convenient calling syntax and enforce the required parameters
                is a way around this, and some people use #def methods exclusively. If
                you look at a compiled template made that way, the main method is just the
                garbage whitespace between the other methods.

                The #args directive is an interesting idea. However, you can do the same
                thing with a #silent method:

                ==== ValidatedTemplate.py
                from Cheetah.NameMapper import NotFound
                from Cheetah.Template import Template
                class ValidatedTemplate(Templated):
                def args(self, *names):
                for name in names:
                try:
                self.getVar(name)
                except NotFound:
                raise RuntimeError("""\
                this template requires a searchList variable %r""" % name)

                ==== MyTemplate.tmpl
                #extends ValidatedTemplate
                #implements respond
                #silent $args('a', 'b', 'c')


                (I had to precompile the template to get this to work. Using "cheetah
                fill", it couldn't find the ValidatedTemplate module.)

                --
                -- Mike Orr <mso@...>



                -------------------------------------------------------
                SF.Net email is Sponsored by the Better Software Conference & EXPO
                September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
                Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
                Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
                _______________________________________________
                Cheetahtemplate-discuss mailing list
                Cheetahtemplate-discuss@...
                https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss
              • Olivier Favre-Simon
                ... Yes, you can do this. But I m thinking about interface at large. I find that for example: #args username email subscription_date #end args at template head
                Message 7 of 13 , Aug 26, 2005
                • 0 Attachment
                  Shannon -jj Behrens wrote:

                  >>>>example:
                  >>>>http://www.myghty.org/source/htdocs/examples/template_step2/layout.myt
                  >>>>
                  >>>>---------------------------------------------------
                  >>>><%doc>
                  >>>> layout.myt, regular layout
                  >>>></%doc>
                  >>>>
                  >>>><%args>
                  >>>> title
                  >>>> header
                  >>>> leftnav
                  >>>> body
                  >>>> footer
                  >>>></%args>
                  >>>>
                  >>>><html>
                  >>>><head>
                  >>>> <title><% title %></title>
                  >>>> <link rel="stylesheet" href="style.css"></link>
                  >>>></head>
                  >>>>
                  >>>><body>
                  >>>> <div class="header">
                  >>>> <% header %>
                  >>>> </div>
                  >>>>
                  >>>> <div class="left-column">
                  >>>> <% leftnav %>
                  >>>> </div>
                  >>>>
                  >>>> <div class="content-body">
                  >>>> <% body %>
                  >>>> </div>
                  >>>>
                  >>>>
                  >>>> <div class="footer">
                  >>>> <% footer %>
                  >>>> </div>
                  >>>></body>
                  >>>>
                  >>>></html>
                  >>>>---------------------------------------------------
                  >>>>
                  >>>>
                  >>>>The <%args> to summarize template args is very useful. find & grep are
                  >>>>wonderful CLI utils but may be Cheetah could have an equivalent #args
                  >>>>construct.
                  >>>>
                  >>>>
                  >>>>
                  >>>>
                  >>><%args> is important in Mason because Perl doesn't have nearly the
                  >>>argument processing that Python has. <%args> is used in Mason as
                  >>>special support for a library that comes from CPAN to add better
                  >>>argument processing. Yes, perhaps <%args> is nice to grep for, but
                  >>>by and large, Python doesn't really need it like Perl does.
                  >>>
                  >>>
                  >>>
                  >>>
                  >>>
                  >>I don't know perl :-( so I'll trust you about the language/syntax reason.
                  >>
                  >>What I was thinking about is Design By Contract: if an argument is not
                  >>present an error is emited *at start* of the processing.
                  >>
                  >>
                  >
                  >Hmm, I suspect there's a disconnect here. Did you know that you can
                  >embed multiple methods in the same Cheetah template?
                  >
                  >#def foo(a, b, c="d", **kargs):
                  > hi!
                  >#end def
                  >
                  >It's just like normal Python. It *is* design by contract. The stuff
                  >that isn't in any method is in the default method. You can change the
                  >default method name by using "#implements name". However, in almost
                  >all of my code, I don't use the default method at all. I put
                  >everything in explicit methods:
                  >
                  >#def __call__(count)
                  >#*doc-method: Print out the count.*##slurp
                  >Count: $count
                  >#end def
                  >
                  >
                  Yes, you can do this.

                  But I'm thinking about interface at large. I find that for example:

                  #args
                  username
                  email
                  subscription_date
                  #end args

                  at template head is much more expressive than any particular python
                  construct (in your example a python method or magic method): It doesn't
                  care wether the args will be used in #for, #if, #def or wathever... they
                  just have to all be present in the searchList.

                  #def is one case, but I really dislike having to crawl through a whole
                  template source to find all items that should be in the searchList (and
                  all the parent templates: may be an arg is not used in the file but
                  inside a #block of some parent).

                  Sure you can do it with comments too, but it's not DBC just dbc-spirit.

                  Of course a template shouldn't span over tons of lines but be split and
                  the whole grouped as a hierachy, but then you have to inspect many
                  smaller templates, which is just a littler better (some people would
                  even disagree on that last point)

                  DBC triggers error before the start of an action not in the course of it
                  (even if you can rollback). With the #def method the error will be
                  triggered when the normal python control flow uses the argument, not
                  beforehand...

                  (It's not a major concern here because templates shouldn't have embeded
                  business logic and shouldn't exhibit side effects, but I rather use a
                  tool that enforce good behavior over one that simply expect user to
                  behave well.)

                  May be it's just I'm used to think differently because of a small Eiffel
                  backgound. I really liked those preconditions.
                • Olivier Favre-Simon
                  Hi Mike, That s just that I m not used to the
                  Message 8 of 13 , Aug 26, 2005
                  • 0 Attachment
                    Hi Mike,

                    That's just that I'm not used to the <% ... (even worse: I had very bad
                    time at porting crappy asp apps so it' really a psycho syndrom), but I
                    think I'll survive :-)

                    And I find the Cheetah one better... (only possible contenders for me
                    are the xml-syntax based one ala ZPT (thinking of kidtemplate in
                    particular), but Cheetah is better suited to what I and my coworkers do.
                    (and because we have to deal with PHP/Smarty too, and conversion and
                    much easier)

                    So I'm not requiring any particular change here (even if added
                    flexibility with compiler setting is not bad; but then the current (and
                    harder to solve) requests from other users on Unicode stuff would
                    certainly get higher priority).

                    Regards.


                    mso@... wrote:

                    >Shannon -jj Behrens wrote:
                    >
                    >
                    >>On 8/25/05, Olivier Favre-Simon <olivier.favre-simon@...>
                    >>wrote:
                    >>
                    >>
                    >>>Cheetah is great tool, and I'm very satisfied with my current use and
                    >>>knowledge of it.
                    >>>
                    >>>Anyway I was looking at Mighty Template for fun, and even if the <%
                    >>>syntax is giving me eczema there are good ideas too in this framework:
                    >>>
                    >>>
                    >
                    >You can change a couple compiler settings to prevent it from recognizing
                    >the Python escapes.
                    >
                    > #compiler PSPStartToken = '//='
                    > #compiler PSPEndToken = '//-'
                    > <% foo %>
                    >
                    >If you don't like these directives in the template there's a Template
                    >constructor arg for them too.
                    >
                    >Maybe we should have another compiler directive to disable the Python
                    >escapes. It's a rarely used feature, and choosing an obscure string to
                    >set them to can be inconvenient.
                    >
                    >
                    >
                  • Shannon -jj Behrens
                    Sorry if I m repeating myself, but if you want method signature checking, you should do as I do and as Mike suggested and put everything in explicit methods in
                    Message 9 of 13 , Aug 27, 2005
                    • 0 Attachment
                      Sorry if I'm repeating myself, but if you want method signature
                      checking, you should do as I do and as Mike suggested and put
                      everything in explicit methods in your template:

                      #def method(a, b, c="d")
                      <p>$a</p>
                      #def

                      This maps 1 to 1 with Python.

                      :-/
                      -jj

                      On 8/26/05, mso@... <mso@...> wrote:
                      >
                      > Olivier Favre-Simon wrote:
                      > >
                      > > Shannon -jj Behrens wrote:
                      > >
                      > >>>>>example:
                      > >>>>>http://www.myghty.org/source/htdocs/examples/template_step2/layout.myt
                      > >>>>>
                      > >>>>>---------------------------------------------------
                      > >>>>><%doc>
                      > >>>>> layout.myt, regular layout
                      > >>>>></%doc>
                      > >>>>>
                      > >>>>><%args>
                      > >>>>> title
                      > >>>>> header
                      > >>>>> leftnav
                      > >>>>> body
                      > >>>>> footer
                      > >>>>></%args>
                      > >>>>>
                      > >>>>><html>
                      > >>>>><head>
                      > >>>>> <title><% title %></title>
                      > >>>>> <link rel="stylesheet" href="style.css"></link>
                      > >>>>></head>
                      > >>>>>
                      > >>>>><body>
                      > >>>>> <div class="header">
                      > >>>>> <% header %>
                      > >>>>> </div>
                      > >>>>>
                      > >>>>> <div class="left-column">
                      > >>>>> <% leftnav %>
                      > >>>>> </div>
                      > >>>>>
                      > >>>>> <div class="content-body">
                      > >>>>> <% body %>
                      > >>>>> </div>
                      > >>>>>
                      > >>>>>
                      > >>>>> <div class="footer">
                      > >>>>> <% footer %>
                      > >>>>> </div>
                      > >>>>></body>
                      > >>>>>
                      > >>>>></html>
                      > >>>>>---------------------------------------------------
                      > >>>>>
                      > >>>>>
                      > >>>>>The <%args> to summarize template args is very useful. find & grep are
                      > >>>>>wonderful CLI utils but may be Cheetah could have an equivalent #args
                      > >>>>>construct.
                      > >>>>>
                      > >>>>>
                      > >>>>>
                      > >>>>>
                      > >>>><%args> is important in Mason because Perl doesn't have nearly the
                      > >>>>argument processing that Python has. <%args> is used in Mason as
                      > >>>>special support for a library that comes from CPAN to add better
                      > >>>>argument processing. Yes, perhaps <%args> is nice to grep for, but
                      > >>>>by and large, Python doesn't really need it like Perl does.
                      > >>>>
                      > >>>>
                      > >>>>
                      > >>>>
                      > >>>>
                      > >>>I don't know perl :-( so I'll trust you about the language/syntax
                      > >>> reason.
                      > >>>
                      > >>>What I was thinking about is Design By Contract: if an argument is not
                      > >>>present an error is emited *at start* of the processing.
                      > >>>
                      > >>>
                      > >>
                      > >>Hmm, I suspect there's a disconnect here. Did you know that you can
                      > >>embed multiple methods in the same Cheetah template?
                      > >>
                      > >>#def foo(a, b, c="d", **kargs):
                      > >> hi!
                      > >>#end def
                      > >>
                      > >>It's just like normal Python. It *is* design by contract. The stuff
                      > >>that isn't in any method is in the default method. You can change the
                      > >>default method name by using "#implements name". However, in almost
                      > >>all of my code, I don't use the default method at all. I put
                      > >>everything in explicit methods:
                      > >>
                      > >>#def __call__(count)
                      > >>#*doc-method: Print out the count.*##slurp
                      > >>Count: $count
                      > >>#end def
                      > >>
                      > >>
                      > > Yes, you can do this.
                      > >
                      > > But I'm thinking about interface at large. I find that for example:
                      > >
                      > > #args
                      > > username
                      > > email
                      > > subscription_date
                      > > #end args
                      > >
                      > > at template head is much more expressive than any particular python
                      > > construct (in your example a python method or magic method): It doesn't
                      > > care wether the args will be used in #for, #if, #def or wathever... they
                      > > just have to all be present in the searchList.
                      >
                      > One *should* put a module docstring at the top of the template listing all
                      > the placeholder values required, but it's so inconvenient to look for them
                      > all and write up a description that I rarely bother. Using #def methods
                      > to provide a convenient calling syntax and enforce the required parameters
                      > is a way around this, and some people use #def methods exclusively. If
                      > you look at a compiled template made that way, the main method is just the
                      > garbage whitespace between the other methods.
                      >
                      > The #args directive is an interesting idea. However, you can do the same
                      > thing with a #silent method:
                      >
                      > ==== ValidatedTemplate.py
                      > from Cheetah.NameMapper import NotFound
                      > from Cheetah.Template import Template
                      > class ValidatedTemplate(Templated):
                      > def args(self, *names):
                      > for name in names:
                      > try:
                      > self.getVar(name)
                      > except NotFound:
                      > raise RuntimeError("""\
                      > this template requires a searchList variable %r""" % name)
                      >
                      > ==== MyTemplate.tmpl
                      > #extends ValidatedTemplate
                      > #implements respond
                      > #silent $args('a', 'b', 'c')
                      >
                      >
                      > (I had to precompile the template to get this to work. Using "cheetah
                      > fill", it couldn't find the ValidatedTemplate module.)
                      >
                      > --
                      > -- Mike Orr <mso@...>
                      >
                      >


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


                      -------------------------------------------------------
                      SF.Net email is Sponsored by the Better Software Conference & EXPO
                      September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
                      Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
                      Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
                      _______________________________________________
                      Cheetahtemplate-discuss mailing list
                      Cheetahtemplate-discuss@...
                      https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss
                    • Tavis Rudd
                      I agree completely. I don t see the point in adding when we already can do this. ... SF.Net email is Sponsored by the Better Software Conference &
                      Message 10 of 13 , Aug 27, 2005
                      • 0 Attachment
                        I agree completely. I don't see the point in adding <& args &> when we
                        already can do this.

                        On Saturday 27 August 2005 09:48, Shannon -jj Behrens wrote:
                        > Sorry if I'm repeating myself, but if you want method signature
                        > checking, you should do as I do and as Mike suggested and put
                        > everything in explicit methods in your template:
                        >
                        > #def method(a, b, c="d")
                        > <p>$a</p>
                        > #def
                        >
                        > This maps 1 to 1 with Python.
                        >
                        > :-/
                        >
                        > -jj
                        >
                        > On 8/26/05, mso@... <mso@...> wrote:
                        > > Olivier Favre-Simon wrote:
                        > > > Shannon -jj Behrens wrote:
                        > > >>>>>example:
                        > > >>>>>http://www.myghty.org/source/htdocs/examples/template_step2/layout.m
                        > > >>>>>yt
                        > > >>>>>
                        > > >>>>>---------------------------------------------------
                        > > >>>>><%doc>
                        > > >>>>> layout.myt, regular layout
                        > > >>>>></%doc>
                        > > >>>>>
                        > > >>>>><%args>
                        > > >>>>> title
                        > > >>>>> header
                        > > >>>>> leftnav
                        > > >>>>> body
                        > > >>>>> footer
                        > > >>>>></%args>
                        > > >>>>>
                        > > >>>>><html>
                        > > >>>>><head>
                        > > >>>>> <title><% title %></title>
                        > > >>>>> <link rel="stylesheet" href="style.css"></link>
                        > > >>>>></head>
                        > > >>>>>
                        > > >>>>><body>
                        > > >>>>> <div class="header">
                        > > >>>>> <% header %>
                        > > >>>>> </div>
                        > > >>>>>
                        > > >>>>> <div class="left-column">
                        > > >>>>> <% leftnav %>
                        > > >>>>> </div>
                        > > >>>>>
                        > > >>>>> <div class="content-body">
                        > > >>>>> <% body %>
                        > > >>>>> </div>
                        > > >>>>>
                        > > >>>>>
                        > > >>>>> <div class="footer">
                        > > >>>>> <% footer %>
                        > > >>>>> </div>
                        > > >>>>></body>
                        > > >>>>>
                        > > >>>>></html>
                        > > >>>>>---------------------------------------------------
                        > > >>>>>
                        > > >>>>>
                        > > >>>>>The <%args> to summarize template args is very useful. find & grep
                        > > >>>>> are wonderful CLI utils but may be Cheetah could have an equivalent
                        > > >>>>> #args construct.
                        > > >>>>
                        > > >>>><%args> is important in Mason because Perl doesn't have nearly the
                        > > >>>>argument processing that Python has. <%args> is used in Mason as
                        > > >>>>special support for a library that comes from CPAN to add better
                        > > >>>>argument processing. Yes, perhaps <%args> is nice to grep for, but
                        > > >>>>by and large, Python doesn't really need it like Perl does.
                        > > >>>
                        > > >>>I don't know perl :-( so I'll trust you about the language/syntax
                        > > >>> reason.
                        > > >>>
                        > > >>>What I was thinking about is Design By Contract: if an argument is not
                        > > >>>present an error is emited *at start* of the processing.
                        > > >>
                        > > >>Hmm, I suspect there's a disconnect here. Did you know that you can
                        > > >>embed multiple methods in the same Cheetah template?
                        > > >>
                        > > >>#def foo(a, b, c="d", **kargs):
                        > > >> hi!
                        > > >>#end def
                        > > >>
                        > > >>It's just like normal Python. It *is* design by contract. The stuff
                        > > >>that isn't in any method is in the default method. You can change the
                        > > >>default method name by using "#implements name". However, in almost
                        > > >>all of my code, I don't use the default method at all. I put
                        > > >>everything in explicit methods:
                        > > >>
                        > > >>#def __call__(count)
                        > > >>#*doc-method: Print out the count.*##slurp
                        > > >>Count: $count
                        > > >>#end def
                        > > >
                        > > > Yes, you can do this.
                        > > >
                        > > > But I'm thinking about interface at large. I find that for example:
                        > > >
                        > > > #args
                        > > > username
                        > > > email
                        > > > subscription_date
                        > > > #end args
                        > > >
                        > > > at template head is much more expressive than any particular python
                        > > > construct (in your example a python method or magic method): It doesn't
                        > > > care wether the args will be used in #for, #if, #def or wathever...
                        > > > they just have to all be present in the searchList.
                        > >
                        > > One *should* put a module docstring at the top of the template listing
                        > > all the placeholder values required, but it's so inconvenient to look for
                        > > them all and write up a description that I rarely bother. Using #def
                        > > methods to provide a convenient calling syntax and enforce the required
                        > > parameters is a way around this, and some people use #def methods
                        > > exclusively. If you look at a compiled template made that way, the main
                        > > method is just the garbage whitespace between the other methods.
                        > >
                        > > The #args directive is an interesting idea. However, you can do the same
                        > > thing with a #silent method:
                        > >
                        > > ==== ValidatedTemplate.py
                        > > from Cheetah.NameMapper import NotFound
                        > > from Cheetah.Template import Template
                        > > class ValidatedTemplate(Templated):
                        > > def args(self, *names):
                        > > for name in names:
                        > > try:
                        > > self.getVar(name)
                        > > except NotFound:
                        > > raise RuntimeError("""\
                        > > this template requires a searchList variable %r""" % name)
                        > >
                        > > ==== MyTemplate.tmpl
                        > > #extends ValidatedTemplate
                        > > #implements respond
                        > > #silent $args('a', 'b', 'c')
                        > >
                        > >
                        > > (I had to precompile the template to get this to work. Using "cheetah
                        > > fill", it couldn't find the ValidatedTemplate module.)
                        > >
                        > > --
                        > > -- Mike Orr <mso@...>


                        -------------------------------------------------------
                        SF.Net email is Sponsored by the Better Software Conference & EXPO
                        September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
                        Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
                        Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
                        _______________________________________________
                        Cheetahtemplate-discuss mailing list
                        Cheetahtemplate-discuss@...
                        https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss
                      • Mike Orr
                        We re talking about two different things. One is #args (searchList verification). The other is changing/disabling the escapes. Perhaps the Users Guide
                        Message 11 of 13 , Aug 27, 2005
                        • 0 Attachment
                          We're talking about two different things. One is #args (searchList
                          verification). The other is changing/disabling the <% %> escapes.

                          Perhaps the Users' Guide should promote #def more.

                          Tavis Rudd wrote:

                          >I agree completely. I don't see the point in adding <& args &> when we
                          >already can do this.
                          >
                          >
                          >On Saturday 27 August 2005 09:48, Shannon -jj Behrens wrote:
                          >
                          >
                          >>Sorry if I'm repeating myself, but if you want method signature
                          >>checking, you should do as I do and as Mike suggested and put
                          >>everything in explicit methods in your template:
                          >>
                          >>#def method(a, b, c="d")
                          >><p>$a</p>
                          >>#def
                          >>
                          >>This maps 1 to 1 with Python.
                          >>
                          >>



                          -------------------------------------------------------
                          SF.Net email is Sponsored by the Better Software Conference & EXPO
                          September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
                          Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
                          Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
                          _______________________________________________
                          Cheetahtemplate-discuss mailing list
                          Cheetahtemplate-discuss@...
                          https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss
                        • Tavis Rudd
                          I wasn t referring to changing the escapes, just the args thing. ... SF.Net email is Sponsored by the Better Software Conference & EXPO September 19-22, 2005 *
                          Message 12 of 13 , Aug 27, 2005
                          • 0 Attachment
                            I wasn't referring to changing the escapes, just the args thing.

                            On Saturday 27 August 2005 11:38, Mike Orr wrote:
                            > We're talking about two different things. One is #args (searchList
                            > verification). The other is changing/disabling the <% %> escapes.
                            >
                            > Perhaps the Users' Guide should promote #def more.
                            >
                            > Tavis Rudd wrote:
                            > >I agree completely. I don't see the point in adding <& args &> when we
                            > >already can do this.
                            > >
                            > >On Saturday 27 August 2005 09:48, Shannon -jj Behrens wrote:
                            > >>Sorry if I'm repeating myself, but if you want method signature
                            > >>checking, you should do as I do and as Mike suggested and put
                            > >>everything in explicit methods in your template:
                            > >>
                            > >>#def method(a, b, c="d")
                            > >><p>$a</p>
                            > >>#def
                            > >>
                            > >>This maps 1 to 1 with Python.
                            >
                            > -------------------------------------------------------
                            > SF.Net email is Sponsored by the Better Software Conference & EXPO
                            > September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
                            > Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
                            > Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
                            > _______________________________________________
                            > Cheetahtemplate-discuss mailing list
                            > Cheetahtemplate-discuss@...
                            > https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss


                            -------------------------------------------------------
                            SF.Net email is Sponsored by the Better Software Conference & EXPO
                            September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
                            Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
                            Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
                            _______________________________________________
                            Cheetahtemplate-discuss mailing list
                            Cheetahtemplate-discuss@...
                            https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss
                          • Tavis Rudd
                            Mike, I think you misunderstood the reference to
                            Message 13 of 13 , Aug 27, 2005
                            • 0 Attachment
                              Mike, I think you misunderstood the reference to <% and eczema. Olivier was
                              talking about their use in Mighty Template.

                              On Friday 26 August 2005 12:52, mso@... wrote:
                              > Shannon -jj Behrens wrote:
                              > > On 8/25/05, Olivier Favre-Simon <olivier.favre-simon@...>
                              > >
                              > > wrote:
                              > >> Cheetah is great tool, and I'm very satisfied with my current use and
                              > >> knowledge of it.
                              > >>
                              > >> Anyway I was looking at Mighty Template for fun, and even if the <%
                              > >> syntax is giving me eczema there are good ideas too in this framework:
                              >
                              > You can change a couple compiler settings to prevent it from recognizing
                              > the Python escapes.
                              >
                              > #compiler PSPStartToken = '//='
                              > #compiler PSPEndToken = '//-'
                              > <% foo %>
                              >
                              > If you don't like these directives in the template there's a Template
                              > constructor arg for them too.
                              >
                              > Maybe we should have another compiler directive to disable the Python
                              > escapes. It's a rarely used feature, and choosing an obscure string to
                              > set them to can be inconvenient.


                              -------------------------------------------------------
                              SF.Net email is Sponsored by the Better Software Conference & EXPO
                              September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
                              Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
                              Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
                              _______________________________________________
                              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.