Hi Bertrand,

Am Montag, den 03.12.2007, 16:57 +0100 schrieb Bertrand Delacretaz:
> Currently microsling looks for scripts under /sling/scripts, which is
> not very convenient if running several apps in the same repository:
> all scripts would end up under this path, which makes it harder to
> package applications.

Very true. The same holds for Sling for the moment.

> Here's a proposal for a different way of resolving scripts, with three
> possible cases:
> 
> a) Node has a valid sling:resourceType property
> The resource type is the value of this property, which, to be valid,
> must not be empty and must start with a /.

I think, we should allow for relative paths, so no leading slash
requirement. But: If there is a leading slash, the resourceType path
would be taken as absolute. Sounds reasonable.

But, I would say, that for maximum interoperability, such paths should
be relative.

> b) Node doesn't have a valid sling:resourceType property
> In this case, the resource type is the node type, for example 
> "nt:unstructured".
> 
> To map to a script, the resource type is converted to a valid path,
> and prefixed with "/apps/sling".

Why not just /apps ?

> For an nt:unstructured node, microsling looks for scripts named
> /apps/sling/nt/unstructured/<method>.<ext>
> 
> c) Script not found using either a) or b) rules
> As a catch-all default (useful mostly for tutorials and simple example
> apps), microsling looks for scripts named
> /apps/sling/default/<method>.<ext>

I do not like this catch all script. We have the default servlet to
catch all. If we have the catch all script, the default servlet will
probably never be called :-)

As a closing statement: I think it is important to clearly define
concerns. The first concern is "every resource has a resource type", the
second one is "the script path is derived from the resource type". What
is really important to me, is that the resource type is resolved before
the script is being resolved. The ScriptResolver only cares for the
Resoure.getResourceType.

So the first question is: How is the resource type defined ? I think it
is (a) the string value of the resource type property. This may be an
absolute or relative path or a namespaced name (e.g. nt:file, just like
a node type). (b) if there is no resource type property, the primary
node type name is used as the resource type.

The second question is: How to get the path from the resource type ? I
think it is the possibly modified resource type. If the resource type is
a namespaced name (that is contains one colon and no slash, such as
nt:file but not pref:name/other:name), the colon is replaced by a slash.
Otherwise the resource type is taken as a path as is.

Finally, the script is looked up below the resource type path if that
path is absolute. If the resoure type path is relative a search path
(compare to PATH environment variable) is applied. For microsling, this
may be fixed, for Sling this will be configurable.

WDYT ?

Regards
Felix

Reply via email to