SES Optional Variables in 2.6 RC2

Hi All,
After updating to rc2, a few of my ses urls will not work as before.
I'm sure it has to do with the new optional variables feature in rc2.

I have one custom route in the routes.cfm file:
<cfset addCourse(pattern=":id-numeric", handler="articles",
action="articledesc")>

This allowed me to have urls like below without actually creating a
'real' handler (aboutus.cfc, resources.cfc):
http://localhost:81/aboutus/1388/contact-us
http://localhost:81/resources/1438/privacy-policy

With RC2, I get the following error:
Framework.EventHandlerNotRegisteredException.
The event handler: aboutus.1388 is not valid registered event.

I'm not sure how to get this same functionality to work in rc2. Do I
have to now in rc2 add a custom route for each 'virtual' handler?

Thanks!
Marcus Cox

marcus

can you post your custom routes here and some more sample urls, so we can digest what changed. One of the things optional variables do, is create permutations for you, so that would not affect this. What could, is that a fix was found, where the route was not being matched from the starting placeholders in a url snippet, it was looking anywhere. This was fixed, in the sense, that the route you define has to be how the url snippet starts. Anyways, please post your routes and some more sample urls.

Luis,

Here is what's in my routes.cfm file:

<!--- CUSTOM COURSES GO HERE (they will be checked in order) --->
<cfset addCourse(pattern="events/:id-numeric", handler="events",
action="eventdetails")>
<cfset addCourse(pattern="events/guestpassregistration/:id-numeric",
handler="events", action="guestpassregistration")>
<cfset addCourse(pattern="events/volunteerregistration/:id-numeric",
handler="events", action="volunteerregistration")>
<cfset addCourse(pattern="events/busgroupregistration/:id-numeric",
handler="events", action="busgroupregistration")>
<cfset addCourse(pattern="events/churchparticipation/:id-numeric",
handler="events", action="churchparticipation")>
<cfset addCourse(pattern=":id-numeric", handler="articles",
action="articledesc")>

<!--- STANDARD COLDBOX COURSES, DO NOT MODIFY UNLESS YOU DON'T LIKE
THEM --->
<cfset addCourse(":handler/:action/:id")>
<cfset addCourse(":handler/:action")>
<cfset addCourse(":handler")>

The last entry in my Custom Courses allowed me to use urls like this:
http://localhost/aboutus/1388/contact-us
http://localhost/resources/1438/privacy-policy
http://localhost/aboutus/1386/about-us
Basically any url with a number that doesn't match any of the previous
custom courses would actually be handled by the last custom course and
go to articledesc function in the articles.cfc handler.

This allowed me to create any url combination I liked and it would
still be handled correctly. For instance:
http://localhost/not_a_real_handler/contact-us/1388
http://localhost/neither_is_this/blah/blah/1388
http://localhost/foo/bar/1388/foo2/bar2/

All these would still work and be shown the contact us page in this
instance.

I am trying to migrate an existing non-ses website into cb and trying
to cut down on creating unnecessary handlers while giving the
appearance of ses friendly urls.

Thanks!

Exactly, this is a problem Marcus, because the interceptor was loosley looking for routes ANYWHERE in the path, when it should only look from start to finish. Basically, the bug was how you got that to work. It should have not worked. In this case, I would suggest using the onInvalidEvent setting, so when invalid urls are placed, you can still control where they go. You can simply create this setting in the coldbox.xml and then point it to the event you want to redirect when an invalid event happens. You can then do any validation or forwarding if needed.

However, I am now thinking that this could probably be a good setting. Maybe something like “looseMatching” and have it default to false. Then if you need looseMatching, you turn it on.

You know what Marcus. I will be adding this setting in and then you can set an ses property of “LooseMatching” = true and you will have the same behavior. I can see the benefit of loose matching.

Awesome..Thanks Luis!
Loose matching would be great and I look forward to the update..
For now, I will continue with RC1.

Thanks again for the help and providing such a great framework!
Marcus Cox

Oh and feel free to update this post's title to something more useful
as it has nothing to do with the
SES optional variables as I had originally thought.

Thanks!