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

[Cheetahtemplate-discuss] Skeleton, _javascriptLibs & own "Framework"

Expand Messages
  • Dirk van Oosterbosch, IR labs
    Hi All, I am trying to design the structure of my web application. But I stumbled on some issues, which I don t exactly know how to solve. I have experience
    Message 1 of 3 , Nov 24, 2005
    • 0 Attachment
      Hi All,

      I am trying to design the structure of my web application. But I
      stumbled on some issues, which I don't exactly know how to solve.

      I have experience with (stand-alone) application design, but not so
      much with web application design. This whole web application thing
      confronts me with some serious issues, which I will not tire you with
      extensively. But I do want to shortly address a few points. Maybe the
      biggest problem I am having that a web-application does not really
      function as an application, having a run-loop and a state and such. In
      the end it just comes down to delivering a page to a client.

      One of the specific strange things I am finding with working with
      cheetah, is that the inheritance of (template) classes should jump
      across the controller-view border, over and over. I like to make a
      clear separation in my code and modules, between model, controller and
      view. But cheetah doesn't really let me (if I want to use the neat
      inheritance feature of it).

      Example:
      1. SiteLogic.py (... from Cheetah.Template import Template, class
      SiteLogic(Template):)
      2. FrameworkViewComponents.tmpl/py (... #from SiteLogic import
      SiteLogic, #extends SiteLogic)
      3. Framework.py (... from FrameworkViewComponents import
      FrameworkViewComponents, class Framework(FrameworkViewComponents):)
      4. CustomTemplate.tmpl/py (... #from Framework import Framework,
      #extends Framework, #implents respond)

      The neat aspect of this arrangement is that the CustomTemplate can
      –from its main body– call a framework component, say $breadcrumb, which
      is a method defined in Framework.py, which on its turn can can call the
      view implementation of this breadcrumb component through
      self.breadcrumbview(), which then can be defined in
      FrameworkViewComponents –using #def breadcrumbview– or overridden in
      CustomTemplate.

      Now there is a separation between model, controller and view in the
      files and modules, but unfortunately the inheritance cuts right through
      this separation.
      For In this example
      1. SiteLogic.py is a controller or even a model
      2. FrameworkViewComponents.tmpl/py is a view
      3. Framework.py is a controller
      4. CustomTemplate.tmpl/py is a view

      Now I guess I'll just have to cope with this unclearness. But there is
      another issue, which is really the why I am writing this mail in the
      first place. So if you are still reading ...

      Lets say I put the SkeletonPage template on the top of this inheritance
      hierarchy. What I really would like is for the Framework.py
      (controller) to be able to add certain javascripts to _SkeletonPage's
      _javascriptLibs dictionary. I.e. it is not known before the template
      gets parsed which javascripts are needed on this page.
      As an example:
      I could put $slideshow in the page content of CustomTemplate. Then
      Framework.py's method slideshow would be called, which knows exactly
      how to make a slideshow in html. The slideshow method would call a
      Template's slideshowview view implementation through
      self.slideshowview(). But it would also have to add the special
      slideshow.js javascript to the page.

      Here the problem is showing: if Framework.py would add "slideshow.js"
      to _SkeletonPage's _javascriptLibs, it would not be effecting <head>'s
      contents, for this gets written before the CustomTemplate gets parsed.
      And I don't like to add all the javascripts that are perhaps necessary
      to make the page work. I only want to add specific javascripts if the
      CustomTemplate (or it underlaying Framework) asks for that.

      Is there a best-practices solution for this problem? Or would there be
      some hack, through which I still could use Skeleton?

      best,
      dirk

      -----------------------------
      Dirk van Oosterbosch
      de Wittenstraat 225
      1052 AT Amsterdam
      the Netherlands

      http://labs.ixopusada.com
      -----------------------------



      -------------------------------------------------------
      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
    • Shannon -jj Behrens
      ... Have you considered Aquarium ? ... True, the stateless nature of HTTP is one of the more irritating challenges of Web programming.
      Message 2 of 3 , Nov 28, 2005
      • 0 Attachment
        On 11/24/05, Dirk van Oosterbosch, IR labs <labs@...> wrote:
        > Hi All,
        >
        > I am trying to design the structure of my web application. But I
        > stumbled on some issues, which I don't exactly know how to solve.

        Have you considered Aquarium <http://aquarium.sf.net>?

        > I have experience with (stand-alone) application design, but not so
        > much with web application design. This whole web application thing
        > confronts me with some serious issues, which I will not tire you with
        > extensively. But I do want to shortly address a few points. Maybe the
        > biggest problem I am having that a web-application does not really
        > function as an application, having a run-loop and a state and such. In
        > the end it just comes down to delivering a page to a client.

        True, the stateless nature of HTTP is one of the more irritating
        challenges of Web programming.

        > One of the specific strange things I am finding with working with
        > cheetah, is that the inheritance of (template) classes should jump
        > across the controller-view border, over and over. I like to make a
        > clear separation in my code and modules, between model, controller and
        > view. But cheetah doesn't really let me (if I want to use the neat
        > inheritance feature of it).

        Absolutely, but what you're talking about has nothing to do with
        Cheetah. It's really WebWare that does that. When using Cheetah in
        Aquarium, there is no such convention. I do not mix the inheritance
        hierarchies of models, views, and controllers.

        > Example:
        > 1. SiteLogic.py (... from Cheetah.Template import Template, class
        > SiteLogic(Template):)
        > 2. FrameworkViewComponents.tmpl/py (... #from SiteLogic import
        > SiteLogic, #extends SiteLogic)
        > 3. Framework.py (... from FrameworkViewComponents import
        > FrameworkViewComponents, class Framework(FrameworkViewComponents):)
        > 4. CustomTemplate.tmpl/py (... #from Framework import Framework,
        > #extends Framework, #implents respond)
        >
        > The neat aspect of this arrangement is that the CustomTemplate can
        > –from its main body– call a framework component, say $breadcrumb, which
        > is a method defined in Framework.py, which on its turn can can call the
        > view implementation of this breadcrumb component through
        > self.breadcrumbview(), which then can be defined in
        > FrameworkViewComponents –using #def breadcrumbview– or overridden in
        > CustomTemplate.
        >
        > Now there is a separation between model, controller and view in the
        > files and modules, but unfortunately the inheritance cuts right through
        > this separation.
        > For In this example
        > 1. SiteLogic.py is a controller or even a model
        > 2. FrameworkViewComponents.tmpl/py is a view
        > 3. Framework.py is a controller
        > 4. CustomTemplate.tmpl/py is a view

        Yep, I had the same distaste as you have.

        > Now I guess I'll just have to cope with this unclearness. But there is
        > another issue, which is really the why I am writing this mail in the
        > first place. So if you are still reading ...
        >
        > Lets say I put the SkeletonPage template on the top of this inheritance
        > hierarchy. What I really would like is for the Framework.py
        > (controller) to be able to add certain javascripts to _SkeletonPage's
        > _javascriptLibs dictionary. I.e. it is not known before the template
        > gets parsed which javascripts are needed on this page.
        > As an example:
        > I could put $slideshow in the page content of CustomTemplate. Then
        > Framework.py's method slideshow would be called, which knows exactly
        > how to make a slideshow in html. The slideshow method would call a
        > Template's slideshowview view implementation through
        > self.slideshowview(). But it would also have to add the special
        > slideshow.js javascript to the page.
        >
        > Here the problem is showing: if Framework.py would add "slideshow.js"
        > to _SkeletonPage's _javascriptLibs, it would not be effecting <head>'s
        > contents, for this gets written before the CustomTemplate gets parsed.
        > And I don't like to add all the javascripts that are perhaps necessary
        > to make the page work. I only want to add specific javascripts if the
        > CustomTemplate (or it underlaying Framework) asks for that.

        Yep, in Aquarium, any view can extend the doJavaScript method to add
        its own JavaScript or JavaScript libraries.

        > Is there a best-practices solution for this problem? Or would there be
        > some hack, through which I still could use Skeleton?

        Dirk, I think you and I think alike.

        Best Regards,
        -jj

        --
        Hacking is to climbing Mt. Everest as
        software engineering is to building a Denny's there.
      • Tavis Rudd
        for the record, SkeletonPage is a quick hack that I created years ago for generating simple, and relatively static, websites. It wasn t designed for MVC style
        Message 3 of 3 , Nov 30, 2005
        • 0 Attachment
          for the record, SkeletonPage is a quick hack that I created years ago for
          generating simple, and relatively static, websites. It wasn't designed for
          MVC style applications. I haven't used it in a long time and really should
          update the docs to make its purpose more explicit.

          When creating MVC style applications with Cheetah and Webware it's best to use
          a pure python servlet as your controller. It should import or create one
          more Cheetah templates for the view portion.

          On Thursday 24 November 2005 10:56, Dirk van Oosterbosch, IR labs wrote:
          > Hi All,
          >
          > I am trying to design the structure of my web application. But I
          > stumbled on some issues, which I don't exactly know how to solve.
          >
          > I have experience with (stand-alone) application design, but not so
          > much with web application design. This whole web application thing
          > confronts me with some serious issues, which I will not tire you with
          > extensively. But I do want to shortly address a few points. Maybe the
          > biggest problem I am having that a web-application does not really
          > function as an application, having a run-loop and a state and such. In
          > the end it just comes down to delivering a page to a client.
          >
          > One of the specific strange things I am finding with working with
          > cheetah, is that the inheritance of (template) classes should jump
          > across the controller-view border, over and over. I like to make a
          > clear separation in my code and modules, between model, controller and
          > view. But cheetah doesn't really let me (if I want to use the neat
          > inheritance feature of it).
          >
          > Example:
          > 1. SiteLogic.py (... from Cheetah.Template import Template, class
          > SiteLogic(Template):)
          > 2. FrameworkViewComponents.tmpl/py (... #from SiteLogic import
          > SiteLogic, #extends SiteLogic)
          > 3. Framework.py (... from FrameworkViewComponents import
          > FrameworkViewComponents, class Framework(FrameworkViewComponents):)
          > 4. CustomTemplate.tmpl/py (... #from Framework import Framework,
          > #extends Framework, #implents respond)
          >
          > The neat aspect of this arrangement is that the CustomTemplate can
          > –from its main body– call a framework component, say $breadcrumb, which
          > is a method defined in Framework.py, which on its turn can can call the
          > view implementation of this breadcrumb component through
          > self.breadcrumbview(), which then can be defined in
          > FrameworkViewComponents –using #def breadcrumbview– or overridden in
          > CustomTemplate.
          >
          > Now there is a separation between model, controller and view in the
          > files and modules, but unfortunately the inheritance cuts right through
          > this separation.
          > For In this example
          > 1. SiteLogic.py is a controller or even a model
          > 2. FrameworkViewComponents.tmpl/py is a view
          > 3. Framework.py is a controller
          > 4. CustomTemplate.tmpl/py is a view
          >
          > Now I guess I'll just have to cope with this unclearness. But there is
          > another issue, which is really the why I am writing this mail in the
          > first place. So if you are still reading ...
          >
          > Lets say I put the SkeletonPage template on the top of this inheritance
          > hierarchy. What I really would like is for the Framework.py
          > (controller) to be able to add certain javascripts to _SkeletonPage's
          > _javascriptLibs dictionary. I.e. it is not known before the template
          > gets parsed which javascripts are needed on this page.
          > As an example:
          > I could put $slideshow in the page content of CustomTemplate. Then
          > Framework.py's method slideshow would be called, which knows exactly
          > how to make a slideshow in html. The slideshow method would call a
          > Template's slideshowview view implementation through
          > self.slideshowview(). But it would also have to add the special
          > slideshow.js javascript to the page.
          >
          > Here the problem is showing: if Framework.py would add "slideshow.js"
          > to _SkeletonPage's _javascriptLibs, it would not be effecting <head>'s
          > contents, for this gets written before the CustomTemplate gets parsed.
          > And I don't like to add all the javascripts that are perhaps necessary
          > to make the page work. I only want to add specific javascripts if the
          > CustomTemplate (or it underlaying Framework) asks for that.
          >
          > Is there a best-practices solution for this problem? Or would there be
          > some hack, through which I still could use Skeleton?
          >
          > best,
          > dirk
          >
          > -----------------------------
          > Dirk van Oosterbosch
          > de Wittenstraat 225
          > 1052 AT Amsterdam
          > the Netherlands
          >
          > http://labs.ixopusada.com
          > -----------------------------
          >
          >
          >
          > -------------------------------------------------------
          > 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


          -------------------------------------------------------
          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
        Your message has been successfully submitted and would be delivered to recipients shortly.