Allow ActionMap binding to any arbitrary URL path #1

wants to merge 1 commit into


None yet
2 participants

justino commented Jan 12, 2011

Hello all. I have patched Interchange to allow ActionMaps to be defined with an arbitrary URL path.
This means that actionmaps can now mimic directory structure.
See commit message for more details and examples.

I have tested this using the 'ActionMap' config directive, as well as the 'CodeDef' config directive.

Here is the break down of basically how this patch works.
At configuration time, it determines what the max depth of all defined actionmaps is.
IE. "foo/bar/baz/quux" - is 4 levels deep
This MaxDepth is used to determine how many directories within a requests path to search for actionmaps.
The next step is to inspect the request URL and attempt to find any defined actionmaps. It does this by looking at the URL finding the $MaxDepth directories and looping through them looking for defined actionmaps. (Example below)

So say the MaxDepth is determined to be 3.
If a request, "foo/bar/baz/qux/koo" comes, it will inspect the first 3 directories, "foo/bar/baz" and look for an actionmap. If no actionmap is defined, then pop one directory off the end and re-search, this time for "foo/bar", if no actionmap is defined, then pop one directory off the end and re-search, this time for "foo".

It searches for the most specific actionmap first, and re-searches for less specific actionmaps.

If a defined actionmap is found then its corresponding subroutine is used and the entire URL is passed in as a param.
If no actionmap is found, then it falls through to checking the "pages" directory for content.

So if you have 2 actionmaps defined as:
when a request comes in for 'tracking/fedex' the 'tracking' actionmap will be used, if a request comes in for 'tracking/ups' then the more specific actionmap 'tracking/ups' will be used. Make sense?

This system should be 100% backwards compatible with the old actionmap system. All old actionmaps are 1 level deep and should be found like normal.

If you have any questions or concerns please let me know: justin [dot] lasotten [at] gmail [dot] com

@justino justino Allow ActionMap binding to any arbitrary URL path.
Originally, actions were restricted to the first directory after cgi-bin/catalog_name
within a URL; like so:

Any additional data beyond the actionmap name was sent into the corresponding function as args

You could not build actionmaps like so:
where the actionmap is defined to be 'my/action/map', this is 3 directories deep and not allowed.

This patch allows ActionMaps to be defined with any arbitrary path.
This allows us to have actionmaps that mimic a directory structure.
Some examples of actionmaps that can now be built is:

In those examples the actionsmaps are defined like so:
ActionMap checkout/basket <<EOA
    do basket stuffs;
ActionMap checkout/shipping_address <<EOA
    do shipping address stuffs;
ActionMap checkout/billing_address <<EOA
    do billing address stuffs;
ActionMap checkout/payment <<EOA
    do payment stuffs;

Notice that there is no actionmap defined as 'checkout'. Previously, this was required and it would handle
the 4 actionmaps we just defined.

justino commented Jan 26, 2012

This patch needs some work, there are things missing from this version of the patch that are needed throughout.
I'll post another patch when i isolate the generic version from my "custom" version

justino closed this Jan 26, 2012


racke commented Oct 4, 2013

Maybe we can do another try on this new feature? It looks like a good idea to me.


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment