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

Re: [Cheetahtemplate-discuss] one more directive

Expand Messages
  • robert_kuzelj@yahoo.com
    hi mike, when using a method or function the primary purpose is to have a container that serves a welldefined unit of work. this is fact in all structured
    Message 1 of 9 , Jul 1, 2002
    • 0 Attachment
      hi mike,

      when using a method or function the primary
      purpose is to have a container that serves
      a welldefined unit of work.

      this is fact in all structured languages, which
      cheetah is a member of. usually in cheetah the
      use for defs is to have a self-serving piece of
      output. but i dont see a reason not to use a function
      as a means of computing. neither conceptially
      nor technically.

      remeber my (and that is solely "my") primary aim
      is to have a programming-environment that does not
      force escaping. cheetah is nearly perfect at that
      cause it is "nearly" a fully capable of all programming
      concepts i expect (excluding return) and has a very
      straight way into python. straight on the other hand
      doesnt mean its completly painless or not disruptive.

      my programming-process in cheetah looks like this.
      - write all contentcode and "business-logic" cheetah.
      - refactor in cheetah
      - refactor for performance in cheetah/python

      that is simply "make run, make right, make it fast".

      at the current stage i will not be bothered with different
      environmental needs. that is the reason i dont like
      the velocity/java-match.

      ciao robertj
      ------------------------------------------------------------
      Robert Kuzelj
      Gaissacherstrasse 7 email: robert_kuzelj@...
      81371 Muenchen tel: 0177/5302230

      the trinity of desirables of (software) architecture:
      Firmitas, Utilitas, Venustas (marcus vitruvius 20 BC)
      strength, utility, beauty

      ----- Original Message -----
      From: "Mike Orr" <iron@...>
      To: "Cheetah Template List" <cheetahtemplate-discuss@...>
      Sent: Saturday, June 29, 2002 9:11 PM
      Subject: Re: [Cheetahtemplate-discuss] one more directive


      > On Sat, Jun 29, 2002 at 01:30:01PM +0200, robert_kuzelj@... wrote:
      > > first on my list, guess what is a new #directive. ;-)
      > > i would like to have a #return which does exactly
      > > what its python cousin does.
      >
      > To do what? Return early from a #def? #stop does this.
      >
      > If you want to return a value that's different from the #def
      > output, you can't. Otherwise, what would it do with the #def
      > output? Throw it away? That would be nonintuitive because the
      > purpose of #def is to produce output.
      >
      > This is the closest thing to a regular Python method:
      >
      > #def $func($arg1, $arg2)
      > #echo $fancyFormula + $arg1 - $arg2#slurp
      > #end def
      >
      > --
      > -Mike (Iron) Orr, iron@... (if mail problems: mso@...)
      > http://iron.cx/ English * Esperanto * Russkiy * Deutsch * Espan~ol
      >
      >
      > -------------------------------------------------------
      > This sf.net email is sponsored by:ThinkGeek
      > No, I will not fix your computer.
      > http://thinkgeek.com/sf
      > _______________________________________________
      > Cheetahtemplate-discuss mailing list
      > Cheetahtemplate-discuss@...
      > https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss



      -------------------------------------------------------
      This sf.net email is sponsored by:ThinkGeek
      Welcome to geek heaven.
      http://thinkgeek.com/sf
      _______________________________________________
      Cheetahtemplate-discuss mailing list
      Cheetahtemplate-discuss@...
      https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss
    • robert_kuzelj@yahoo.com
      hi tavis, ... control ... is ... Python c ode and you ll see what I m on about. ... jessir! ... it ... hopefully my more philosophic/processoriented
      Message 2 of 9 , Jul 1, 2002
      • 0 Attachment
        hi tavis,

        >>Well, not quite. #stop returns, but it doesn't allow the method to
        control
        >>what it returns. It always returns either the current sum of all text
        >>output from the #def'ined method or it returns None if the method is
        >>streaming the output via a 'Transaction' or 'DummyTransaction' object that
        is
        >>passed in by the calling code. Have a look at some Cheetah generated
        Python
        c>>ode and you'll see what I'm on about.

        >>In contrast, #return would allow the method to specify the return value.
        >>Robert, is this what you mean?
        jessir!

        >>I thought about adding this last year, but held back until there was a
        >>demonstrated need for it. If no one can think of a compelling reason why
        it
        >>shouldn't be implemented, we can add it now.
        hopefully my more "philosophic/processoriented" explanation is
        reason enough.

        ciao robertj

        ------------------------------------------------------------
        Robert Kuzelj
        Gaissacherstrasse 7 email: robert_kuzelj@...
        81371 Muenchen tel: 0177/5302230

        the trinity of desirables of (software) architecture:
        Firmitas, Utilitas, Venustas (marcus vitruvius 20 BC)
        strength, utility, beauty




        -------------------------------------------------------
        This sf.net email is sponsored by:ThinkGeek
        Welcome to geek heaven.
        http://thinkgeek.com/sf
        _______________________________________________
        Cheetahtemplate-discuss mailing list
        Cheetahtemplate-discuss@...
        https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss
      • Mike Orr
        ... Which is what #def is, a mini unit of its context, or in Cheetah terms a mini-template. Like an #include file but with better handling of arguments, and
        Message 3 of 9 , Jul 1, 2002
        • 0 Attachment
          On Mon, Jul 01, 2002 at 10:53:06AM +0200, robert_kuzelj@... wrote:
          > when using a method or function the primary
          > purpose is to have a container that serves
          > a welldefined unit of work.

          Which is what #def is, a mini unit of its context, or in Cheetah terms a
          mini-template. Like an #include file but with better handling of
          arguments, and the ability to be overridden in a subclass.

          > this is fact in all structured languages, which
          > cheetah is a member of. usually in cheetah the
          > use for defs is to have a self-serving piece of
          > output. but i dont see a reason not to use a function
          > as a means of computing. neither conceptially
          > nor technically.

          Since it's already been implemented, it doesn't matter what I think
          about it. My goal is to prevent "DTML hell" where one tries to do
          everything in Cheetah because they can. Then you end up with a
          function that does no more than its Python equivalent would, while being
          harder to maintain because it has to deal with Cheetah's quirks rather
          than being cleanly expressed in a language that was designed for
          analytic logic (Python).

          > remeber my (and that is solely "my") primary aim
          > is to have a programming-environment that does not
          > force escaping. cheetah is nearly perfect at that
          > cause it is "nearly" a fully capable of all programming
          > concepts i expect (excluding return) and has a very
          > straight way into python. straight on the other hand
          > doesnt mean its completly painless or not disruptive.

          > my programming-process in cheetah looks like this.
          > - write all contentcode and "business-logic" cheetah.
          > - refactor in cheetah
          > - refactor for performance in cheetah/python

          The thing is, this goes against one of the general goals of Cheetah.
          Cheetah is for big texty things that need a bit of logic to help them
          along, not for programmy things. The purpose of #def is to allow you to
          write a big texty thing without having to use concatenation operators,
          string quoting, explicit .getVar() lookups or 'return'. If you need a
          'return' and can't be bothered to transform it to an output placeholder +
          #stop (or #expr EXPRESSION + #stop), perhaps #def is the wrong tool for
          the job.

          The reason Cheetah has all these Python-like directives is because we
          aren't sure where to draw the line. Sometimes you have a big texty
          thing that just needs one or two little #while's or #try's, and you
          don't want to convert it to Python just for that, or maybe it would be
          the only method in the Python class so it would get lonely. So the
          directives are meant for occasional avoidance of escaping in a method
          that's primarily text based, not to avoid extensive escaping in a method
          that's really analytical, and I can't think of a case where a method
          that has to #return something is not analytical.

          --
          -Mike (Iron) Orr, iron@... (if mail problems: mso@...)
          http://iron.cx/ English * Esperanto * Russkiy * Deutsch * Espan~ol


          -------------------------------------------------------
          This sf.net email is sponsored by:ThinkGeek
          Welcome to geek heaven.
          http://thinkgeek.com/sf
          _______________________________________________
          Cheetahtemplate-discuss mailing list
          Cheetahtemplate-discuss@...
          https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss
        • robert_kuzelj@yahoo.com
          hi mike, ... i think this is a goal on that you will fail. it is simply (as you have admitted yourself) very hard to draw the line. different projects have
          Message 4 of 9 , Jul 3, 2002
          • 0 Attachment
            hi mike,

            > Since it's already been implemented, it doesn't matter what I think
            > about it. My goal is to prevent "DTML hell" where one tries to do
            > everything in Cheetah because they can. Then you end up with a
            > function that does no more than its Python equivalent would, while being
            > harder to maintain because it has to deal with Cheetah's quirks rather
            > than being cleanly expressed in a language that was designed for
            > analytic logic (Python).
            i think this is a goal on that you will fail. it is simply (as you
            have admitted yourself) very hard to draw the line. different
            projects have different contexts and might purposefully decide
            to implement stuff in cheetah which you personally would not ever do.

            comming from a java-background (6+ years) and being very happy with
            the language in the begining i am being more and more fed up with the
            "savety" java gives me. it is so restrictive, that sometimes it makes
            simle things incredibly hard to do.

            >> my programming-process in cheetah looks like this.
            >> - write all contentcode and "business-logic" cheetah.
            >> - refactor in cheetah
            >> - refactor for performance in cheetah/python
            >
            > The thing is, this goes against one of the general goals of Cheetah.
            > Cheetah is for big texty things that need a bit of logic to help them
            > along, not for programmy things. The purpose of #def is to allow you to
            > write a big texty thing without having to use concatenation operators,
            > string quoting, explicit .getVar() lookups or 'return'. If you need a
            > 'return' and can't be bothered to transform it to an output placeholder +
            > #stop (or #expr EXPRESSION + #stop), perhaps #def is the wrong tool for
            > the job.
            maybe i wasnt very clear on what i am doing. i am very well aware that
            cheetah is for big texty things and i am doing exactly this (a java
            sourcecode generator).

            > The reason Cheetah has all these Python-like directives is because we
            > aren't sure where to draw the line. Sometimes you have a big texty
            > thing that just needs one or two little #while's or #try's, and you
            > don't want to convert it to Python just for that, or maybe it would be
            > the only method in the Python class so it would get lonely. So the
            > directives are meant for occasional avoidance of escaping in a method
            > that's primarily text based, not to avoid extensive escaping in a method
            > that's really analytical, and I can't think of a case where a method
            > that has to #return something is not analytical.
            just an example:
            my model is being supplied by means of an dom-tree that i traverse
            when generating code. but the concrete output may depend on some flags.

            ##typedescription is an domelement
            #def getType($TypeDescription)
            #set $type = $TypeDescription.getAttribute("PrimaryType").getValue()
            #else if $type == "VT_I1"
            #return "short"
            #else if ($type == "VT_BOOL")
            #return "boolean"
            #else if ($type == "VT_BSTR")
            #return "String"
            #else if ($type == "VT_LPSTR")
            #return "String"
            #end def

            ##and then
            public $getType($typedesc)($getParams)
            {
            $getType($typedesc) result = new $getType($typedesc);
            ...
            }
            ##(i know that getType could be also implemented as a dict)

            is that businesslogic? i dont think so. must of the code
            just renders the output. but some "logic" snippets are
            used in multiple places. its exactly like the source for
            a gui that renders the gui according to the modelstate.
            there i have functions too, that maybe reused somewhere else.

            ciao robertj
            ------------------------------------------------------------
            Robert Kuzelj
            Gaissacherstrasse 7 email: robert_kuzelj@...
            81371 Muenchen tel: 0177/5302230

            the trinity of desirables of (software) architecture:
            Firmitas, Utilitas, Venustas (marcus vitruvius 20 BC)
            strength, utility, beauty




            -------------------------------------------------------
            This sf.net email is sponsored by:ThinkGeek
            No, I will not fix your computer.
            http://thinkgeek.com/sf
            _______________________________________________
            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.