You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by Chris Anderson <jc...@apache.org> on 2009/07/24 23:49:04 UTC

Re: switching between response content type in show? how to trigger html response inst of default xml

On Fri, Jul 24, 2009 at 12:19 PM, Nitin Borwankar<ni...@borwankar.com> wrote:
> Hi guys,
>
> so the list/show coding is going well - have the show running except for one
> blocker - I am using curl to invoke the show (alost identical to example) in
> couch app as follows - change dthe name from example to show_details in both
> the shows code and lib/template - id in this request is "aacosta"  - the
> template just returns a doc with the id in it
>
> curl $CDB/ptest2/_design/vt2/_show/show_details/aacosta
>
> <xml>
>  <node value="aacosta"/>
> </xml>
>
> two questions
>
> Why is the xml being sent back by default? What is the right param to pass
> in to trigger the html?
>
> show function is as follows
>
>
> function(doc, req) {
>  // !code lib/helpers/template.js
>  // !json lib.templates
>
>  respondWith(req, {
>    html : function() {
>      var html = template(lib.templates.show_details, doc);
>      return {body:html}
>    },
>    xml : function() {
>      return {
>        body : <xml><node value={doc._id}/></xml>
>      }
>    }
>  })
> };

Accept header handling in browsers is so bad I'm starting to wish I'd
never written that code. Kinda want to strip it out altogether.

I believe Rails just stopped supporting the Accept header for the same
reason. (They've moved to URLs like /path/object.xml due to lack of
browser support for Accept.)

To make a long story short, for the time being you can request:

$CDB/ptest2/_design/vt2/_show/show_details/aacosta?format=html

to override the format.

Chris

>
>
> html template is as follows
>
>
> <!DOCTYPE html>
> <html>
>  <head>
>    <title>Details</title>
>  </head>
>  <body>
>    <div id="docid">
>      <h1><% doc._id %></h1>
>    </div>
>  </body>
>
> </html>
>
>
> Thanks much,
>
>
>
>
> 37% of all statistics are made up on the spot
> -------------------------------------------------------------------------------------
> Nitin Borwankar
> nborwankar@gmail.com
>



-- 
Chris Anderson
http://jchrisa.net
http://couch.io

Re: switching between response content type in show? how to trigger html response inst of default xml

Posted by Chris Anderson <jc...@apache.org>.
Moved this thread over from user@. The context was me being unhappy
with how browsers handle Accept headers.

Adam convinced me that they can be good, but our API needs to change
so that users can define an ordering. Often many accept headers match
a request, in which case the server can pick what they want. This
would prevent browsers getting XML when they'd be better with HTML,
for instance.

