Hi Felix,
What I would like to work out is how an intelligent script resolution
could work that allows multiple levels of fallbacks and that supports
mixin types.
Cool, would be very interested in such an approach.
Out of my head, here is how I would do it (for an illustration, see http://weblogs.goshaky.com/weblogs/lars/resource/scriptresolution.png)
:
For script resolution, we create a weighted list of candidate paths.
As soon as a script is found in a candidate path, we start looking for
refinements, or mixin-specific scripts.
The first candidate is the path denoted by slingResouceType. If this
is not set, we resort to the primaryNode type. If there is no script
available, we build a graph of declaredSuperTypes and use the first
matching script.
If two nodes in the graph have the same distance to the primaryType,
following rules are applied:
1) nt:base has precedence over nt:unstructured
2) built-in node types have precedence over nt:base
3) user-defined node types have precedence over built-in node types
4) an alphabetical precedence ordering takes place
In the case of a defined slingResourceType, we deal with mixins in the
following way: if there are sub-folders in the folder denoted by the
slingResourceType that have a naming pattern that matches the declared
mixin types, descend into these folders and try to find a script. A
deeper descend beats a more shallow descend, so for instance
/mix/referenceable/mix/versionable beats /mix/referenceable if two
scripts are found at the same level, the precedence rules expressed
above take place, so that
/mix/versionable/mix/userdefined beats /mix/referenceable/mix/
versionable because of rule 3)
regards,
Lars