forrest-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tim Williams <william...@gmail.com>
Subject Re: Locationmap now works for repositories
Date Tue, 07 Jun 2005 17:49:23 GMT
On 6/7/05, Ross Gardler <rgardler@apache.org> wrote:
> Tim Williams wrote:
> > On 6/7/05, Ross Gardler <rgardler@apache.org> wrote:
> >
> >>Tim Williams wrote:
> >>
> >>>On 6/6/05, Ross Gardler <rgardler@apache.org> wrote:
> >>>
> >>>
> >>>>Tim Williams wrote:
> >>>>
> >>>>
> >>>>>On 6/6/05, Ross Gardler <rgardler@apache.org> wrote:
> >>>>>
> >>>>>
> >>>>>
> >>>>>>Tim Williams wrote:
> >>>>
> >>>>...
> >>>>
> >>>>
> >>>>
> >>>>><map:select type="exists">
> >>>>>    <map:when test="{project:content.xdocs}tabs.xml">
> >>>>>         <map:generate src="{project:content.xdocs}tabs.xml"/>
> >>>>>    </map:when>
> >>>>>    <map:when test="{lm:tabs.xml}">
> >>>>>         <map:generate src="{lm:tabs.xml}"/>
> >>>>>     </map:when>
> >>>>></map:select>
> >>>>
> >>>>This is interesting. Have you tested what happens when {lm:tabs.xml}
> >>>>does not point to anything useful? That is, does the second <map:when>
work?
> >>>
> >>>
> >>>:( Sadly, no.  It looks like {lm:tabs.xml} always evaluates to
> >>>existing.  Are locationmaps not usable in an exists selector for some
> >>>reason?
> >>>
> >>
> >>My guess is (there's another disclaimer, I haven't tested this yet)...
> >>
> >>Since you are mapping the {lm:tabs.xml} to a http request a document is
> >>always returned. It may be a 404 error, but it is still a document. To
> >>confirm this we would need to look at the generator code and, if
> >>necessary detect error conditions from the various repository types.
> >
> >
> > The problem or at least a symptom appears to be with the resolver
> > inside the select method of SourceExistsSelector.  Here's my
> > rationale:
> >
> > o) LocationMapModule appears to properly be responding with null if a
> > particular hint is not found.
> 
> This is different from what I intended to ask above. I meant if the hint
> *does* resolve to something sensible in the locationmap (e.g.
> http://slide.domain.org:8080/page.xml) what happens.

It works fine then.  

> What you appear to have tested is what happens if the locationmap does
> not have a match for the resource.

Right, I've now tested:
a) If the "hint" does exist in locationmap.xml --> Works as expected 
b) If the "hint" does exist in locationmap.xml but the location src is
junk --> fails in the same way that it would if
{project.content.xdocs}tabs.xml didn't exist.
c) If the "hint" does not exist in locationmap.xml --> Works as
expected once SourceExistSelector is hacked.

> > o) The empty string comes into SourceExistsSelector and for some weird
> > reason the resolver resolves it to
> > "file:/C:/src/apache-forrest-7-branch/main/webapp/" (for me, but you
> > get the idea).
> 
> This is not weird if one knows the internals of Cocoon. This location is
>   the context root for your installation of Cocoon. This is were
> everything is relative to. So, since we have a null from the locaitonmap
> module we are looking in the root.

This may seem reasonable to Cocooners but I still think such behaviour
is non-intuitive.

> > o) Obviously calling src.exists() on the above location returns true
> > causing the map:when to always evaluate to true even when no hint is
> > found in the locationmap.
> 
> This is an interesting point...
> 
> > I've got a temporary hack in place by testing for an empty uri
> > parameter immediately before it even gets to the resolver.  This gets
> > me the behaviour I would expect in an exists selector test
> 
> Does it get the behaviour you expect. Have you tried having a valid
> match in the locationmap but not having the resource present at
> indicated location?

It is what I expect.  That's my test "b" above.  

> > but I'm
> > thinking it'd be best if someone who knows exactly how the
> > resolver/SourceExistsSelector works took a look at it.  In the mean
> > time, I could use my little hack to keep moving.
> 
> I would have thought we can just check for a null in the
> SourceExistsSelector. However, this is a Cocoon component not a Forrest
> one so we need to take this to Cocoon. I don't have the time to follow
> it through just yet, maybe next week.

Right now a null test didn't work so I'm checking for null or "". 
Somewhere along the line that null is passed in as a "" but I don't
know where/how yet.

> Could you provide a patch to the locationmap branch for the stuff that
> you have done so that we can both see the same code.

Sure, post it to the jira issue or send to the list? It'll take some
time because I'm going to have to revert everything and reapply select
changes locally so that I don't goof anything up.

--tim

Mime
View raw message