browserviews not recognized as view_templates
Tim Hicks
tim at sitefusion.co.uk
Sat Sep 22 13:17:42 UTC 2007
Tom Lazar wrote:
> hi everybody,
>
> tim hicks and i are migrating Quills to Plone 3.0 and came across the
> problem that topic- and archive views (which are now handled via custom
> traversal adapters) are not recognized properly as 'view_templates',
> i.e. they lack their assigned portlets and blog entries lack a
> commenting button, etc.
To clarify, the lack of portlets is unrelated, and I should be able to
fix easily enough.
> here's a snip from the issue that has been filed at [1]
>
> --snip--
> Plone's main_template does a test explained by this comment:
>
> "The div with ID #content will only show up if we're actually on a
> content view, never on edit forms, control panels etc. It's meant to
> only wrap the actual content that gets rendered on a page, not the other
> UI elements."
>
> WeblogEntries are given URLs of the format "/year/month/day/name" and,
> as a result, fail the test contained in "plone/app/layout/globals".
> Because the WeblogEntries are not recognized as being view_templates,
> the "content" div of the main_template is not rendered. This causes both
> the contentActionMenus and the comments portions of the page not to be
> rendered. Most problematic is the dropping of the comments which loses
> any comments and the button to create comments. Moreover, the main
> weblog pages leaves off the "comments: x" link.
> --snap--
>
> and here's a relevant snippet from the traversal adapter[2]
The traversal logic is also fairly superfluous to this issue, I think.
The real problem (as pointed out in the issue report), is that
plone.app.layout.globals.context.ContextState.is_view_template is not
smart enough to figure out that it should return True when viewing a
WeblogEntry that physically lives at .../weblog/my_entry, but is
traversed to via .../weblog/2007/07/13/my_entry.
Here's the method:
def is_view_template(self):
current_url = self.current_base_url()
canonical_url = self.canonical_object_url()
object_url = self.object_url()
if current_url.endswith('/'):
current_url = current_url[:-1]
if current_url == canonical_url or current_url == object_url:
return True
elif current_url == object_url + '/view':
return True
template_id = self.view_template_id()
if current_url == "%s/%s" % (object_url, template_id):
return True
elif current_url == "%s/@@%s" % (object_url, template_id):
return True
return False
I don't know how to fix this in the general case, or even if that's
desirable, but I can see a possible fix for Quills. I guess we should
create our own ContextState implementation that overrides
is_view_template and register it only for the relevant Quills types.
Does that sound reasonable to folks here?
Tim
More information about the Product-Developers
mailing list