You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by Mohammed AlMarzouq <up...@twothirty.am> on 2011/06/06 19:30:28 UTC

workaround for url rewrite formatting

Hi,

I'm on v1.0.2 of couchdb and having problems formatting rewrite queries correctly. I keep getting %22 (double quotes) around numeric tokens extracted from the url.

I saw this fix which will be included in v1.1 and allows for the proper formatting of extracted tokens https://issues.apache.org/jira/browse/COUCHDB-1074

But since I can't use the development branch, can anyone recommend a workaround?

Thanks :)

Mohammad AlMarzouq

Re: workaround for url rewrite formatting

Posted by Paul Davis <pa...@gmail.com>.
Also, the commit message from the backport:

> COUCHDB-1074 - fix variable substitution in rewriter
>
> - key= ":key", startkey=[":a", ":b"]
> - variable substitution via query arguments
> - variable substituin via reversed path matching variables
>
> The variable substition is now a lot easier than the old one. Variables
> are decoded from the query if they are json, and we recode them only at
> the end.
>
> (Patch by Benoît Chesneau)

I can't speak to anything other than that in terms of usage. The
commit to the 1.1.x branch was r1128189 if anyone wants to update the
docs at [1].

[1] http://wiki.apache.org/couchdb/Rewriting_urls

On Tue, Jun 7, 2011 at 5:51 PM, Paul Davis <pa...@gmail.com> wrote:
> The URL referenced earlier [1] is from CouchBase and is not at all the
> official release notes for Apache CouchDB. You'll want to contact them
> directly if they have an error or if perhaps they have downstream
> patches relating to the rewriter.
>
> [1] http://docs.couchbase.org/couchdb-release-1.1/index.html
>
> On Tue, Jun 7, 2011 at 4:21 PM, Caolan McMahon <ca...@gmail.com> wrote:
>>> like I said I didn't write that :) You can do that in couchapp-ng though.
>>
>> Damn, looks like I wasted my time then. There should be an
>> announcement and an update to the release notes so others don't do the
>> same.
>>
>> Caolan
>>
>

Re: workaround for url rewrite formatting

Posted by Paul Davis <pa...@gmail.com>.
The URL referenced earlier [1] is from CouchBase and is not at all the
official release notes for Apache CouchDB. You'll want to contact them
directly if they have an error or if perhaps they have downstream
patches relating to the rewriter.

[1] http://docs.couchbase.org/couchdb-release-1.1/index.html

On Tue, Jun 7, 2011 at 4:21 PM, Caolan McMahon <ca...@gmail.com> wrote:
>> like I said I didn't write that :) You can do that in couchapp-ng though.
>
> Damn, looks like I wasted my time then. There should be an
> announcement and an update to the release notes so others don't do the
> same.
>
> Caolan
>

Re: workaround for url rewrite formatting

Posted by Caolan McMahon <ca...@gmail.com>.
> like I said I didn't write that :) You can do that in couchapp-ng though.

Damn, looks like I wasted my time then. There should be an
announcement and an update to the release notes so others don't do the
same.

Caolan

Re: workaround for url rewrite formatting

