Ticket #12898 (closed Bug: wontfix)

Opened 4 years ago

Last modified 3 years ago

getRemoteURL logic surprising and faulty

Reported by: miohtama Owned by:
Priority: minor Milestone: 4.x
Component: General Version: 4.1
Keywords: Cc:


Currently Link content have getRemoteUrl portal_catalog metadata. This is to adi to links go to the their target directly if you are a site visitor.

However the logic deciding when to follow link automatically (print direct URL) is faulty:


        def get_link_url(item):
            linkremote = item.getRemoteUrl and not member == item.Creator
            if linkremote:
                return (get_id(item), item.getRemoteUrl)
                return False

This means that only item creator is able to go to the link by clicking it, edit it and correct the URL. Other site editors cannot do this.


  • Is it possible to check whether you are able to edit the item in the navigation tree output stage - this would be the correct check
  • If is not possible could this condition made overrideable, so that at least sites suffering from this logic (editors don't want getRemoteUrl() behavior) have a way to set a workaround locally e.g. having getRemoteUrl() behavior only for anonymous visitors

Change History

comment:1 Changed 4 years ago by miohtama

Here is a monkey-patch to fix this for the navigation tree. Looks like the issue is handled separately for tabs and navigation trees and there is no unified code path.

from Products.CMFPlone.browser import navigation
from Products.CMFPlone.browser.navigation import  get_id, get_view_url
from Acquisition import aq_inner
from Products.CMFCore.utils import getToolByName
from zope.component import getMultiAdapter, queryUtility
from Products.CMFPlone import utils
from plone.i18n.normalizer.interfaces import IIDNormalizer

def decoratorFactory(self, node):
    context = aq_inner(self.context)
    request = context.REQUEST

    newNode = node.copy()
    item = node['item']

    portalType = getattr(item, 'portal_type', None)
    itemUrl = item.getURL()
    if portalType is not None and portalType in self.viewActionTypes:
        itemUrl += '/view'

    useRemoteUrl = False
    getRemoteUrl = getattr(item, 'getRemoteUrl', None)
    # isCreator = self.memberId == getattr(item, 'Creator', None)
    if getRemoteUrl and self.memberId is None:
        useRemoteUrl = True

    isFolderish = getattr(item, 'is_folderish', None)
    showChildren = False
    if isFolderish and (portalType is None or portalType not in self.parentTypesNQ):
        showChildren = True

    ploneview = getMultiAdapter((context, request), name=u'plone')

    newNode['Title'] = utils.pretty_title_or_id(context, item)
    newNode['id'] = item.getId
    newNode['UID'] = item.UID
    newNode['absolute_url'] = itemUrl
    newNode['getURL'] = itemUrl
    newNode['path'] = item.getPath()
    newNode['item_icon'] = ploneview.getIcon(item)
    newNode['Creator'] = getattr(item, 'Creator', None)
    newNode['creation_date'] = getattr(item, 'CreationDate', None)
    newNode['portal_type'] = portalType
    newNode['review_state'] = getattr(item, 'review_state', None)
    newNode['Description'] = getattr(item, 'Description', None)
    newNode['show_children'] = showChildren
    newNode['no_display'] = False # We sort this out with the nodeFilter
    # BBB getRemoteUrl and link_remote are deprecated, remove in Plone 4
    newNode['getRemoteUrl'] = getattr(item, 'getRemoteUrl', None)
    newNode['useRemoteUrl'] = useRemoteUrl
    newNode['link_remote'] = newNode['getRemoteUrl'] and newNode['Creator'] != self.memberId

    idnormalizer = queryUtility(IIDNormalizer)
    newNode['normalized_portal_type'] = idnormalizer.normalize(portalType)
    newNode['normalized_review_state'] = idnormalizer.normalize(newNode['review_state'])
    newNode['normalized_id'] = idnormalizer.normalize(newNode['id'])

    return newNode

from Products.CMFPlone.browser import navtree
navtree.SitemapNavtreeStrategy.decoratorFactory = decoratorFactory

comment:2 Changed 4 years ago by eleddy

  • Status changed from new to confirmed

how about a pull request for this so there can be discussion on it?

comment:3 Changed 3 years ago by eleddy

  • Status changed from confirmed to closed
  • Resolution set to wontfix

This ticket has not been modified in over 9 months. In another brazen attempt to clean this tracker up, this is closed. If you really, REALLY care about this ticket, please re-verify that it is still an issue on the current supported releases (4.2 or 4.3) and reopen. Better yet, submit a pull request to fix the bug and then close the bug properly. We <3 you and all of your effort, but we can't go on like this anymore. I hope you aren't too mad and we can still be friends. Hugs.

Note: See TracTickets for help on using tickets.