On Sun, Jul 26, 2009 at 1:54 PM, Adam Jacob<ad...@opscode.com> wrote:
> On Sat, Jul 25, 2009 at 3:22 PM, Chris Anderson<jc...@apache.org> wrote:
>> You've got me thinking about how I can craft an API that makes all
>> this clearer for users, something like:
>>
>> respondWith("html", function() { ... }");
>>
>> respondWith("xml", function() { ... }");
>
> Totally - merb's provides api does something similar.
>
>> etc...
>>
>> The difference between this and the current API is that it gets an
>> ordering for users. So the first matching function would be run to
>> generate the response. If no functions matched, the first function
>> would also be run (or maybe there should an option for strict 406
>> errors.)
>
> Well, if the Accept header contains */*, then you get to pick.  If it
> doesn't, then it's a 406.
>

I'm starting to implement this right now. I think this will be a
clearer API. The first function that matches the client's Accept
header is chosen.

provides("html", function() {
   ... generate html ...
});

provides("atom", function() {
   ... generate atom ...
});

provides("csv", function() {
   ... generate csv ...
});

I also like the provides() name better... thanks Merb.

What do people think? I think it should replace respondsWith() as the
API for Accept header / format switching. If there are a bunch of
people needing respondsWith to stay the same, we can do a deprecation
notice for 0.10, but the old API is more or less wrong, so it should
be removed eventually.

Maybe there should be an option, in the case of no match - either the
first function is run, or a 406 is returned. Maybe the spec has more
to say here.

Of course, all the list functions that don't use respondsWith will not
be effected.

Chris

-- 
Chris Anderson
http://jchrisa.net
http://couch.io

Re: switching between response content type in show? how to trigger html response inst of default xml

Posted by Adam Jacob <ad...@opscode.com>.
On Sat, Jul 25, 2009 at 3:22 PM, Chris Anderson<jc...@apache.org> wrote:
> The implementation of respondsWith is built on top of mimeparse.js, my
> port of the Mimeparse library. Mimeparse doesn't have a public method
> to return all the acceptable matches, it only returns the "best". This
> can of course be arbitrary as the protocol allows matches to be equal.
>
> So I'll need to push a change back to the Mimeparse repo to add a
> public method to return the supported content-types sorted by quality
> score.

Yep - at which point it'll be pretty easy to get to the next phase
(where you allow people to override a sane default for picking which
content type to send back when they are equal.)  One other common
thing is that web browsers often have complicated accept headers, but
people usually set the accept header explicitly when using a REST
client.  An easy way to exploit that is to just set the default
preference to be returning html if any of it's content-type
derivatives are present.

> Thanks for pushing back Adam. I've even seen situations where browser
> accept headers were triggering xml feed generation instead of html.
> This isn't fun for new developers, especially as it's triggered by
> some browsers and not others.

Yeah - Accept header parsing is a huge pain to get right, but when you
do, it's glorious.

> You've got me thinking about how I can craft an API that makes all
> this clearer for users, something like:
>
> respondWith("html", function() { ... }");
>
> respondWith("xml", function() { ... }");

Totally - merb's provides api does something similar.

> etc...
>
> The difference between this and the current API is that it gets an
> ordering for users. So the first matching function would be run to
> generate the response. If no functions matched, the first function
> would also be run (or maybe there should an option for strict 406
> errors.)

Well, if the Accept header contains */*, then you get to pick.  If it
doesn't, then it's a 406.

> Still thinking about all this...

I'm holoway on IRC, and I'm almost always there, and I'm super
opinionated (obviously). :)  Feel free to ping me directly if I can be
of any assistance.

Adam

-- 
Opscode, Inc.
Adam Jacob, CTO
T: (206) 508-4759 E: adam@opscode.com

Re: switching between response content type in show? how to trigger html response inst of default xml

Posted by Chris Anderson <jc...@apache.org>.
On Fri, Jul 24, 2009 at 7:06 PM, Adam Jacob<ad...@opscode.com> wrote:
> On Fri, Jul 24, 2009 at 2:49 PM, Chris Anderson<jc...@apache.org> wrote:
>> Accept header handling in browsers is so bad I'm starting to wish I'd
>> never written that code. Kinda want to strip it out altogether.
>>
>> I believe Rails just stopped supporting the Accept header for the same
>> reason. (They've moved to URLs like /path/object.xml due to lack of
>> browser support for Accept.)
>
> That is insanity for web services - the Accept header works the way it
> does to support negotiation, which is why properly dealing with it is
> complicated.  Disabling honoring Accept headers is a one way ticket to
> crazy town, in my opinion - you can solve this problem by setting
> internal options for what content types *you* prefer to return to the
> client, all things being equal.  In Firefox:
>
> Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
>
> Means that the application server can choose the content type it
> thinks is most suitable at quality 0.9.  Because it lists text/xml
> first is irrelevant - any of the content types at that quality level
> will do.

The implementation of respondsWith is built on top of mimeparse.js, my
port of the Mimeparse library. Mimeparse doesn't have a public method
to return all the acceptable matches, it only returns the "best". This
can of course be arbitrary as the protocol allows matches to be equal.

So I'll need to push a change back to the Mimeparse repo to add a
public method to return the supported content-types sorted by quality
score.

Thanks for pushing back Adam. I've even seen situations where browser
accept headers were triggering xml feed generation instead of html.
This isn't fun for new developers, especially as it's triggered by
some browsers and not others.

You've got me thinking about how I can craft an API that makes all
this clearer for users, something like:

respondWith("html", function() { ... }");

respondWith("xml", function() { ... }");

etc...

The difference between this and the current API is that it gets an
ordering for users. So the first matching function would be run to
generate the response. If no functions matched, the first function
would also be run (or maybe there should an option for strict 406
errors.)

Still thinking about all this...


> Typically frameworks default to just sending the first thing
> they know how to serialize back, but you could just as easily set an
> internal preference.
>
> Let the author set the preferred content type if they have multiple
> choices - but honor the quality settings.  It's not crazy that a web
> service client would do:
>
> Accept: application/json,application/xml;q=0.9,text/yaml;q=0.8
>
> Catalyst, the perl web framework, does a great job with this, if you
> want something to use as a reference.
>
>> To make a long story short, for the time being you can request:
>>
>> $CDB/ptest2/_design/vt2/_show/show_details/aacosta?format=html
>>
>> to override the format.
>
> Or do 'curl -H "Accept: text/html"'
>
> Regards,
> Adam
>
> --
> Opscode, Inc.
> Adam Jacob, CTO
> T: (206) 508-4759 E: adam@opscode.com
>



-- 
Chris Anderson
http://jchrisa.net
http://couch.io

Re: switching between response content type in show? how to trigger html response inst of default xml

Posted by Adam Jacob <ad...@opscode.com>.
On Fri, Jul 24, 2009 at 2:49 PM, Chris Anderson<jc...@apache.org> wrote:
> Accept header handling in browsers is so bad I'm starting to wish I'd
> never written that code. Kinda want to strip it out altogether.
>
> I believe Rails just stopped supporting the Accept header for the same
> reason. (They've moved to URLs like /path/object.xml due to lack of
> browser support for Accept.)

That is insanity for web services - the Accept header works the way it
does to support negotiation, which is why properly dealing with it is
complicated.  Disabling honoring Accept headers is a one way ticket to
crazy town, in my opinion - you can solve this problem by setting
internal options for what content types *you* prefer to return to the
client, all things being equal.  In Firefox:

Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5

Means that the application server can choose the content type it
thinks is most suitable at quality 0.9.  Because it lists text/xml
first is irrelevant - any of the content types at that quality level
will do.  Typically frameworks default to just sending the first thing
they know how to serialize back, but you could just as easily set an
internal preference.

Let the author set the preferred content type if they have multiple
choices - but honor the quality settings.  It's not crazy that a web
service client would do:

Accept: application/json,application/xml;q=0.9,text/yaml;q=0.8

Catalyst, the perl web framework, does a great job with this, if you
want something to use as a reference.

> To make a long story short, for the time being you can request:
>
> $CDB/ptest2/_design/vt2/_show/show_details/aacosta?format=html
>
> to override the format.

Or do 'curl -H "Accept: text/html"'

Regards,
Adam

-- 
Opscode, Inc.
Adam Jacob, CTO
T: (206) 508-4759 E: adam@opscode.com

Re: switching between response content type in show? how to trigger html response inst of default xml

Posted by Nitin Borwankar <ni...@borwankar.com>.
Also if it matters I am using couchapp 0.2 - does that matter ?
When I last looked the default versions of jquery and jquery.couch.js were
1.2.6 and 0.8 in couchapp code eg templates/example.html
while the corresponding versions in couch 0.9 were 1.3.1 and of course 0.9
respectively.

Nitin


37% of all statistics are made up on the spot
-------------------------------------------------------------------------------------
Nitin Borwankar
nborwankar@gmail.com


On Fri, Jul 24, 2009 at 3:47 PM, Nitin Borwankar <ni...@borwankar.com>wrote:

> Hi Paul,
>
> No change - still the same error.
>
>
>  curl $CDB/ptest2/_design/vt2/_show/show_details/aacosta?format=html
>
> {"error":"noproc","reason":"{gen_server,call,\n
> [couch_query_servers,{ret_proc,<<\"javascript\">>,<0.19458.0>}]}"}
>
>
>
> Has anyone gotten list views to work on 0.9 ?
> I can't be the only one having this problem right?
> Or are most people not using couchapp ?
>
> Nitin
>
> 37% of all statistics are made up on the spot
>
> -------------------------------------------------------------------------------------
> Nitin Borwankar
> nborwankar@gmail.com
>
>
> On Fri, Jul 24, 2009 at 3:28 PM, Paul Davis <pa...@gmail.com>wrote:
>
>> Another shot in the dark, care to try quoting the html value so that
>> it's {"html": ...}
>>
>> On Fri, Jul 24, 2009 at 6:06 PM, Nitin Borwankar<ni...@borwankar.com>
>> wrote:
>> > Hi Chris,
>> >
>> > In CouchDBX 0.9 on Leopard adding ?format=html  hangs and then gives
>> foll
>> > error
>> >
>> > {"error":"noproc","reason":"{gen_server,call,\n
>> > [couch_query_servers,{ret_proc,<<\"javascript\">>,<0.16450.0>}]}"}
>> >
>> > Same behavior when you remove the xml: key/val pair and leave just the
>> html:
>> >
>> > I don't see anything in the code or the template that may be a problem
>> do
>> > you ?
>> >
>> > Nitin
>> >
>> > 37% of all statistics are made up on the spot
>> >
>> -------------------------------------------------------------------------------------
>> > Nitin Borwankar
>> > nborwankar@gmail.com
>> >
>> >
>> > On Fri, Jul 24, 2009 at 2:49 PM, Chris Anderson <jc...@apache.org>
>> wrote:
>> >
>> >> On Fri, Jul 24, 2009 at 12:19 PM, Nitin Borwankar<ni...@borwankar.com>
>> >> wrote:
>> >> > Hi guys,
>> >> >
>> >> > so the list/show coding is going well - have the show running except
>> for
>> >> one
>> >> > blocker - I am using curl to invoke the show (alost identical to
>> example)
>> >> in
>> >> > couch app as follows - change dthe name from example to show_details
>> in
>> >> both
>> >> > the shows code and lib/template - id in this request is "aacosta"  -
>> the
>> >> > template just returns a doc with the id in it
>> >> >
>> >> > curl $CDB/ptest2/_design/vt2/_show/show_details/aacosta
>> >> >
>> >> > <xml>
>> >> >  <node value="aacosta"/>
>> >> > </xml>
>> >> >
>> >> > two questions
>> >> >
>> >> > Why is the xml being sent back by default? What is the right param to
>> >> pass
>> >> > in to trigger the html?
>> >> >
>> >> > show function is as follows
>> >> >
>> >> >
>> >> > function(doc, req) {
>> >> >  // !code lib/helpers/template.js
>> >> >  // !json lib.templates
>> >> >
>> >> >  respondWith(req, {
>> >> >    html : function() {
>> >> >      var html = template(lib.templates.show_details, doc);
>> >> >      return {body:html}
>> >> >    },
>> >> >    xml : function() {
>> >> >      return {
>> >> >        body : <xml><node value={doc._id}/></xml>
>> >> >      }
>> >> >    }
>> >> >  })
>> >> > };
>> >>
>> >> Accept header handling in browsers is so bad I'm starting to wish I'd
>> >> never written that code. Kinda want to strip it out altogether.
>> >>
>> >> I believe Rails just stopped supporting the Accept header for the same
>> >> reason. (They've moved to URLs like /path/object.xml due to lack of
>> >> browser support for Accept.)
>> >>
>> >> To make a long story short, for the time being you can request:
>> >>
>> >> $CDB/ptest2/_design/vt2/_show/show_details/aacosta?format=html
>> >>
>> >> to override the format.
>> >>
>> >> Chris
>> >>
>> >> >
>> >> >
>> >> > html template is as follows
>> >> >
>> >> >
>> >> > <!DOCTYPE html>
>> >> > <html>
>> >> >  <head>
>> >> >    <title>Details</title>
>> >> >  </head>
>> >> >  <body>
>> >> >    <div id="docid">
>> >> >      <h1><% doc._id %></h1>
>> >> >    </div>
>> >> >  </body>
>> >> >
>> >> > </html>
>> >> >
>> >> >
>> >> > Thanks much,
>> >> >
>> >> >
>> >> >
>> >> >
>> >> > 37% of all statistics are made up on the spot
>> >> >
>> >>
>> -------------------------------------------------------------------------------------
>> >> > Nitin Borwankar
>> >> > nborwankar@gmail.com
>> >> >
>> >>
>> >>
>> >>
>> >> --
>> >> Chris Anderson
>> >> http://jchrisa.net
>> >> http://couch.io
>> >>
>> >
>>
>
>

Re: switching between response content type in show? how to trigger html response inst of default xml

Posted by Nitin Borwankar <ni...@borwankar.com>.
Hi Paul,

No change - still the same error.


 curl $CDB/ptest2/_design/vt2/_show/show_details/aacosta?format=html

{"error":"noproc","reason":"{gen_server,call,\n
[couch_query_servers,{ret_proc,<<\"javascript\">>,<0.19458.0>}]}"}



Has anyone gotten list views to work on 0.9 ?
I can't be the only one having this problem right?
Or are most people not using couchapp ?

Nitin

37% of all statistics are made up on the spot
-------------------------------------------------------------------------------------
Nitin Borwankar
nborwankar@gmail.com


On Fri, Jul 24, 2009 at 3:28 PM, Paul Davis <pa...@gmail.com>wrote:

> Another shot in the dark, care to try quoting the html value so that
> it's {"html": ...}
>
> On Fri, Jul 24, 2009 at 6:06 PM, Nitin Borwankar<ni...@borwankar.com>
> wrote:
> > Hi Chris,
> >
> > In CouchDBX 0.9 on Leopard adding ?format=html  hangs and then gives foll
> > error
> >
> > {"error":"noproc","reason":"{gen_server,call,\n
> > [couch_query_servers,{ret_proc,<<\"javascript\">>,<0.16450.0>}]}"}
> >
> > Same behavior when you remove the xml: key/val pair and leave just the
> html:
> >
> > I don't see anything in the code or the template that may be a problem do
> > you ?
> >
> > Nitin
> >
> > 37% of all statistics are made up on the spot
> >
> -------------------------------------------------------------------------------------
> > Nitin Borwankar
> > nborwankar@gmail.com
> >
> >
> > On Fri, Jul 24, 2009 at 2:49 PM, Chris Anderson <jc...@apache.org>
> wrote:
> >
> >> On Fri, Jul 24, 2009 at 12:19 PM, Nitin Borwankar<ni...@borwankar.com>
> >> wrote:
> >> > Hi guys,
> >> >
> >> > so the list/show coding is going well - have the show running except
> for
> >> one
> >> > blocker - I am using curl to invoke the show (alost identical to
> example)
> >> in
> >> > couch app as follows - change dthe name from example to show_details
> in
> >> both
> >> > the shows code and lib/template - id in this request is "aacosta"  -
> the
> >> > template just returns a doc with the id in it
> >> >
> >> > curl $CDB/ptest2/_design/vt2/_show/show_details/aacosta
> >> >
> >> > <xml>
> >> >  <node value="aacosta"/>
> >> > </xml>
> >> >
> >> > two questions
> >> >
> >> > Why is the xml being sent back by default? What is the right param to
> >> pass
> >> > in to trigger the html?
> >> >
> >> > show function is as follows
> >> >
> >> >
> >> > function(doc, req) {
> >> >  // !code lib/helpers/template.js
> >> >  // !json lib.templates
> >> >
> >> >  respondWith(req, {
> >> >    html : function() {
> >> >      var html = template(lib.templates.show_details, doc);
> >> >      return {body:html}
> >> >    },
> >> >    xml : function() {
> >> >      return {
> >> >        body : <xml><node value={doc._id}/></xml>
> >> >      }
> >> >    }
> >> >  })
> >> > };
> >>
> >> Accept header handling in browsers is so bad I'm starting to wish I'd
> >> never written that code. Kinda want to strip it out altogether.
> >>
> >> I believe Rails just stopped supporting the Accept header for the same
> >> reason. (They've moved to URLs like /path/object.xml due to lack of
> >> browser support for Accept.)
> >>
> >> To make a long story short, for the time being you can request:
> >>
> >> $CDB/ptest2/_design/vt2/_show/show_details/aacosta?format=html
> >>
> >> to override the format.
> >>
> >> Chris
> >>
> >> >
> >> >
> >> > html template is as follows
> >> >
> >> >
> >> > <!DOCTYPE html>
> >> > <html>
> >> >  <head>
> >> >    <title>Details</title>
> >> >  </head>
> >> >  <body>
> >> >    <div id="docid">
> >> >      <h1><% doc._id %></h1>
> >> >    </div>
> >> >  </body>
> >> >
> >> > </html>
> >> >
> >> >
> >> > Thanks much,
> >> >
> >> >
> >> >
> >> >
> >> > 37% of all statistics are made up on the spot
> >> >
> >>
> -------------------------------------------------------------------------------------
> >> > Nitin Borwankar
> >> > nborwankar@gmail.com
> >> >
> >>
> >>
> >>
> >> --
> >> Chris Anderson
> >> http://jchrisa.net
> >> http://couch.io
> >>
> >
>

Re: switching between response content type in show? how to trigger html response inst of default xml

Posted by Paul Davis <pa...@gmail.com>.
Another shot in the dark, care to try quoting the html value so that
it's {"html": ...}

On Fri, Jul 24, 2009 at 6:06 PM, Nitin Borwankar<ni...@borwankar.com> wrote:
> Hi Chris,
>
> In CouchDBX 0.9 on Leopard adding ?format=html  hangs and then gives foll
> error
>
> {"error":"noproc","reason":"{gen_server,call,\n
> [couch_query_servers,{ret_proc,<<\"javascript\">>,<0.16450.0>}]}"}
>
> Same behavior when you remove the xml: key/val pair and leave just the html:
>
> I don't see anything in the code or the template that may be a problem do
> you ?
>
> Nitin
>
> 37% of all statistics are made up on the spot
> -------------------------------------------------------------------------------------
> Nitin Borwankar
> nborwankar@gmail.com
>
>
> On Fri, Jul 24, 2009 at 2:49 PM, Chris Anderson <jc...@apache.org> wrote:
>
>> On Fri, Jul 24, 2009 at 12:19 PM, Nitin Borwankar<ni...@borwankar.com>
>> wrote:
>> > Hi guys,
>> >
>> > so the list/show coding is going well - have the show running except for
>> one
>> > blocker - I am using curl to invoke the show (alost identical to example)
>> in
>> > couch app as follows - change dthe name from example to show_details in
>> both
>> > the shows code and lib/template - id in this request is "aacosta"  - the
>> > template just returns a doc with the id in it
>> >
>> > curl $CDB/ptest2/_design/vt2/_show/show_details/aacosta
>> >
>> > <xml>
>> >  <node value="aacosta"/>
>> > </xml>
>> >
>> > two questions
>> >
>> > Why is the xml being sent back by default? What is the right param to
>> pass
>> > in to trigger the html?
>> >
>> > show function is as follows
>> >
>> >
>> > function(doc, req) {
>> >  // !code lib/helpers/template.js
>> >  // !json lib.templates
>> >
>> >  respondWith(req, {
>> >    html : function() {
>> >      var html = template(lib.templates.show_details, doc);
>> >      return {body:html}
>> >    },
>> >    xml : function() {
>> >      return {
>> >        body : <xml><node value={doc._id}/></xml>
>> >      }
>> >    }
>> >  })
>> > };
>>
>> Accept header handling in browsers is so bad I'm starting to wish I'd
>> never written that code. Kinda want to strip it out altogether.
>>
>> I believe Rails just stopped supporting the Accept header for the same
>> reason. (They've moved to URLs like /path/object.xml due to lack of
>> browser support for Accept.)
>>
>> To make a long story short, for the time being you can request:
>>
>> $CDB/ptest2/_design/vt2/_show/show_details/aacosta?format=html
>>
>> to override the format.
>>
>> Chris
>>
>> >
>> >
>> > html template is as follows
>> >
>> >
>> > <!DOCTYPE html>
>> > <html>
>> >  <head>
>> >    <title>Details</title>
>> >  </head>
>> >  <body>
>> >    <div id="docid">
>> >      <h1><% doc._id %></h1>
>> >    </div>
>> >  </body>
>> >
>> > </html>
>> >
>> >
>> > Thanks much,
>> >
>> >
>> >
>> >
>> > 37% of all statistics are made up on the spot
>> >
>> -------------------------------------------------------------------------------------
>> > Nitin Borwankar
>> > nborwankar@gmail.com
>> >
>>
>>
>>
>> --
>> Chris Anderson
>> http://jchrisa.net
>> http://couch.io
>>
>

Re: switching between response content type in show? how to trigger html response inst of default xml

Posted by Nitin Borwankar <ni...@borwankar.com>.
Hi Chris,

In CouchDBX 0.9 on Leopard adding ?format=html  hangs and then gives foll
error

{"error":"noproc","reason":"{gen_server,call,\n
[couch_query_servers,{ret_proc,<<\"javascript\">>,<0.16450.0>}]}"}

Same behavior when you remove the xml: key/val pair and leave just the html:

I don't see anything in the code or the template that may be a problem do
you ?

Nitin

37% of all statistics are made up on the spot
-------------------------------------------------------------------------------------
Nitin Borwankar
nborwankar@gmail.com


On Fri, Jul 24, 2009 at 2:49 PM, Chris Anderson <jc...@apache.org> wrote:

> On Fri, Jul 24, 2009 at 12:19 PM, Nitin Borwankar<ni...@borwankar.com>
> wrote:
> > Hi guys,
> >
> > so the list/show coding is going well - have the show running except for
> one
> > blocker - I am using curl to invoke the show (alost identical to example)
> in
> > couch app as follows - change dthe name from example to show_details in
> both
> > the shows code and lib/template - id in this request is "aacosta"  - the
> > template just returns a doc with the id in it
> >
> > curl $CDB/ptest2/_design/vt2/_show/show_details/aacosta
> >
> > <xml>
> >  <node value="aacosta"/>
> > </xml>
> >
> > two questions
> >
> > Why is the xml being sent back by default? What is the right param to
> pass
> > in to trigger the html?
> >
> > show function is as follows
> >
> >
> > function(doc, req) {
> >  // !code lib/helpers/template.js
> >  // !json lib.templates
> >
> >  respondWith(req, {
> >    html : function() {
> >      var html = template(lib.templates.show_details, doc);
> >      return {body:html}
> >    },
> >    xml : function() {
> >      return {
> >        body : <xml><node value={doc._id}/></xml>
> >      }
> >    }
> >  })
> > };
>
> Accept header handling in browsers is so bad I'm starting to wish I'd
> never written that code. Kinda want to strip it out altogether.
>
> I believe Rails just stopped supporting the Accept header for the same
> reason. (They've moved to URLs like /path/object.xml due to lack of
> browser support for Accept.)
>
> To make a long story short, for the time being you can request:
>
> $CDB/ptest2/_design/vt2/_show/show_details/aacosta?format=html
>
> to override the format.
>
> Chris
>
> >
> >
> > html template is as follows
> >
> >
> > <!DOCTYPE html>
> > <html>
> >  <head>
> >    <title>Details</title>
> >  </head>
> >  <body>
> >    <div id="docid">
> >      <h1><% doc._id %></h1>
> >    </div>
> >  </body>
> >
> > </html>
> >
> >
> > Thanks much,
> >
> >
> >
> >
> > 37% of all statistics are made up on the spot
> >
> -------------------------------------------------------------------------------------
> > Nitin Borwankar
> > nborwankar@gmail.com
> >
>
>
>
> --
> Chris Anderson
> http://jchrisa.net
> http://couch.io
>