Posted by Benoit Chesneau <bc...@gmail.com>.
On Tue, Jun 7, 2011 at 10:11 PM, Caolan McMahon
<ca...@gmail.com> wrote:
>> {
>>    "from":"/<year>-<month>-<day>",
>>    "to": "_show/calendar/<year>:<month>:<day>"
>> }
>
> I just tested out exactly this rewrite in CouchDB 1.1.0 and it fails
> to match the URL "/2011-06-07". I've implemented a client-side version
> of this rewriter in Kanso (http://kansojs.org) that works, but there's
> not much point me pushing it until it also works on CouchDB.
>
> Has anybody got this working?
>
> Caolan
>

like I said I didn't write that :) You can do that in couchapp-ng though.

https://github.com/benoitc/couchapp-ng

- benoît

Re: workaround for url rewrite formatting

Posted by Caolan McMahon <ca...@gmail.com>.
> {
>    "from":"/<year>-<month>-<day>",
>    "to": "_show/calendar/<year>:<month>:<day>"
> }

I just tested out exactly this rewrite in CouchDB 1.1.0 and it fails
to match the URL "/2011-06-07". I've implemented a client-side version
of this rewriter in Kanso (http://kansojs.org) that works, but there's
not much point me pushing it until it also works on CouchDB.

Has anybody got this working?

Caolan

Re: workaround for url rewrite formatting

Posted by Benoit Chesneau <bc...@gmail.com>.
On Tue, Jun 7, 2011 at 2:53 PM, Oliver Boermans <bo...@gmail.com> wrote:
> On 07/06/2011, at 5:27 AM, Gary Thomas <7z...@gmail.com> wrote:
>
>> Thanks, is there a description somewhere of what  "More flexible URL rewriter" means in the release notes?
>
> There is a brief description near the bottom of this page
> http://docs.couchbase.org/couchdb-release-1.1/index.html
>
> More flexible URL rewriter
>
> Prior to CouchDB 1.1 the rewriter could only collect variable information delimited by forward slashes. URL's like /:year/:month/:day was possible, but not /:year-:month-:day. The improved URL Rewriter in CouchDB 1.1 now supports variables within a path, so the earlier URL is now possible written as /<year>-<month>-<day>. The same format is used with the "to" and "from" portions of a rewrite rule, so the above example would look something like this (if documents were delimited with colons rather than dashes):
>
> {
>    "from":"/<year>-<month>-<day>",
>    "to": "_show/calendar/<year>:<month>:<day>"
> }
>
>

I don't remember to have written that.

- benoît

Re: workaround for url rewrite formatting

Posted by Oliver Boermans <bo...@gmail.com>.
On 07/06/2011, at 5:27 AM, Gary Thomas <7z...@gmail.com> wrote:

> Thanks, is there a description somewhere of what  "More flexible URL rewriter" means in the release notes?

There is a brief description near the bottom of this page
http://docs.couchbase.org/couchdb-release-1.1/index.html

More flexible URL rewriter

Prior to CouchDB 1.1 the rewriter could only collect variable information delimited by forward slashes. URL's like /:year/:month/:day was possible, but not /:year-:month-:day. The improved URL Rewriter in CouchDB 1.1 now supports variables within a path, so the earlier URL is now possible written as /<year>-<month>-<day>. The same format is used with the "to" and "from" portions of a rewrite rule, so the above example would look something like this (if documents were delimited with colons rather than dashes):

{
    "from":"/<year>-<month>-<day>",
    "to": "_show/calendar/<year>:<month>:<day>"
}


Re: workaround for url rewrite formatting

Posted by Gary Thomas <7z...@gmail.com>.
Thanks, is there a description somewhere of what  "More flexible URL 
rewriter" means in the release notes?

Thanks

On 6/6/11 10:50 AM, Robert Newson wrote:
> It's your lucky day. CouchDB 1.1.0 has been released.
>
> http://couchdb.apache.org/downloads.html
>
> On 6 June 2011 18:30, Mohammed AlMarzouq<up...@twothirty.am>  wrote:
>> Hi,
>>
>> I'm on v1.0.2 of couchdb and having problems formatting rewrite queries correctly. I keep getting %22 (double quotes) around numeric tokens extracted from the url.
>>
>> I saw this fix which will be included in v1.1 and allows for the proper formatting of extracted tokens https://issues.apache.org/jira/browse/COUCHDB-1074
>>
>> But since I can't use the development branch, can anyone recommend a workaround?
>>
>> Thanks :)
>>
>> Mohammad AlMarzouq


Re: workaround for url rewrite formatting

Posted by Robert Newson <ro...@gmail.com>.
It's your lucky day. CouchDB 1.1.0 has been released.

http://couchdb.apache.org/downloads.html

On 6 June 2011 18:30, Mohammed AlMarzouq <up...@twothirty.am> wrote:
> Hi,
>
> I'm on v1.0.2 of couchdb and having problems formatting rewrite queries correctly. I keep getting %22 (double quotes) around numeric tokens extracted from the url.
>
> I saw this fix which will be included in v1.1 and allows for the proper formatting of extracted tokens https://issues.apache.org/jira/browse/COUCHDB-1074
>
> But since I can't use the development branch, can anyone recommend a workaround?
>
> Thanks :)
>
> Mohammad AlMarzouq