Hello kasapo,

I do not completely follow you code. If I do, you have two blocks. The
code included in one of the blocks seems to extend a  block included
in another block. I am unsure this is supposed to work. Anyway, let's
try figure out what has changed that broke and then we may be able to
revert the previous behavior.

Can you try:

hg revert -r 1488 gluon/template.py > ~/Downloads/template.diff

Dow it work?

If yes, download the latest web2py again and do

hg diff -r 1488 gluon/template.py > ~/Downloads/template.diff

you will see what has changed in the file. mostly comments.
Try manually revert each of the changes. Which ones causes the
problem?


On May 5, 11:55 am, kasapo <[email protected]> wrote:
> Hi all,
>
> I recently setup another instance of web2py for testing on a new
> system, and noticed something strange with blocks.
>
> Basically, I have three slightly different versions of web2py running:
> 1.89.3 (DEMO server), 1.91.6 (DEV server) and 1.95.1 which I just
> installed with the auto-upgrade feature (TEST server -- soon to be the
> Production server).
>
> The problem is, i have an include directive inside of a block/end
> block pair. The included file (right-col.html) then goes on to define
> a couple other blocks (for navigation mainly) which are filled in by
> different templates associated with different areas of the site.
>
> However, templates which extend the file which includes right-col.html
> do not have access to BLOCKs that are defined INSIDE of right-
> col.html, but this behavior occurs only on the TEST server (v1.95.1)
>
> This code WORKED before 1.95.1 (on DEMO and DEV):
>
> #################
> # views/bare.html
> #################
> <html>
>  ... (abbreviated for brevity's sake)
>      <div id='content'>
>      {{ block content }}{{ end }}
>      </div>
>
>       {{ block right-col }}
>            {{ include 'base/right-col.html' }}
>       {{ end }}
>
> ...
> </html>
> #EOF bare.html
>
> #######################
> # views/base/right-col.html
> #######################
> <div id='right-col'>
>    {{ block nav }}
>    {{ end }}
>
>    <section id='social'>
>    {{ block social }}{{end}}
>    </section>
>
> </div>
> #EOF
>
> #################
> # views/base.html
> #################
> {{ extends 'bare.html }}
>
> {{ block content }}
>     {{ include }}
> {{ end }}
>
> <!-- defines stuff inside of right-col -->
> {{ block nav }}
>     <nav id='side-nav'>
>     {{=MENU(get_menu(request.controller) or standard_menu)}}
>     </nav>
> {{ end }}
>
> {{ block social }}
>    ... stuff to do with social networking
> {{ end }}
> #EOF
>
> ####################
> # view/some-page.html
> ####################
> {{ extends 'base.html' }}
>
> Blah blah blah. Wait, my side menu is missing. Crap.
>
> But the outline of the sidebar is still there since div#right-col is
> present....
>
> #EOF
>
> What I had to do to get it to work with the TEST version was to take
> away the include statement for right-col.html and move the contents of
> the file inside the right-col block in bare.html. This works fine.
>
>  The strange thing is that the <div id='right-col'><section
> id='social'></section></div> (the markup in right-col.html) shows up
> -- even if I wrap it in a block within the included file. The problem
> is just that the template blocks defined in the right-col.html file
> seem to be forgotten later on in the template. So even though
> bare.html includes right-col, the base file, which extends bare,
> cannot access the blocks defined in the right-col file. Thus, when
> rendering "some-page" which extends "base", the contents of the right
> column aren't included.
>
> So, the question:
>
> Is my usage of blocks improper? Or is this an undesired outcome of
> code updates?
>
> I just checked the code.google.com page and did not see any issues,
> open or closed, that mentioned anything about this.
>
> Thanks,
> Faithful web2py user
>
> PS:
>
> I think the reason I did this was to be able to reuse HTML chunks
> which might be included in different places on the page, or even among
> different templates from the site (e.g. bare.html is the ancestor of
> most public pages, but user.html is the ancestor of another, and both
> should be able to use right-col.html).
>
> Also, I would love to see the include directive supported within for
> loops, though I think I see why it is not. I think the include
> directives are always handled first and the file is included before
> the template is parsed, thus template variables are not available and
> loops cannot be iterated. Oh well.

Reply via email to