template inheritance

Discussion in 'Python' started by Alex K, Jan 11, 2009.

  1. Alex K

    Alex K Guest

    While building a website using template inheritance one usually does
    the following:

    fetch from database
    fetch from some more data from database
    .... << more required computations
    then at the end render the template with the fetched data

    Without template inheritance one usually does the following:

    fetch from database
    render this part of the site with this fetched data
    fetch some more data from the database
    render this other part of the site with the fetched data
    ....
    etc

    The first approach is much more elegant and leads to easier to
    maintain code. However the user will have to wait till the end of the
    fetching (long computations) before any rendering can take place. In
    the second approach however the site loads as we are fetching the data
    which is more convenient to the user.

    Am I correct to assume this? Is there a way to get the best of both
    worlds? Thank you.
    Alex K, Jan 11, 2009
    #1
    1. Advertising

  2. Alex K schrieb:
    > While building a website using template inheritance one usually does
    > the following:
    >
    > fetch from database
    > fetch from some more data from database
    > ... << more required computations
    > then at the end render the template with the fetched data
    >
    > Without template inheritance one usually does the following:
    >
    > fetch from database
    > render this part of the site with this fetched data
    > fetch some more data from the database
    > render this other part of the site with the fetched data
    > ...
    > etc
    >
    > The first approach is much more elegant and leads to easier to
    > maintain code. However the user will have to wait till the end of the
    > fetching (long computations) before any rendering can take place. In
    > the second approach however the site loads as we are fetching the data
    > which is more convenient to the user.
    >
    > Am I correct to assume this? Is there a way to get the best of both
    > worlds? Thank you.


    I don't think that the question of inheritance or not is really relevant
    here.

    It's a matter of how the templating system is written - does it collect
    all the data beforehand, or not, is it potentially using e.g. generators
    and so forth.

    And of course how the programmer uses the templating system. does he
    fetch all the data beforehand, or does he use lazy generation approachs
    - again, e.g. generators, or callbacks.

    Besides, *usually* the 20-39Kb of a website itself aren't the problem
    I'd say - loading referenced resources is much more of an issue.

    And AFAIK the render-mode matters, too. If the site is XHTML-compliant,
    the browser can start the rendering once the HTML is complete -
    otherwise, it might wait until the referenced resources are all loaded
    to calculate the layout.

    Diez
    Diez B. Roggisch, Jan 11, 2009
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Chris Theis
    Replies:
    2
    Views:
    446
    Chris Theis
    Jul 24, 2003
  2. tom_usenet
    Replies:
    0
    Views:
    515
    tom_usenet
    Jul 24, 2003
  3. Replies:
    1
    Views:
    2,072
    Gianni Mariani
    Jun 8, 2007
  4. Peng Yu
    Replies:
    3
    Views:
    750
    Thomas J. Gritzan
    Oct 26, 2008
  5. nguillot
    Replies:
    5
    Views:
    510
Loading...

Share This Page