[Kss-devel] How is the KSS context determined?

Martin Aspeli optilude at gmx.net
Mon Dec 24 02:19:48 CET 2007


Balazs Ree wrote:
> On Sat, 27 Oct 2007 22:39:29 +0100, Martin Aspeli wrote:
>> Martin Aspeli wrote:
>>> How is the KSS context determined? That is, what is the base URL used
>>> when submitting a server-side request?
>> *bump* - I'm happy to debug what goes on inside the namespace traversal
>> adapters, but I need to know where to start looking. How does KSS know
>> which base URL to submit to for an action-server?
> 
> The base url is decided in the file kukit.js, in the function 
> kukit.Engine.prototype.calculateBase . It is pretty complicated, and I 
> actually have no remembering of neither a description of the supported 
> use cases nor a written discussion about it.

I finally had time to look at this again (I need to fix it for PLIP 202, 
which adds KSS inline validation/editing for formlib forms - see 
https://svn.plone.org/svn/plone/plone.app.form/branches/plip202-formlib-kss 
and https://svn.plone.org/svn/plone/review/optilude-plip202).

> As I read from the code it tries to fetch the base in the following order:
> 
> 1. if there is a link with rel="kss-base-url", it is using the href of 
> that as base. This allows a manual override from the template. I cannot 
> tell you why/when this is needed or used, since point 2. is meant to do 
> exactly the same.
> 
> 2. if there is a "base" tag in the html, it is using its href. In 
> addition it strips the trailing "/" from it, if there is one. This is 
> what happens normally, I believe also in your case.
> 
> 3. If this is not present it uses window.location from javascript.
> 
> I hope this helps something, please contact me when you want about this 
> issue, I'd try to look at it deeper as well. We may need to improve this 
> algorithm to cover the case you are using.

That's actually relatively straightforward. The problem is that the 
<base /> tag in Plone is rendered with a call to context/absolute_url, 
and in the case of namespace traversal magic, absolute_url doesn't 
appear to be reliable.

I'm going to look into fixing that (either in renderBase.py in Plone or 
in the portlets and content rules implementations, where I'm seeing 
this). If I can't, adding a <link /> tag as in (1) above should be 
pretty easy too.

Martin

-- 
Author of `Professional Plone Development`, a book for developers who
want to work with Plone. See http://martinaspeli.net/plone-book



More information about the Kss-devel mailing list