cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeff Turner <je...@apache.org>
Subject Re: ResourceExistsAction
Date Mon, 23 Jun 2003 10:03:09 GMT
On Mon, Jun 23, 2003 at 11:08:25AM +0200, Michael Wechner wrote:
> Gianugo Rabellino wrote:
> >Michael Wechner wrote:
> >
> >>I have "patched" the ResourceExistsAction in the case of the resources 
> >>sitemap pipeline (file-exists), such that
> >>it only checks files and not directories. Therefore URLs such as 
> >>.../oscom/authoring/ are working
> >>again, but it seems to me that this is just a quick fix and we need to 
> >>think of something better.
> >
> >
> >Would you guys please consider avoiding code duplication between Lenya 
> >and Cocoon? ResourceExistsAction is pure c&p from the Cocoon codebase, 
> >with a change of package and a one liner added. This is a bit unethical, 
> >technically poor and, most of all, misleading for users that will find 
> >two ResourceExistsAction and won't know exactly which is which. At a 
> >very least, please consider renaming it to something like FileExistsAction.
> 
> agreed. But what about enhancing the ResourceExistsAction, such that one 
> can configure it only to check on files or directories or both?
> 
> Would Cocoon be interested in a patch like this?

If you're using 2.1 and doing if-then-else logic, it might be better to
modify the ResourceExistsSelector.  Eg, comparing:

<map:act type="resource-exists">
  <map:parameter name="url" value="content/xdocs/{1}{2}" />
  <map:generate src="content/xdocs/{../1}{../2}" />
  ...
  <map:serialize type="xml"/>
</map:act>
<!-- stuff to do if resource doesn't exist -->

with:

<map:select type="exists">
  <map:when test="content/xdocs/{1}{2}">
    <map:generate src="content/xdocs/{1}{2}" />
    ...
    <map:serialize type="xml"/>
  </map:when>
  <map:otherwise>
    <!-- stuff to do if resource doesn't exist -->
  </map:otherwise>
</map:select>

Making a FileExistsSelector and DirectoryExistsSelector from this
wouldn't be hard.


--Jeff

> Thanks
> 
> Michael
> 
> 
> >
> >Ciao,
> >

Mime
View raw message