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

Re: [Cheetahtemplate-discuss] new #call directive implemented

Expand Messages
  • Mike Orr
    ... That sounds like something from the Developer s Guide. I probably tried to run that template and got an exception. I ve never used #cache and Tavis said
    Message 1 of 46 , Jan 4, 2006
    • 0 Attachment
      On 1/3/06, Tavis Rudd <tavis@...> wrote:
      > On Tuesday 03 January 2006 11:38 am, Shannon -jj Behrens wrote:
      > > o The following should be fixed:
      > >
      > > The template:
      > >
      > > #cache test=$isDBUpdated
      > > This is a cached region. $voom
      > > #end cache
      > >
      > > (Analysis postponed: bug in Cheetah produces invalid Python.)
      >
      > I don't understand this one ...

      That sounds like something from the Developer's Guide. I probably
      tried to run that template and got an exception. I've never used
      #cache and Tavis said he was going to renovate it, I didn't analyze
      further.

      Are you still planning a major change to #cache? I think there are
      some unimplemented features.

      > > o Cheetah can't deal with the following construct:
      > >
      > > #for ($name, $dir, $children) in $map
      > > $name
      > > #end for
      > yeah, the parsing of #for directives needs improvement.


      I'd consider this the highest priority. I sometimes want to do this
      in templates, and instead I have to use a tuple variable and a bunch
      of #set's.

      > Ditto for #set.

      I think I've had some #set annoyances but I can't remember what.


      >
      > > o If you follow the Python style guide, it recommends python docs that look
      > > like this:
      > >
      > > """One line.
      > >
      > > Para-
      > > graph.
      > >
      > > """
      > >
      > > If you try to do this with Cheetah:
      > >
      > > #*doc-method: One line.
      > >
      > > Para-
      > > graph.
      > >
      > > *#
      > >
      > > You would think that you'd be fine because Cheetah strips out whitespace
      > > on lines with nothing other than directives. However, you'll end up with
      > > the indentation as well as a newline in the HTML source. Hence, you must
      > > do the following *with no indentation*:
      > >
      > > #*doc-method: One line.
      > >
      > > Para-
      > > graph.
      > >
      > > *##slurp
      > this is unfortunate, but I don't see any way around it.

      I've found all the #*doc- directives seem pretty useless in practice
      except #doc-module. Do people really look at compiled templates
      except to debug them?

      The documentation is getting more and more out of date. Tavis, do you
      have time to go through the Users' Guide and Developers' Guide and
      note what's obsolete or missing? Then JJ or I can fill in the text.

      I'm not excited about spending time rewriting the Developers' Guide
      though, so let's see how many obvious mistakes it has. It's easy to
      take stuff out or just change wording, and we can list the additions
      on an errata page, or just say the guide was written for an older
      version of Cheetah and leave it at that.

      --
      Mike Orr <sluggoster@...>
      (mso@... address is semi-reliable)


      -------------------------------------------------------
      This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
      for problems? Stop! Download the new AJAX search engine that makes
      searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
      http://ads.osdn.com/?ad_idv37&alloc_id865&op=click
      _______________________________________________
      Cheetahtemplate-discuss mailing list
      Cheetahtemplate-discuss@...
      https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss
    • Tavis Rudd
      I ve just checked in support for decorators: #from xxx import aDecorator ... ... #@aDecorator #def func #end def It also works with blocks. As in vanilla
      Message 46 of 46 , Jan 26, 2006
      • 0 Attachment
        I've just checked in support for decorators:
        #from xxx import aDecorator
        ...
        ...
        #@aDecorator
        #def func

        #end def

        It also works with blocks. As in vanilla Python, the @decorator statement
        must be followed with a function/method definition (i.e. #def or #block).



        On Wednesday 04 January 2006 4:01 pm, Shannon -jj Behrens wrote:
        > On 1/4/06, Tavis Rudd <tavis@...> wrote:
        > > On Wednesday 04 January 2006 1:40 pm, Ian Bicking wrote:
        > > > Shannon -jj Behrens wrote:
        > > > > On 1/3/06, Tavis Rudd <tavis@...> wrote:
        > > > >>On Tuesday 03 January 2006 11:38 am, Shannon -jj Behrens wrote:
        > > > >>>On 1/3/06, Tavis Rudd <tavis@...> wrote:
        > > > >>>o I want a mechanism like Mason's inheritance mechanism which
        > > > >>> permits each parent class to wrap it's child class's main method
        > > > >>> and call $m->callnext at the right time for the child to take over.
        > > > >>> This should chain through the inheritance hierarchy. It's
        > > > >>> probably too late to add this feature. Section 8.3 details the
        > > > >>> correct Cheetah idiom. Section 8.8 shows how to use block to
        > > > >>> simplify the superclass. Specifically:
        > > > >>>
        > > > >>> In the Inheritance approach, parents provide #blocks and
        > > > >>> children override them using #def.
        > > > >>>
        > > > >>> I just coded Mason's feature in Aquarium. See
        > > > >>> <http://www.linuxjournal.com/article/8747>.
        > > > >>
        > > > >>Can you expand on how this would apply to Cheetah?
        > > > >
        > > > > I brought it up because it was on my list, and it's a key piece of
        > > > > Aquarium. However, I'm not so sure many other people would enjoy or
        > > > > adapt to this pattern. It would be possible to add a compiler
        > > > > setting that said, "run InverseExtend on the #implements method".
        > > > > This would also clear up the common problem of "which method should I
        > > > > implement?"
        > > >
        > > > Could similar functionality be implemented using decorators? And, of
        > > > course, Cheetah extended with a decorator syntax.
        > > >
        > > > It wouldn't be automatic, I'd guess, but *if* the superclass method was
        > > > written with this in mind, and *if* the subclass method used the
        > > > decorator, it should work, and I don't think the decorator should be
        > > > too hard to implement (though it's not obvious to me exactly how it
        > > > would work).
        > >
        > > If you guys could provide a pseudocode example of this, or two, I'll
        > > look into the implementation.
        >
        > Pseudocode for which part?
        >
        > A decorator might look like:
        >
        > #@wrapped
        > #def foo
        > #end def
        >
        > Hence, to use inverse extend, along the inheritance hierarchy, parent
        > class methods might look like:
        >
        > #def __call__(callNext, *args, **kargs)
        > Start stuff.
        > $callNext(*args, **kargs)
        > End stuff.
        > #end def
        >
        > Then, the child class would look like:
        >
        > #@inverse_extend
        > #def __call__(someArgument, someOther)
        > Hi! I'm doing stuff!
        > #end def
        >
        > Anyway, code for this along (except the decorator part) along with an
        > explanation can be found <http://www.linuxjournal.com/article/8747>.
        >
        > Happy Hacking!
        > -jj
        >
        > --
        > Law is much too important to be left to politicians, lawyers, and
        > celebrities.


        -------------------------------------------------------
        This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
        for problems? Stop! Download the new AJAX search engine that makes
        searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
        http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
        _______________________________________________
        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.