Ticket #8198 (closed Bug: fixed)
Aliases for Content Types don't provide IViewView in case they refer to (Default)
| Reported by: | spliter | Owned by: | maurits |
|---|---|---|---|
| Priority: | major | Milestone: | 4.2 |
| Component: | Infrastructure | Keywords: | IViewView view alias plone.app.layout folder |
| Cc: |
Description
If you create alias for Folder for example like:
index.html (Default)
you would expect to get the same you get from "view" alias (unless it's aliased to the same (Default)). But right now this doesn't happen. Aliased view you get at your_folder/index.html doesn't provide IViewView that leads to missing contentActions ("Display", "Add new" and so on) on aliased view. Moreover if you have any other stuff, based on presence of IViewView (custom viewlet maybe?) you get it broken as well.
The problem is in plone.app.layout.globals.context - every entry we have for checking whether we are actually at the view have hardcoded "/view" url. This doesn't look nice. It should check whether the current view is the same as (Default) and not use hardcoded URLs.
Change History
comment:2 follow-up: ↓ 5 Changed 4 years ago by regebro
Sorry about that, trying again:
def is_view_template(self):
...
elif current_url == object_url + '/view':
return True
+ context = aq_inner(self.context)
+ browserDefault = IBrowserDefault(context, None)
+ fti = browserDefault.getTypeInfo()
+ if current_url.split('/')[-1] in fti.getMethodAliases():
+ return True
comment:3 Changed 4 years ago by hannosch
- Owner changed from nobody to optilude
- Component changed from Unknown to Infrastructure
comment:4 Changed 2 years ago by optilude
- Owner optilude deleted
Sorry, this has been stuck with me, but it's not something I'll have time to look into.
comment:5 in reply to: ↑ 2 ; follow-up: ↓ 6 Changed 5 months ago by maurits
- Owner set to maurits
- Milestone changed from 3.3.x to 4.2
Replying to regebro:
Sorry about that, trying again:
def is_view_template(self): ... elif current_url == object_url + '/view': return True + context = aq_inner(self.context) + browserDefault = IBrowserDefault(context, None) + fti = browserDefault.getTypeInfo() + if current_url.split('/')[-1] in fti.getMethodAliases(): + return True
This would return True for all aliases, so also for 'edit' as alias for 'atct_edit' and we don't want that. This seems to do the trick instead:
if fti.getMethodAliases().get(last_part) == '(Default)':
return True
Looking at tests now, and meanwhile claiming the ticket before someone else grabs it on this TuneUp day.
comment:6 in reply to: ↑ 5 Changed 5 months ago by maurits
Right, trying again as well, for better formatting.
Replying to regebro:
Sorry about that, trying again:
def is_view_template(self):
...
elif current_url == object_url + '/view':
return True
+ context = aq_inner(self.context)
+ browserDefault = IBrowserDefault(context, None)
+ fti = browserDefault.getTypeInfo()
+ if current_url.split('/')[-1] in fti.getMethodAliases():
+ return True
This would return True for all aliases, so also for 'edit' as alias for 'atct_edit' and we don't want that. This seems to do the trick instead:
if fti.getMethodAliases().get(last_part) == '(Default)':
return True
Looking at tests now, and meanwhile claiming the ticket before someone else grabs it on this TuneUp day.

This code fixes the issues we have, but maybe there is a better way:
in plone.app.layout.globals.context.ContextState:
def is_view_template(self): ...
+ context = aq_inner(self.context) + browserDefault = IBrowserDefault(context, None) + fti = browserDefault.getTypeInfo() + if current_url.split('/')[-1] in fti.getMethodAliases(): + return True
...