Ticket #2988 (reopened Bug)

Opened 12 years ago

Last modified 23 months ago

base tag differs from actual url

Reported by: vinsci Owned by:
Priority: minor Milestone: 4.x
Component: Navigation/Folder listings Version:
Keywords: Cc:

Description (last modified by rodfersou) (diff)

The base tag is given a value that differs from the url used to retrieve the page. This is bad because it forces a page reload for page internal links. For example, see the links in the table at the top of  http://plone.org/events/conferences/1/video - clicking on a link reloads the page.

The problem is with skins/plone_scripts/renderBase.py. "cvs log renderBase.py" shows a few earlier attempts to get it right, but there's no useful discussion on the changes done. I'll investigate simply setting it to context.REQUEST.URL instead.

Change History

comment:1 Changed 12 years ago by vinsci

The renderBase.py replacement below seems to do the trick. I'll check that in unless there are objections.

# returns correct base href if getattr(context.aq_explicit, 'isPrincipiaFolderish', 0):

if context.REQUEST.URL[-1:] == '/': return context.REQUEST.URL return context.REQUEST.URL + '/'

else:

return context.REQUEST.URL

comment:2 Changed 12 years ago by limi

Is there a unit test for this? People keep changing the base tag, and it keeps breaking. If there isn't a test, I would be very cautious, there's a lot of strange CMF base tag behaviour involved. Simon Eisenmann and Ronan Amiciel are the ones that know most about this.

comment:3 Changed 12 years ago by brentmh

I don't believe there are currently any unittests for renderBase, but in any case this change is not correct. It messes up <base> for the case of an action on folderish types.

For example, when visiting  http://foo.com/folder/folder_contents it incorrectly sets base to ' http://foo.com/folder/folder_contents/' (note the excess trailing slash)

comment:4 Changed 12 years ago by vinsci

Also see the similar Zope issue:  http://collector.zope.org/Zope/1252

...and this related thread on Zope-CMF:  http://marc.free.net.ph/message/20040303.105239.a8c3b9bf.html

comment:5 Changed 12 years ago by shh

Need to take a look at renderBase then...

comment:6 Changed 11 years ago by shh

So, I have added some tests for renderBase. This may not be a simple as we'd like it to be.

For the #anchors to work, base must equal the URL appearing in the browser. For Zope relative form submission to work, base must be set to the context's URL. What a mess.

comment:7 Changed 11 years ago by vinsci

As Zope has closed (prematurely, we think) their original corresponding bug (at  http://collector.zope.org/Zope/1252), the issue was today opened again at zope.org, as a new issue:  http://collector.zope.org/Zope/1568

comment:8 Changed 11 years ago by shh

Postponing for lack of an immediate fix.

comment:9 Changed 11 years ago by vinsci

Resolved (again) in Zope 2.7.4, 2.8a2. See  http://www.zope.org/Collectors/Zope/1568

comment:10 Changed 11 years ago by limi

  • Status changed from new to closed
  • Resolution set to fixed

...almost. ;)

ACTUAL_URL does not include the query string yet, and I filed another bug at:

 http://www.zope.org/Collectors/Zope/1845

Closing this one, as we are using ACTUAL_URL, and I will follow up to make sure the Zope issue is solved properly.

comment:11 Changed 3 years ago by rodfersou

  • Status changed from closed to reopened
  • Resolution fixed deleted
  • Description modified (diff)

This problem happen again, now the code that generates the base tag url is into this piece of code  https://github.com/plone/plone.app.layout/blob/master/plone/app/layout/globals/layout.py#L115-L125

I suggest to resolve this problem this way (you need to import aq_parent too to make this work):

def renderBase(self):

"""Returns the current URL to be used in the base tag. """ context = self.context

# if it is the default page of a folder, try to get the folder url try:

if getattr(aq_base(context), 'isDefaultPage', True):

context = aq_parent(context) return context.absolute_url()

except Unauthorized:

pass

# when accessing via WEBDAV you're not allowed to access aq_base try:

if getattr(aq_base(context), 'isPrincipiaFolderish', False):

return context.absolute_url() + '/'

except Unauthorized:

pass

return context.absolute_url()

comment:12 Changed 3 years ago by rodfersou

  • Milestone changed from 2.1 to 4.x

comment:13 Changed 23 months ago by jensens

wow, thats an old one. just found a pull request for this one - see  https://github.com/plone/plone.app.layout/pull/19 - needs review

Note: See TracTickets for help on using tickets.