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

Re: [Cheetahtemplate-discuss] Mucking around with template inheritance

Expand Messages
  • Shannon -jj Behrens
    I chose not to intermix Cheetah classes with Python classes in this way so that I could vary them independently. That is, a piece of Python can make use of
    Message 1 of 11 , Oct 18, 2005
    • 0 Attachment
      I chose not to intermix Cheetah classes with Python classes in this
      way so that I could vary them independently. That is, a piece of
      Python can make use of any template it wants. That template can
      inherit from any other template it wants.

      Best Regards,
      -jj

      On 10/18/05, Henning Hasemann <hhasemann@...> wrote:
      > > I'm thinking that I probably need each level of my template hierarchy (something like global, section, page) to inherit from an intermediate
      > > pure-python class that figures out what its parent should be (or, proceeds the other way and starts at the base and specifies children).
      >
      > I'm having a structure like this at the moment.
      > I prefix the pure-python classes with the word "Base" (although that
      > choice might not be the best), looks like this:
      >
      > BaseBase (pure Python)
      > |
      > v
      > Base (Cheetah)
      > |
      > v
      > TableBase (pure Python) this is a Base class for lists
      > | (whith edit,add,delete functions)
      > v
      > Table (Cheetah)
      > |--------------------------------.
      > v v
      > StudentBase (Python) WorkstationBase (Python)
      > | |
      > v v
      > Student (Cheetah) Workstation (Cheetah)
      >
      > (you get the picture)
      > Henning
      >
      > --
      > "Windows is a 64 bit tweak of a 32-bit extension to a 16-bit user
      > interface for an 8-bit operating system based on a 4-bit architecture
      > from a 2-bit company that can't stand 1 bit of competition."
      >
      >
      > -------------------------------------------------------
      > This SF.Net email is sponsored by:
      > Power Architecture Resource Center: Free content, downloads, discussions,
      > and more. http://solutions.newsforge.com/ibmarch.tmpl
      > _______________________________________________
      > Cheetahtemplate-discuss mailing list
      > Cheetahtemplate-discuss@...
      > https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss
      >


      --
      Hacking is to climbing Mt. Everest as
      software engineering is to building a Denny's there.


      -------------------------------------------------------
      This SF.Net email is sponsored by:
      Power Architecture Resource Center: Free content, downloads, discussions,
      and more. http://solutions.newsforge.com/ibmarch.tmpl
      _______________________________________________
      Cheetahtemplate-discuss mailing list
      Cheetahtemplate-discuss@...
      https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss
    • mso@oz.net
      ... Erm, how do you get a page template to delegate from a site template? Or maybe that should be a site template delegating to a page template? -- Mike
      Message 2 of 11 , Oct 18, 2005
      • 0 Attachment
        JJ wrote:
        > Perhaps I'm misunderstanding you, but it reminds me of the age old
        > object oriented nuggest of wisdom that if you feel like you need to
        > determine an inheritance hierarchy dynamically, you should be using
        > delegation, not inheritance.

        Erm, how do you get a page template to "delegate" from a site template?
        Or maybe that should be a site template "delegating to" a page template?

        -- Mike



        -------------------------------------------------------
        This SF.Net email is sponsored by:
        Power Architecture Resource Center: Free content, downloads, discussions,
        and more. http://solutions.newsforge.com/ibmarch.tmpl
        _______________________________________________
        Cheetahtemplate-discuss mailing list
        Cheetahtemplate-discuss@...
        https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss
      • mso@oz.net
        ... Erm, how do you get a page template to delegate from a site template? Or maybe that should be a site template delegating to a page template? -- Mike
        Message 3 of 11 , Oct 18, 2005
        • 0 Attachment
          JJ wrote:
          > Perhaps I'm misunderstanding you, but it reminds me of the age old
          > object oriented nuggest of wisdom that if you feel like you need to
          > determine an inheritance hierarchy dynamically, you should be using
          > delegation, not inheritance.

          Erm, how do you get a page template to "delegate" from a site template?
          Or maybe that should be a site template "delegating to" a page template?

          -- Mike



          -------------------------------------------------------
          This SF.Net email is sponsored by:
          Power Architecture Resource Center: Free content, downloads, discussions,
          and more. http://solutions.newsforge.com/ibmarch.tmpl
          _______________________________________________
          Cheetahtemplate-discuss mailing list
          Cheetahtemplate-discuss@...
          https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss
        • Shannon -jj Behrens
          ... Well, it sounds like you re using WebWare instead of Aquarium, so things just work differently in WebWare than in Aquarium, but I assume you have something
          Message 4 of 11 , Oct 18, 2005
          • 0 Attachment
            On 10/18/05, mso@... <mso@...> wrote:
            > JJ wrote:
            > > Perhaps I'm misunderstanding you, but it reminds me of the age old
            > > object oriented nuggest of wisdom that if you feel like you need to
            > > determine an inheritance hierarchy dynamically, you should be using
            > > delegation, not inheritance.
            >
            > Erm, how do you get a page template to "delegate" from a site template?
            > Or maybe that should be a site template "delegating to" a page template?

            Well, it sounds like you're using WebWare instead of Aquarium, so
            things just work differently in WebWare than in Aquarium, but I assume
            you have something like a page template that extends a site template.
            Furthermore, you have an inheritance hierarchy such that the business
            logic is mixed in:

            WebWare stuff
            Site business logic superclass (.py)
            Site template superclass (.tmpl)
            Page business logic (.py)
            Page template (.tmpl)

            I suggest you have:

            WebWare stuff
            Site business logic superclass (.py)
            Page business logic (.py)

            WebWare stuff
            Site template superclass (.tmpl)
            Page template (.tmpl)

            Now that the two inheritance hierarchies are separate, your "Page
            business logic" can dynamically pick and use any "Page template" it
            wants.

            I hope that makes sense and is useful. At one point, I saw my boss
            struggling with the same thing in WebWare, and I figured it was
            strange to see the two inheritance hierarchies mixed like that.

            Best Regards,
            -jj


            -------------------------------------------------------
            This SF.Net email is sponsored by:
            Power Architecture Resource Center: Free content, downloads, discussions,
            and more. http://solutions.newsforge.com/ibmarch.tmpl
            _______________________________________________
            Cheetahtemplate-discuss mailing list
            Cheetahtemplate-discuss@...
            https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss
          • mso@oz.net
            ... I m all for separating business logic and presentation logic. In that scenario, a template would have a Python superclass only if *that template* needs
            Message 5 of 11 , Oct 18, 2005
            • 0 Attachment
              > On 10/18/05, mso@... <mso@...> wrote:
              >> JJ wrote:
              >> > Perhaps I'm misunderstanding you, but it reminds me of the age old
              >> > object oriented nuggest of wisdom that if you feel like you need to
              >> > determine an inheritance hierarchy dynamically, you should be using
              >> > delegation, not inheritance.
              >>
              >> Erm, how do you get a page template to "delegate" from a site template?
              >> Or maybe that should be a site template "delegating to" a page template?
              >
              > Well, it sounds like you're using WebWare instead of Aquarium, so
              > things just work differently in WebWare than in Aquarium, but I assume
              > you have something like a page template that extends a site template.
              > Furthermore, you have an inheritance hierarchy such that the business
              > logic is mixed in:
              >
              > WebWare stuff
              > Site business logic superclass (.py)
              > Site template superclass (.tmpl)
              > Page business logic (.py)
              > Page template (.tmpl)
              >
              > I suggest you have:
              >
              > WebWare stuff
              > Site business logic superclass (.py)
              > Page business logic (.py)
              >
              > WebWare stuff
              > Site template superclass (.tmpl)
              > Page template (.tmpl)
              >
              > Now that the two inheritance hierarchies are separate, your "Page
              > business logic" can dynamically pick and use any "Page template" it
              > wants.

              I'm all for separating business logic and presentation logic. In that
              scenario, a template would have a Python superclass only if *that
              template* needs presentation logic written in Python; e.g., a method
              written in Python rather than '#def', or color preferences, or the
              webmaster's email address.

              However, when using a template-servlet in Webware, the template is the
              entire response. So there are only two places to put business logic: in a
              Python superclass, or in a standalone #import'ed module.




              -------------------------------------------------------
              This SF.Net email is sponsored by:
              Power Architecture Resource Center: Free content, downloads, discussions,
              and more. http://solutions.newsforge.com/ibmarch.tmpl
              _______________________________________________
              Cheetahtemplate-discuss mailing list
              Cheetahtemplate-discuss@...
              https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss
            • mso@oz.net
              ... My original point, in case it wasn t clear, is, I don t know a model for doing site template / section template / page template hierarchies without using
              Message 6 of 11 , Oct 18, 2005
              • 0 Attachment
                >> On 10/18/05, mso@... <mso@...> wrote:
                >>> JJ wrote:
                >>> > Perhaps I'm misunderstanding you, but it reminds me of the age old
                >>> > object oriented nuggest of wisdom that if you feel like you need to
                >>> > determine an inheritance hierarchy dynamically, you should be using
                >>> > delegation, not inheritance.
                >>>
                >>> Erm, how do you get a page template to "delegate" from a site template?
                >>> Or maybe that should be a site template "delegating to" a page
                >>> template?
                >>
                >> Well, it sounds like you're using WebWare instead of Aquarium, so
                >> things just work differently in WebWare than in Aquarium, but I assume
                >> you have something like a page template that extends a site template.
                >> Furthermore, you have an inheritance hierarchy such that the business
                >> logic is mixed in:
                >>
                >> WebWare stuff
                >> Site business logic superclass (.py)
                >> Site template superclass (.tmpl)
                >> Page business logic (.py)
                >> Page template (.tmpl)
                >>
                >> I suggest you have:
                >>
                >> WebWare stuff
                >> Site business logic superclass (.py)
                >> Page business logic (.py)
                >>
                >> WebWare stuff
                >> Site template superclass (.tmpl)
                >> Page template (.tmpl)
                >>
                >> Now that the two inheritance hierarchies are separate, your "Page
                >> business logic" can dynamically pick and use any "Page template" it
                >> wants.
                >
                > I'm all for separating business logic and presentation logic. In that
                > scenario, a template would have a Python superclass only if *that
                > template* needs presentation logic written in Python; e.g., a method
                > written in Python rather than '#def', or color preferences, or the
                > webmaster's email address.
                >
                > However, when using a template-servlet in Webware, the template is the
                > entire response. So there are only two places to put business logic: in a
                > Python superclass, or in a standalone #import'ed module.

                My original point, in case it wasn't clear, is, I don't know a model for
                doing "site template / section template / page template" hierarchies
                without using inheritance. One way would be for the controller to choose
                a page template, set its searchList, plug that template as a placeholder
                value into the section template, then plug that into the site template.
                It all works, and you can choose each template dynamically this way, but
                I've generally found template-servlets with inheritance more convenient to
                maintain.

                On the other hand, not using inheritance means you can debug each template
                in isolation, rather than having one bug wipe out an entire set of
                templates and making them non-instantiatable.

                -- Mike



                -------------------------------------------------------
                This SF.Net email is sponsored by:
                Power Architecture Resource Center: Free content, downloads, discussions,
                and more. http://solutions.newsforge.com/ibmarch.tmpl
                _______________________________________________
                Cheetahtemplate-discuss mailing list
                Cheetahtemplate-discuss@...
                https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss
              • Shannon -jj Behrens
                ... Yep, sorry, I stand corrected. Best Regards, -jj -- Hacking is to climbing Mt. Everest as software engineering is to building a Denny s there. ... This
                Message 7 of 11 , Oct 18, 2005
                • 0 Attachment
                  On 10/18/05, mso@... <mso@...> wrote:
                  > > On 10/18/05, mso@... <mso@...> wrote:
                  > >> JJ wrote:
                  > >> > Perhaps I'm misunderstanding you, but it reminds me of the age old
                  > >> > object oriented nuggest of wisdom that if you feel like you need to
                  > >> > determine an inheritance hierarchy dynamically, you should be using
                  > >> > delegation, not inheritance.
                  > >>
                  > >> Erm, how do you get a page template to "delegate" from a site template?
                  > >> Or maybe that should be a site template "delegating to" a page template?
                  > >
                  > > Well, it sounds like you're using WebWare instead of Aquarium, so
                  > > things just work differently in WebWare than in Aquarium, but I assume
                  > > you have something like a page template that extends a site template.
                  > > Furthermore, you have an inheritance hierarchy such that the business
                  > > logic is mixed in:
                  > >
                  > > WebWare stuff
                  > > Site business logic superclass (.py)
                  > > Site template superclass (.tmpl)
                  > > Page business logic (.py)
                  > > Page template (.tmpl)
                  > >
                  > > I suggest you have:
                  > >
                  > > WebWare stuff
                  > > Site business logic superclass (.py)
                  > > Page business logic (.py)
                  > >
                  > > WebWare stuff
                  > > Site template superclass (.tmpl)
                  > > Page template (.tmpl)
                  > >
                  > > Now that the two inheritance hierarchies are separate, your "Page
                  > > business logic" can dynamically pick and use any "Page template" it
                  > > wants.
                  >
                  > I'm all for separating business logic and presentation logic. In that
                  > scenario, a template would have a Python superclass only if *that
                  > template* needs presentation logic written in Python; e.g., a method
                  > written in Python rather than '#def', or color preferences, or the
                  > webmaster's email address.
                  >
                  > However, when using a template-servlet in Webware, the template is the
                  > entire response. So there are only two places to put business logic: in a
                  > Python superclass, or in a standalone #import'ed module.

                  Yep, sorry, I stand corrected.

                  Best Regards,
                  -jj

                  --
                  Hacking is to climbing Mt. Everest as
                  software engineering is to building a Denny's there.


                  -------------------------------------------------------
                  This SF.Net email is sponsored by:
                  Power Architecture Resource Center: Free content, downloads, discussions,
                  and more. http://solutions.newsforge.com/ibmarch.tmpl
                  _______________________________________________
                  Cheetahtemplate-discuss mailing list
                  Cheetahtemplate-discuss@...
                  https://lists.sourceforge.net/lists/listinfo/cheetahtemplate-discuss
                • Matt Patterson
                  ... Thanks for everyone s ideas. For the moment I m kind of ducking the issue (although I suspect that I ve found a much more sensible and workable solution
                  Message 8 of 11 , Oct 24, 2005
                  • 0 Attachment
                    On 18 Oct 2005, at 19:08, Henning Hasemann wrote:


                    > I'm having a structure like this at the moment.
                    > I prefix the pure-python classes with the word "Base" (although that
                    > choice might not be the best), looks like this:
                    >
                    > BaseBase (pure Python)
                    > |
                    > v
                    > Base (Cheetah)
                    > [snip]
                    >

                    Thanks for everyone's ideas. For the moment I'm kind of ducking the
                    issue (although I suspect that I've found a much more sensible and
                    workable solution than my original idea). I'm using some minor
                    __import__ abuse to grab references to template modules and store
                    those refs in a lookup table, which maps regexes of URLs to a
                    template class.

                    So, that's how I pick my templates.

                    'Selective' inheritance is achieved by more cheating: adding a
                    'global' and a 'local' template directory to sys.path so that they
                    get searched from local to global means that you can easily override
                    global templates by dropping an identically named template into the
                    local template dir, and it will override on app restart.

                    Thanks again,

                    Matt

                    --
                    Matt Patterson | Design & Code
                    <matt at emdash co uk> | http://www.emdash.co.uk/
                    <matt at reprocessed org> | http://www.reprocessed.org/




                    -------------------------------------------------------
                    This SF.Net email is sponsored by the JBoss Inc.
                    Get Certified Today * Register for a JBoss Training Course
                    Free Certification Exam for All Training Attendees Through End of 2005
                    Visit http://www.jboss.com/services/certification for more information
                    _______________________________________________
                    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.