#25 includeURL and paths

closed-fixed
WebKit (58)
5
2003-01-16
2002-11-11
Anonymous
No

I've found the following bug (or maybe its a feature)
using includeURL:

Suppose we have a directory structure as follows:

/bla/mycontext
/pageTemplates
/application1
/application2

and inside pageTemplates we have a BasePage
subclassed from Page. This is the page from which
pages are subclassed in application1 and application2

at 'root level' in mycontext we have components that
are used from BasePage like footer.psp, header.html,
as well as a stylesheet file. All of this components are
included using includeURL at the proper methods.
Everything works fine when using a page (subclassed
from BasePage) at mycontext level.

the problem here is that the call
includeURL('header.html')
when we are in a page from the directory application1
will actually look for 'header.html' inside application1,
and if we use includeURL('/header.html') will not have
the disired effect of including the file from mycontext.

If its a feature, we do not know how to get that effect,
since we do not want to duplicate our files in every
directory of application#

We have temporarly fixed the problem with the
following change to includeURL inside Application.py:
def includeURL(self, trans, URL):
req = trans.request()

#Save the things we're gonna change.
currentPath=req.urlPath()
currentServlet=trans._servlet

urlPath = req.urlPath()
# ***************************** IMPORTANT
********************************
# the following condition was changed to 'accept'
an absolute path
# defined within the URL, that is: '/servlet' will
NOT be looked
# in the relative parent directory
#
# LCJ --- Oct 17th 2002
#
# original code: get rid of the first if condition and
leave the else code
# unconditioned

if (URL.startswith('/')):
urlPath = URL
else:
if urlPath=='':
urlPath = '/' + URL
elif urlPath[-1]=='/':
urlPath = urlPath + URL
else:
lastSlash = string.rfind(urlPath, '/')
urlPath = urlPath[:lastSlash+1] + URL
#
*******************************************************
*****************

req.setURLPath(urlPath)
req.addParent(currentServlet)

#Get the new servlet
self.createServletInTransaction(trans)

#call the servlet, but not session, it's already
alive
trans.servlet().awake(trans)
trans.servlet().respond(trans)
trans.servlet().sleep(trans)

self.returnInstance(trans,trans.request
().serverSidePath())

#replace things like they were
#trans.request()._serverSidePath=currentPath
req.setURLPath(currentPath)
req.popParent()
trans._servlet=currentServlet

Discussion

  • Stuart Donaldson

    Logged In: YES
    user_id=326269

    How are pages under application1 and application2
    referenced, if they are not in a context? Are the items
    under application1 and application2 only PSP and HTML?

    What defines /bla/mycontext as the "root level"?

     
  • Stuart Donaldson

    Logged In: YES
    user_id=326269

    How are pages under application1 and application2
    referenced, if they are not in a context? Are the items
    under application1 and application2 only PSP and HTML?

    What defines /bla/mycontext as the "root level"?

     
  • Geoff Talvola

    Geoff Talvola - 2003-01-15

    Logged In: YES
    user_id=88162

    Assigning to Stuart because he's currently improving
    forward(), includeURL(), and callMethodOfServlet().

     
  • Geoff Talvola

    Geoff Talvola - 2003-01-15
    • assigned_to: nobody --> stuartd
     
  • Stuart Donaldson

    • status: open --> closed-fixed
     
  • Stuart Donaldson

    Logged In: YES
    user_id=326269

    Not exactly clear on this bug report, but I believe this has
    been addressed as of 2003/01/15 .

    includeURL now takes a URL relative to the current servlet.
    Absolute references are absolute relative to the context.

     

Log in to post a comment.