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

[Cheetahtemplate-discuss] '#set module varName = expr' implemented (was Re: new #call directive implemented)

Expand Messages
  • Tavis Rudd
    ... done. The old syntax is wacky enough that I misremembered it. It s actually ##docformat@ aString which translates to __docformat__= aString . As you can
    Message 1 of 46 , Jan 4, 2006
    • 0 Attachment
      On Wednesday 04 January 2006 1:33 pm, Shannon -jj Behrens wrote:
      > > > o We need some way of declaring module level variables like
      > > > VERSION_STRING and __docformat__.
      > >
      > > It's already there, though the syntax is a bit ugly
      > > ##__docformat__@ = 'xxxx'
      >
      > Whacky :) Perhaps "#set module __docformat__ =" would be a nice
      > counterpart to "#set global".

      done.

      The old syntax is wacky enough that I misremembered it. It's actually
      ##docformat@ aString
      which translates to __docformat__= 'aString'. As you can see, it only worked
      with strings. I've never used it.


      -------------------------------------------------------
      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_id=7637&alloc_id=16865&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.