Return-Path: Delivered-To: apmail-incubator-abdera-dev-archive@locus.apache.org Received: (qmail 29425 invoked from network); 16 May 2008 17:55:11 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 16 May 2008 17:55:11 -0000 Received: (qmail 52678 invoked by uid 500); 16 May 2008 17:55:13 -0000 Delivered-To: apmail-incubator-abdera-dev-archive@incubator.apache.org Received: (qmail 52652 invoked by uid 500); 16 May 2008 17:55:13 -0000 Mailing-List: contact abdera-dev-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: abdera-dev@incubator.apache.org Delivered-To: mailing list abdera-dev@incubator.apache.org Received: (qmail 52641 invoked by uid 99); 16 May 2008 17:55:13 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 16 May 2008 10:55:13 -0700 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of jasnell@gmail.com designates 209.85.132.242 as permitted sender) Received: from [209.85.132.242] (HELO an-out-0708.google.com) (209.85.132.242) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 16 May 2008 17:54:25 +0000 Received: by an-out-0708.google.com with SMTP id b38so217650ana.83 for ; Fri, 16 May 2008 10:54:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:user-agent:mime-version:to:subject:references:in-reply-to:x-enigmail-version:content-type:content-transfer-encoding; bh=C9G/cNLzLL0QGDFzbc3UB8AqvmquSGQEVj7seEm4pf4=; b=qdC2ws3mnGNoTPj42RJunkaxD8madcP6uN6H76R/zmMt943tkJGmAWQfiFw3CrVgymLiK0V7LXMuOHG9zJpSEfpOBTf3PyEdkwt3Q5hnlahcsVdfV1X3IkICzaKw5GIbXkjgwl9vnC+5DMCtLKCEqrJl07z7Oo/AMCpkOZgB+g8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject:references:in-reply-to:x-enigmail-version:content-type:content-transfer-encoding; b=CXY/YnHaD0dipkckSwdKdJGyjupaPwmPdZIDpIgpsy4tISW3/O0ICCCrTVr1Mv+7Ps4uVpPZZJD6Qf25KVO8XC/LmP8cmX4yOAJfakiT8fWgOUYe2P5gkx18xE1G3Ype6ntIOVnItxbackBim7lqdx1FZkcezv3vkpRX4kdlUYk= Received: by 10.100.165.13 with SMTP id n13mr5050262ane.76.1210960479699; Fri, 16 May 2008 10:54:39 -0700 (PDT) Received: from ?192.168.2.2? ( [98.224.93.96]) by mx.google.com with ESMTPS id c37sm8896179ana.11.2008.05.16.10.54.37 (version=TLSv1/SSLv3 cipher=RC4-MD5); Fri, 16 May 2008 10:54:38 -0700 (PDT) Message-ID: <482DCA5B.4010009@gmail.com> Date: Fri, 16 May 2008 10:54:35 -0700 From: James M Snell User-Agent: Thunderbird 2.0.0.14 (X11/20080505) MIME-Version: 1.0 To: abdera-dev@incubator.apache.org Subject: Re: urlFor in RouteManager does not let you null out vars References: <482C5216.4030809@gmail.com> In-Reply-To: X-Enigmail-Version: 0.95.6 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org Dave, I agree. Implicit variable substitution in problematic at best and makes the code more complicated and error prone. - James David Primmer wrote: > I just chatted with Ben Bangert, who ported Routes form Ruby to Rails > and he says that urlFor in those libs just works like a plain ol' > function and ignores the current request. When using a named route, > you must 'fill in the blanks' or else it doesn't return anything. > There is no magical pulling request variables in during expansion. > This is a pretty easily understood behavior and I'd recommend we > change it before it's too late. Once people start using routes with > the implicit token substitution, their code will break if we want to > make it explicit. > > Is this what James was saying we need to fix? > > davep > > On Fri, May 16, 2008 at 5:20 AM, David Calavera > wrote: >> this patch solves the query params bug but I continue thinking of the best >> behavior for the "urlFor" method: >> >> https://issues.apache.org/jira/secure/ManageAttachments.jspa?id=12396195 >> >> On Fri, May 16, 2008 at 10:41 AM, David Calavera >> wrote: >> >>> David, what abdera version are you using? can you include one of your test >>> cases? I'm trying to fix it but I don't have the same results. >>> >>> >>> On Fri, May 16, 2008 at 12:12 AM, David Primmer >>> wrote: >>> >>>> I just tested another use case, for the situation where I'm sending in >>>> a map with a nulled out param 'id=null' and in this case, I have send >>>> a request with query params '/feed/1?format=atom' and in this case, >>>> when it builds the link, it actually adds '?id=' onto the end of the >>>> url that is created so '/feed/?id='. So this seems to get complicated >>>> if there are query params already in the request context. >>>> >>>> davep >>>> >>>> On Thu, May 15, 2008 at 2:10 PM, David Primmer >>>> wrote: >>>>> I was thinking that if you passed in null, the urlFor would not >>>>> replace any of your tokens. But on the other hand, this behavior lets >>>>> you get a url by just sending in one arg: the route name. >>>>> >>>>> I'm not sure off the top of my head how the Ruby and Python Routes >>>>> libs handle this. It is hard to know what users would expect but at a >>>>> minimum it should be in a code comment. As it is, if I have two tokens >>>>> in my route and I only one one of them to be replaced with the request >>>>> var, i can get this by sending in a map with only one of the params >>>>> set to null for the one i don't want and the other one will magically >>>>> get resolved. Seems a little to implicit to me. >>>>> >>>>> davep >>>>> >>>>> On Thu, May 15, 2008 at 2:02 PM, David Calavera >>>>> wrote: >>>>>> Hi David, what do you think could be the expected behavior? >>>>>> >>>>>> On Thu, May 15, 2008 at 5:09 PM, James M Snell >>>> wrote: >>>>>>> Ok, we need to fix that. Want to open a jira issue? >>>>>>> >>>>>>> - James >>>>>>> >>>>>>> >>>>>>> David Primmer wrote: >>>>>>> >>>>>>>> I need to correct myself here. After investigating the code more, I >>>>>>>> was able to get the result I wanted by sending in a map with id=null >>>>>>>> as params instead of sending in a null param arg. The code only pulls >>>>>>>> in values from the request if they're not explicitly included in the >>>>>>>> params map in urlFor. I still don't know if this is the desired >>>>>>>> behavior. It's certainly not what I expected. >>>>>>>> >>>>>>>> davep >>>>>>>> >>>>>>>> On Wed, May 14, 2008 at 11:21 AM, David Primmer < >>>> david.primmer@gmail.com> >>>>>>>> wrote: >>>>>>>> >>>>>>>>> I'm trying to implement getHref in an adapter, which returns the url >>>>>>>>> for the collection. I'm also using RouteManager and it's urlfor >>>>>>>>> >>>>>>>>> for (String var : route.getVariables()) { >>>>>>>>> Object value = context.getTarget().getParameter(var); >>>>>>>>> if (!map.containsKey(var) && value != null) { >>>>>>>>> map.put(var, value); >>>>>>>>> } >>>>>>>>> } >>>>>>>>> >>>>>>>>> say my route is /feed/:id >>>>>>>>> and my request is /feed/1 >>>>>>>>> >>>>>>>>> if i'm doing urlFor("myroute", null), hoping that it produces /feed/ >>>>>>>>> as a url, but instead, the code above pulls the id out of the >>>> request >>>>>>>>> context and fills in those params, giving me a url of /feed/1. I >>>> don't >>>>>>>>> understand why it would do this and it limits the use of urlFor for >>>>>>>>> generating collection urls. >>>>>>>>> >>>>>>>>> davep >>>>>>>>> >>>>>>>>> >>>>>> >>>>>> -- >>>>>> David Calavera >>>>>> http://www.thinkincode.net >>>>>> >>> >>> >>> -- >>> David Calavera >>> http://www.thinkincode.net >>> >> >> >> -- >> David Calavera >> http://www.thinkincode.net >> >