Routing too greedy?

View: New views
6 Messages — Rating Filter:   Alert me  

Routing too greedy?

by chrisortman :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


I am wading through the routing code and slowing starting to make
sense of it.

IMHO this test should pass:

                [Test]
                public void
ShouldNotUseARouteUrlIfAskingForActionOnSameControllerAndArea()
                {
                        UrlInfo urlInfo = new
UrlInfo("xarea","ycontroller","zaction","/",".castle");
                        IRoutingEngine routingEngine = new StubRoutingEngine();
                        routingEngine.Add(new PatternRoute("myroute","/somepath/
<action>").DefaultForArea().Is("Aarea").DefaultForController().Is("Bcontroller"));

                        urlBuilder.RoutingEngine = routingEngine;
                        ListDictionary parameters = new ListDictionary();
                        parameters["action"] = "myaction";
                        Assert.AreEqual("/xarea/ycontroller/
myaction.castle",urlBuilder.BuildUrl(urlInfo,parameters,null));
                }

Based on what TryCreateUrlUsingRegisteredRoutes is doing it looks like
we are trying to guess about when we should use a route url which
seems very wrong to me....


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Castle Project Development List" group.
To post to this group, send email to castle-project-devel@...
To unsubscribe from this group, send email to castle-project-devel-unsubscribe@...
For more options, visit this group at http://groups.google.com/group/castle-project-devel?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: Routing too greedy?

by Hamilton Verissimo :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


The TryCreateUrlUsingRegisteredRoutes, as the name implies, try to
find a route that is able to create that url given the current
parameters. Having said that, I'm ok with changing it to use routing
only in a specific case. That would break lots of cases, though. For
instance, wizard's family of redirects (RedirectToNext,
RedirectToStep...), and breaking those might break the whole app. If
you have mapped * to ISAPI and there's no mapping to .castle, if the
urlbuilder produce a .castle url, you have a dead end...

Another thing that I considered was to having the routing, when
enabled, supporting a few standard route(s) by default, that could be
overwritten by the user. That would allow controllers and wizards
always falling back to "standard" route or "wizard" route...


On Mon, Jul 21, 2008 at 1:02 PM, chriso <chrisortman@...> wrote:

>
> I am wading through the routing code and slowing starting to make
> sense of it.
>
> IMHO this test should pass:
>
>                [Test]
>                public void
> ShouldNotUseARouteUrlIfAskingForActionOnSameControllerAndArea()
>                {
>                        UrlInfo urlInfo = new
> UrlInfo("xarea","ycontroller","zaction","/",".castle");
>                        IRoutingEngine routingEngine = new StubRoutingEngine();
>                        routingEngine.Add(new PatternRoute("myroute","/somepath/
> <action>").DefaultForArea().Is("Aarea").DefaultForController().Is("Bcontroller"));
>
>                        urlBuilder.RoutingEngine = routingEngine;
>                        ListDictionary parameters = new ListDictionary();
>                        parameters["action"] = "myaction";
>                        Assert.AreEqual("/xarea/ycontroller/
> myaction.castle",urlBuilder.BuildUrl(urlInfo,parameters,null));
>                }
>
> Based on what TryCreateUrlUsingRegisteredRoutes is doing it looks like
> we are trying to guess about when we should use a route url which
> seems very wrong to me....
>
>
> >
>



--
Cheers,
hamilton verissimo
hammett@...
http://www.castlestronghold.com/

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Castle Project Development List" group.
To post to this group, send email to castle-project-devel@...
To unsubscribe from this group, send email to castle-project-devel-unsubscribe@...
For more options, visit this group at http://groups.google.com/group/castle-project-devel?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: Routing too greedy?

by chrisortman :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


I also worry about breaking a bunch of places, but I am currently
broken all over the place because my urls all get mapped to the wrong
route.

Even having a default /<area>/<controller>/<action> route doesn't get
mapped just the route with static/<action> picks it up.

I have thought about changing UrlHelper to handle defaulting
controller / area but that seems like what UrlBuilder does already
today and would probably cause some other problems (not to mentions
mixing up responsibilities)

On Jul 21, 11:19 am, "Hamilton Verissimo"
<hamm...@...> wrote:

> The TryCreateUrlUsingRegisteredRoutes, as the name implies, try to
> find a route that is able to create that url given the current
> parameters. Having said that, I'm ok with changing it to use routing
> only in a specific case. That would break lots of cases, though. For
> instance, wizard's family of redirects (RedirectToNext,
> RedirectToStep...), and breaking those might break the whole app. If
> you have mapped * to ISAPI and there's no mapping to .castle, if the
> urlbuilder produce a .castle url, you have a dead end...
>
> Another thing that I considered was to having the routing, when
> enabled, supporting a few standard route(s) by default, that could be
> overwritten by the user. That would allow controllers and wizards
> always falling back to "standard" route or "wizard" route...
>
>
>
> On Mon, Jul 21, 2008 at 1:02 PM, chriso <chrisort...@...> wrote:
>
> > I am wading through the routing code and slowing starting to make
> > sense of it.
>
> > IMHO this test should pass:
>
> >                [Test]
> >                public void
> > ShouldNotUseARouteUrlIfAskingForActionOnSameControllerAndArea()
> >                {
> >                        UrlInfo urlInfo = new
> > UrlInfo("xarea","ycontroller","zaction","/",".castle");
> >                        IRoutingEngine routingEngine = new StubRoutingEngine();
> >                        routingEngine.Add(new PatternRoute("myroute","/somepath/
> > <action>").DefaultForArea().Is("Aarea").DefaultForController().Is("Bcontroller"));
>
> >                        urlBuilder.RoutingEngine = routingEngine;
> >                        ListDictionary parameters = new ListDictionary();
> >                        parameters["action"] = "myaction";
> >                        Assert.AreEqual("/xarea/ycontroller/
> > myaction.castle",urlBuilder.BuildUrl(urlInfo,parameters,null));
> >                }
>
> > Based on what TryCreateUrlUsingRegisteredRoutes is doing it looks like
> > we are trying to guess about when we should use a route url which
> > seems very wrong to me....
>
> --
> Cheers,
> hamilton verissimo
> hamm...@...://www.castlestronghold.com/
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Castle Project Development List" group.
To post to this group, send email to castle-project-devel@...
To unsubscribe from this group, send email to castle-project-devel-unsubscribe@...
For more options, visit this group at http://groups.google.com/group/castle-project-devel?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: Routing too greedy?

by Hamilton Verissimo :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


And what's your suggestion?

On Mon, Jul 21, 2008 at 3:40 PM, chriso <chrisortman@...> wrote:

>
> I also worry about breaking a bunch of places, but I am currently
> broken all over the place because my urls all get mapped to the wrong
> route.
>
> Even having a default /<area>/<controller>/<action> route doesn't get
> mapped just the route with static/<action> picks it up.
>
> I have thought about changing UrlHelper to handle defaulting
> controller / area but that seems like what UrlBuilder does already
> today and would probably cause some other problems (not to mentions
> mixing up responsibilities)
>
> On Jul 21, 11:19 am, "Hamilton Verissimo"
> <hamm...@...> wrote:
>> The TryCreateUrlUsingRegisteredRoutes, as the name implies, try to
>> find a route that is able to create that url given the current
>> parameters. Having said that, I'm ok with changing it to use routing
>> only in a specific case. That would break lots of cases, though. For
>> instance, wizard's family of redirects (RedirectToNext,
>> RedirectToStep...), and breaking those might break the whole app. If
>> you have mapped * to ISAPI and there's no mapping to .castle, if the
>> urlbuilder produce a .castle url, you have a dead end...
>>
>> Another thing that I considered was to having the routing, when
>> enabled, supporting a few standard route(s) by default, that could be
>> overwritten by the user. That would allow controllers and wizards
>> always falling back to "standard" route or "wizard" route...
>>
>>
>>
>> On Mon, Jul 21, 2008 at 1:02 PM, chriso <chrisort...@...> wrote:
>>
>> > I am wading through the routing code and slowing starting to make
>> > sense of it.
>>
>> > IMHO this test should pass:
>>
>> >                [Test]
>> >                public void
>> > ShouldNotUseARouteUrlIfAskingForActionOnSameControllerAndArea()
>> >                {
>> >                        UrlInfo urlInfo = new
>> > UrlInfo("xarea","ycontroller","zaction","/",".castle");
>> >                        IRoutingEngine routingEngine = new StubRoutingEngine();
>> >                        routingEngine.Add(new PatternRoute("myroute","/somepath/
>> > <action>").DefaultForArea().Is("Aarea").DefaultForController().Is("Bcontroller"));
>>
>> >                        urlBuilder.RoutingEngine = routingEngine;
>> >                        ListDictionary parameters = new ListDictionary();
>> >                        parameters["action"] = "myaction";
>> >                        Assert.AreEqual("/xarea/ycontroller/
>> > myaction.castle",urlBuilder.BuildUrl(urlInfo,parameters,null));
>> >                }
>>
>> > Based on what TryCreateUrlUsingRegisteredRoutes is doing it looks like
>> > we are trying to guess about when we should use a route url which
>> > seems very wrong to me....
>>
>> --
>> Cheers,
>> hamilton verissimo
>> hamm...@...://www.castlestronghold.com/
> >
>



--
Cheers,
hamilton verissimo
hammett@...
http://www.castlestronghold.com/

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Castle Project Development List" group.
To post to this group, send email to castle-project-devel@...
To unsubscribe from this group, send email to castle-project-devel-unsubscribe@...
For more options, visit this group at http://groups.google.com/group/castle-project-devel?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: Routing too greedy?

by chrisortman :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


This is what I'm doing for the time being to make my stuff work....


From 64c040c95b44a21fede5dadc74ba5fcf686b01e3 Mon Sep 17 00:00:00 2001
From: Chris Ortman <chrisortman@...>
Date: Mon, 21 Jul 2008 15:24:33 -0500
Subject: [PATCH] Change UrlHelper to default controller and area if
not given

---
 .../Castle.MonoRail.Framework/Helpers/UrlHelper.cs |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)
 mode change 100644 => 100755 MonoRail/Castle.MonoRail.Framework/
Helpers/UrlHelper.cs

diff --git a/MonoRail/Castle.MonoRail.Framework/Helpers/UrlHelper.cs b/
MonoRail/Castle.MonoRail.Framework/Helpers/UrlHelper.cs
old mode 100644
new mode 100755
index d77966c..47ed6b3
--- a/MonoRail/Castle.MonoRail.Framework/Helpers/UrlHelper.cs
+++ b/MonoRail/Castle.MonoRail.Framework/Helpers/UrlHelper.cs
@@ -114,6 +114,16 @@ namespace Castle.MonoRail.Framework.Helpers
  {
  SetEncodeDefault(parameters);

+      if(!parameters.Contains("area"))
+      {
+        parameters["area"] = ControllerContext.AreaName;
+      }
+
+      if(!parameters.Contains("controller"))
+      {
+        parameters["controller"] = ControllerContext.Name;
+      }
+
  UrlBuilderParameters urlParams =
UrlBuilderParameters.From(parameters).
  SetRouteMatch(ControllerContext.RouteMatch);

--
1.5.5.1



On Jul 21, 2:01 pm, "Hamilton Verissimo"
<hamm...@...> wrote:

> And what's your suggestion?
>
>
>
> On Mon, Jul 21, 2008 at 3:40 PM, chriso <chrisort...@...> wrote:
>
> > I also worry about breaking a bunch of places, but I am currently
> > broken all over the place because my urls all get mapped to the wrong
> > route.
>
> > Even having a default /<area>/<controller>/<action> route doesn't get
> > mapped just the route with static/<action> picks it up.
>
> > I have thought about changing UrlHelper to handle defaulting
> > controller / area but that seems like what UrlBuilder does already
> > today and would probably cause some other problems (not to mentions
> > mixing up responsibilities)
>
> > On Jul 21, 11:19 am, "Hamilton Verissimo"
> > <hamm...@...> wrote:
> >> The TryCreateUrlUsingRegisteredRoutes, as the name implies, try to
> >> find a route that is able to create that url given the current
> >> parameters. Having said that, I'm ok with changing it to use routing
> >> only in a specific case. That would break lots of cases, though. For
> >> instance, wizard's family of redirects (RedirectToNext,
> >> RedirectToStep...), and breaking those might break the whole app. If
> >> you have mapped * to ISAPI and there's no mapping to .castle, if the
> >> urlbuilder produce a .castle url, you have a dead end...
>
> >> Another thing that I considered was to having the routing, when
> >> enabled, supporting a few standard route(s) by default, that could be
> >> overwritten by the user. That would allow controllers and wizards
> >> always falling back to "standard" route or "wizard" route...
>
> >> On Mon, Jul 21, 2008 at 1:02 PM, chriso <chrisort...@...> wrote:
>
> >> > I am wading through the routing code and slowing starting to make
> >> > sense of it.
>
> >> > IMHO this test should pass:
>
> >> >                [Test]
> >> >                public void
> >> > ShouldNotUseARouteUrlIfAskingForActionOnSameControllerAndArea()
> >> >                {
> >> >                        UrlInfo urlInfo = new
> >> > UrlInfo("xarea","ycontroller","zaction","/",".castle");
> >> >                        IRoutingEngine routingEngine = new StubRoutingEngine();
> >> >                        routingEngine.Add(new PatternRoute("myroute","/somepath/
> >> > <action>").DefaultForArea().Is("Aarea").DefaultForController().Is("Bcontroller"));
>
> >> >                        urlBuilder.RoutingEngine = routingEngine;
> >> >                        ListDictionary parameters = new ListDictionary();
> >> >                        parameters["action"] = "myaction";
> >> >                        Assert.AreEqual("/xarea/ycontroller/
> >> > myaction.castle",urlBuilder.BuildUrl(urlInfo,parameters,null));
> >> >                }
>
> >> > Based on what TryCreateUrlUsingRegisteredRoutes is doing it looks like
> >> > we are trying to guess about when we should use a route url which
> >> > seems very wrong to me....
>
> >> --
> >> Cheers,
> >> hamilton verissimo
> >> hamm...@...://www.castlestronghold.com/
>
> --
> Cheers,
> hamilton verissimo
> hamm...@...://www.castlestronghold.com/
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Castle Project Development List" group.
To post to this group, send email to castle-project-devel@...
To unsubscribe from this group, send email to castle-project-devel-unsubscribe@...
For more options, visit this group at http://groups.google.com/group/castle-project-devel?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: Routing too greedy?

by Hamilton Verissimo :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Gonna take a look at this today.

On Mon, Jul 21, 2008 at 5:25 PM, chriso <chrisortman@...> wrote:

>
> This is what I'm doing for the time being to make my stuff work....
>
>
> From 64c040c95b44a21fede5dadc74ba5fcf686b01e3 Mon Sep 17 00:00:00 2001
> From: Chris Ortman <chrisortman@...>
> Date: Mon, 21 Jul 2008 15:24:33 -0500
> Subject: [PATCH] Change UrlHelper to default controller and area if
> not given
>
> ---
>  .../Castle.MonoRail.Framework/Helpers/UrlHelper.cs |   10 ++++++++++
>  1 files changed, 10 insertions(+), 0 deletions(-)
>  mode change 100644 => 100755 MonoRail/Castle.MonoRail.Framework/
> Helpers/UrlHelper.cs
>
> diff --git a/MonoRail/Castle.MonoRail.Framework/Helpers/UrlHelper.cs b/
> MonoRail/Castle.MonoRail.Framework/Helpers/UrlHelper.cs
> old mode 100644
> new mode 100755
> index d77966c..47ed6b3
> --- a/MonoRail/Castle.MonoRail.Framework/Helpers/UrlHelper.cs
> +++ b/MonoRail/Castle.MonoRail.Framework/Helpers/UrlHelper.cs
> @@ -114,6 +114,16 @@ namespace Castle.MonoRail.Framework.Helpers
>                {
>                        SetEncodeDefault(parameters);
>
> +      if(!parameters.Contains("area"))
> +      {
> +        parameters["area"] = ControllerContext.AreaName;
> +      }
> +
> +      if(!parameters.Contains("controller"))
> +      {
> +        parameters["controller"] = ControllerContext.Name;
> +      }
> +
>                        UrlBuilderParameters urlParams =
> UrlBuilderParameters.From(parameters).
>                                SetRouteMatch(ControllerContext.RouteMatch);
>
> --
> 1.5.5.1
>
>
>
> On Jul 21, 2:01 pm, "Hamilton Verissimo"
> <hamm...@...> wrote:
>> And what's your suggestion?
>>
>>
>>
>> On Mon, Jul 21, 2008 at 3:40 PM, chriso <chrisort...@...> wrote:
>>
>> > I also worry about breaking a bunch of places, but I am currently
>> > broken all over the place because my urls all get mapped to the wrong
>> > route.
>>
>> > Even having a default /<area>/<controller>/<action> route doesn't get
>> > mapped just the route with static/<action> picks it up.
>>
>> > I have thought about changing UrlHelper to handle defaulting
>> > controller / area but that seems like what UrlBuilder does already
>> > today and would probably cause some other problems (not to mentions
>> > mixing up responsibilities)
>>
>> > On Jul 21, 11:19 am, "Hamilton Verissimo"
>> > <hamm...@...> wrote:
>> >> The TryCreateUrlUsingRegisteredRoutes, as the name implies, try to
>> >> find a route that is able to create that url given the current
>> >> parameters. Having said that, I'm ok with changing it to use routing
>> >> only in a specific case. That would break lots of cases, though. For
>> >> instance, wizard's family of redirects (RedirectToNext,
>> >> RedirectToStep...), and breaking those might break the whole app. If
>> >> you have mapped * to ISAPI and there's no mapping to .castle, if the
>> >> urlbuilder produce a .castle url, you have a dead end...
>>
>> >> Another thing that I considered was to having the routing, when
>> >> enabled, supporting a few standard route(s) by default, that could be
>> >> overwritten by the user. That would allow controllers and wizards
>> >> always falling back to "standard" route or "wizard" route...
>>
>> >> On Mon, Jul 21, 2008 at 1:02 PM, chriso <chrisort...@...> wrote:
>>
>> >> > I am wading through the routing code and slowing starting to make
>> >> > sense of it.
>>
>> >> > IMHO this test should pass:
>>
>> >> >                [Test]
>> >> >                public void
>> >> > ShouldNotUseARouteUrlIfAskingForActionOnSameControllerAndArea()
>> >> >                {
>> >> >                        UrlInfo urlInfo = new
>> >> > UrlInfo("xarea","ycontroller","zaction","/",".castle");
>> >> >                        IRoutingEngine routingEngine = new StubRoutingEngine();
>> >> >                        routingEngine.Add(new PatternRoute("myroute","/somepath/
>> >> > <action>").DefaultForArea().Is("Aarea").DefaultForController().Is("Bcontroller"));
>>
>> >> >                        urlBuilder.RoutingEngine = routingEngine;
>> >> >                        ListDictionary parameters = new ListDictionary();
>> >> >                        parameters["action"] = "myaction";
>> >> >                        Assert.AreEqual("/xarea/ycontroller/
>> >> > myaction.castle",urlBuilder.BuildUrl(urlInfo,parameters,null));
>> >> >                }
>>
>> >> > Based on what TryCreateUrlUsingRegisteredRoutes is doing it looks like
>> >> > we are trying to guess about when we should use a route url which
>> >> > seems very wrong to me....
>>
>> >> --
>> >> Cheers,
>> >> hamilton verissimo
>> >> hamm...@...://www.castlestronghold.com/
>>
>> --
>> Cheers,
>> hamilton verissimo
>> hamm...@...://www.castlestronghold.com/
> >
>



--
Cheers,
hamilton verissimo
hammett@...
http://www.castlestronghold.com/

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Castle Project Development List" group.
To post to this group, send email to castle-project-devel@...
To unsubscribe from this group, send email to castle-project-devel+unsubscribe@...
For more options, visit this group at http://groups.google.com/group/castle-project-devel?hl=en
-~----------~----~----~----~------~----~------~--~---

LightInTheBox - Buy quality products at wholesale price