svn commit: r1051325 - /couchdb/trunk/test/bench/benchbulk.sh

2010-12-20 Thread jchris
Author: jchris
Date: Tue Dec 21 00:07:40 2010
New Revision: 1051325

URL: http://svn.apache.org/viewvc?rev=1051325&view=rev
Log:
update benchbulk script for json content-type

Modified:
couchdb/trunk/test/bench/benchbulk.sh

Modified: couchdb/trunk/test/bench/benchbulk.sh
URL: 
http://svn.apache.org/viewvc/couchdb/trunk/test/bench/benchbulk.sh?rev=1051325&r1=1051324&r2=1051325&view=diff
==
--- couchdb/trunk/test/bench/benchbulk.sh (original)
+++ couchdb/trunk/test/bench/benchbulk.sh Tue Dec 21 00:07:40 2010
@@ -57,7 +57,7 @@ while [ $RUN -lt $ROUNDS ]; do
 echo "startkey $STARTKEY bulksize $BULKSIZE"
 DOCS=$(make_bulk_docs $BULKSIZE $STARTKEY $DOCSIZE)
 # echo $DOCS
-echo $DOCS | curl -T - -X POST $POSTURL -w%{http_code}\ %{time_total}\ 
sec\\n >/dev/null 2>&1 &
+echo $DOCS | curl -T - -H Content-Type:application/json -X POST $POSTURL 
-w%{http_code}\ %{time_total}\ sec\\n >/dev/null 2>&1 &
 let POSTS=POSTS+1
   done
 




svn commit: r1039619 - in /couchdb/trunk: share/www/dialog/ share/www/script/ share/www/script/test/ share/www/spec/ src/couchdb/

2010-11-26 Thread jchris
Author: jchris
Date: Sat Nov 27 04:41:20 2010
New Revision: 1039619

URL: http://svn.apache.org/viewvc?rev=1039619&view=rev
Log:
rename "readers" to "members" in _security object, keep backwards compatibility 
with old security objects"

Modified:
couchdb/trunk/share/www/dialog/_database_security.html
couchdb/trunk/share/www/script/futon.browse.js
couchdb/trunk/share/www/script/test/reader_acl.js
couchdb/trunk/share/www/script/test/replication.js
couchdb/trunk/share/www/spec/couch_js_instance_methods_3_spec.js
couchdb/trunk/src/couchdb/couch_db.erl

Modified: couchdb/trunk/share/www/dialog/_database_security.html
URL: 
http://svn.apache.org/viewvc/couchdb/trunk/share/www/dialog/_database_security.html?rev=1039619&r1=1039618&r2=1039619&view=diff
==
--- couchdb/trunk/share/www/dialog/_database_security.html (original)
+++ couchdb/trunk/share/www/dialog/_database_security.html Sat Nov 27 04:41:20 
2010
@@ -16,12 +16,12 @@ specific language governing permissions 
   Security
   
 
-  Each database contains lists of admins and readers. 
-  Admins and readers are each defined by names and 
roles, which are lists of strings.
+  Each database contains lists of admins and members.
+  Admins and members are each defined by names and 
roles, which are lists of strings.
 
 
 Admins
-Database admins can update design documents and edit the 
readers list.
+Database admins can update design documents and edit the 
admin and member lists.
 
   Names:
   
@@ -31,14 +31,14 @@ specific language governing permissions 
 
 
 
-Readers
-Database readers can access the database. If no readers 
are defined, the database is public.
+Members
+Database members can access the database. If no members 
are defined, the database is public.
 
   Names:
-  
+  
 
   Roles:
-  
+  
 
 
 

Modified: couchdb/trunk/share/www/script/futon.browse.js
URL: 
http://svn.apache.org/viewvc/couchdb/trunk/share/www/script/futon.browse.js?rev=1039619&r1=1039618&r2=1039619&view=diff
==
--- couchdb/trunk/share/www/script/futon.browse.js [utf-8] (original)
+++ couchdb/trunk/share/www/script/futon.browse.js [utf-8] Sat Nov 27 04:41:20 
2010
@@ -189,26 +189,34 @@
   }
 
   this.databaseSecurity = function() {
+function namesAndRoles(r, key) {
+  var names = [];
+  var roles = [];
+  if (r && typeof r[key + "s"] === "object") {
+if ($.isArray(r[key + "s"]["names"])) {
+  names = r[key + "s"]["names"];
+}
+if ($.isArray(r[key + "s"]["roles"])) {
+  roles = r[key + "s"]["roles"];
+}
+  }
+  return {names : names, roles: roles};
+};
+
 $.showDialog("dialog/_database_security.html", {
   load : function(d) {
 db.getDbProperty("_security", {
   success: function(r) {
-["admin", "reader"].forEach(function(key) {
-  var names = [];
-  var roles = [];
-
-  if (r && typeof r[key + "s"] === "object") {
-if ($.isArray(r[key + "s"]["names"])) {
-  names = r[key + "s"]["names"];
-}
-if ($.isArray(r[key + "s"]["roles"])) {
-  roles = r[key + "s"]["roles"];
-}
-  }
-
-  $("input[name=" + key + "_names]", 
d).val(JSON.stringify(names));
-  $("input[name=" + key + "_roles]", 
d).val(JSON.stringify(roles));
-});
+var admins = namesAndRoles(r, "admin")
+  , members = namesAndRoles(r, "member");
+if (members.names.length + members.roles.length == 0) {
+  // backwards compatibility with readers for 1.x
+  members = namesAndRoles(r, "reader");
+}
+$("input[name=admin_names]", 
d).val(JSON.stringify(admins.names));
+$("input[name=admin_roles]", 
d).val(JSON.stringify(admins.roles));
+$("input[name=member_names]", 
d).val(JSON.stringify(members.names));
+$("input[name=member_roles]", 
d).val(JSON.stringify(members.roles));
   }
 });
   },
@@ -220,13 +228,13 @@

svn commit: r1003726 - /couchdb/branches/1.0.x/src/couchdb/couch_view.erl

2010-10-01 Thread jchris
Author: jchris
Date: Sat Oct  2 01:12:43 2010
New Revision: 1003726

URL: http://svn.apache.org/viewvc?rev=1003726&view=rev
Log:
using an infinity timeout in places where we wait on disk io

Modified:
couchdb/branches/1.0.x/src/couchdb/couch_view.erl

Modified: couchdb/branches/1.0.x/src/couchdb/couch_view.erl
URL: 
http://svn.apache.org/viewvc/couchdb/branches/1.0.x/src/couchdb/couch_view.erl?rev=1003726&r1=1003725&r2=1003726&view=diff
==
--- couchdb/branches/1.0.x/src/couchdb/couch_view.erl (original)
+++ couchdb/branches/1.0.x/src/couchdb/couch_view.erl Sat Oct  2 01:12:43 2010
@@ -31,7 +31,7 @@ start_link() ->
 get_temp_updater(DbName, Language, DesignOptions, MapSrc, RedSrc) ->
 {ok, Group} =
 couch_view_group:open_temp_group(DbName, Language, DesignOptions, 
MapSrc, RedSrc),
-case gen_server:call(couch_view, {get_group_server, DbName, Group}) of
+case gen_server:call(couch_view, {get_group_server, DbName, Group}, 
infinity) of
 {ok, Pid} ->
 Pid;
 Error ->
@@ -41,7 +41,7 @@ get_temp_updater(DbName, Language, Desig
 get_group_server(DbName, GroupId) ->
 case couch_view_group:open_db_group(DbName, GroupId) of
 {ok, Group} ->
-case gen_server:call(couch_view, {get_group_server, DbName, Group}) of
+case gen_server:call(couch_view, {get_group_server, DbName, Group}, 
infinity) of
 {ok, Pid} ->
 Pid;
 Error ->




svn commit: r1003723 - /couchdb/trunk/src/couchdb/couch_view.erl

2010-10-01 Thread jchris
Author: jchris
Date: Sat Oct  2 00:50:49 2010
New Revision: 1003723

URL: http://svn.apache.org/viewvc?rev=1003723&view=rev
Log:
using an infinity timeout in places where we wait on disk io

Modified:
couchdb/trunk/src/couchdb/couch_view.erl

Modified: couchdb/trunk/src/couchdb/couch_view.erl
URL: 
http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_view.erl?rev=1003723&r1=1003722&r2=1003723&view=diff
==
--- couchdb/trunk/src/couchdb/couch_view.erl (original)
+++ couchdb/trunk/src/couchdb/couch_view.erl Sat Oct  2 00:50:49 2010
@@ -31,7 +31,7 @@ start_link() ->
 get_temp_updater(DbName, Language, DesignOptions, MapSrc, RedSrc) ->
 {ok, Group} =
 couch_view_group:open_temp_group(DbName, Language, DesignOptions, 
MapSrc, RedSrc),
-case gen_server:call(couch_view, {get_group_server, DbName, Group}) of
+case gen_server:call(couch_view, {get_group_server, DbName, Group}, 
infinity) of
 {ok, Pid} ->
 Pid;
 Error ->
@@ -41,7 +41,7 @@ get_temp_updater(DbName, Language, Desig
 get_group_server(DbName, GroupId) ->
 case couch_view_group:open_db_group(DbName, GroupId) of
 {ok, Group} ->
-case gen_server:call(couch_view, {get_group_server, DbName, Group}) of
+case gen_server:call(couch_view, {get_group_server, DbName, Group}, 
infinity) of
 {ok, Pid} ->
 Pid;
 Error ->




svn commit: r1003718 - in /couchdb/branches/1.0.x/src/couchdb: couch_view.erl couch_view_group.erl

2010-10-01 Thread jchris
Author: jchris
Date: Sat Oct  2 00:05:59 2010
New Revision: 1003718

URL: http://svn.apache.org/viewvc?rev=1003718&view=rev
Log:
backport r1003701 (fix db file ref count in view generation

Modified:
couchdb/branches/1.0.x/src/couchdb/couch_view.erl
couchdb/branches/1.0.x/src/couchdb/couch_view_group.erl

Modified: couchdb/branches/1.0.x/src/couchdb/couch_view.erl
URL: 
http://svn.apache.org/viewvc/couchdb/branches/1.0.x/src/couchdb/couch_view.erl?rev=1003718&r1=1003717&r2=1003718&view=diff
==
--- couchdb/branches/1.0.x/src/couchdb/couch_view.erl (original)
+++ couchdb/branches/1.0.x/src/couchdb/couch_view.erl Sat Oct  2 00:05:59 2010
@@ -29,9 +29,7 @@ start_link() ->
 gen_server:start_link({local, couch_view}, couch_view, [], []).
 
 get_temp_updater(DbName, Language, DesignOptions, MapSrc, RedSrc) ->
-% make temp group
-% do we need to close this db?
-{ok, _Db, Group} =
+{ok, Group} =
 couch_view_group:open_temp_group(DbName, Language, DesignOptions, 
MapSrc, RedSrc),
 case gen_server:call(couch_view, {get_group_server, DbName, Group}) of
 {ok, Pid} ->
@@ -41,10 +39,8 @@ get_temp_updater(DbName, Language, Desig
 end.
 
 get_group_server(DbName, GroupId) ->
-% get signature for group
 case couch_view_group:open_db_group(DbName, GroupId) of
-% do we need to close this db?
-{ok, _Db, Group} ->
+{ok, Group} ->
 case gen_server:call(couch_view, {get_group_server, DbName, Group}) of
 {ok, Pid} ->
 Pid;

Modified: couchdb/branches/1.0.x/src/couchdb/couch_view_group.erl
URL: 
http://svn.apache.org/viewvc/couchdb/branches/1.0.x/src/couchdb/couch_view_group.erl?rev=1003718&r1=1003717&r2=1003718&view=diff
==
--- couchdb/branches/1.0.x/src/couchdb/couch_view_group.erl (original)
+++ couchdb/branches/1.0.x/src/couchdb/couch_view_group.erl Sat Oct  2 00:05:59 
2010
@@ -445,8 +445,8 @@ open_temp_group(DbName, Language, Design
 def=MapSrc,
 reduce_funs= if RedSrc==[] -> []; true -> [{<<"_temp">>, RedSrc}] 
end,
 options=DesignOptions},
-
-{ok, Db, set_view_sig(#group{name = <<"_temp">>, db=Db, views=[View],
+couch_db:close(Db),
+{ok, set_view_sig(#group{name = <<"_temp">>, views=[View],
 def_lang=Language, design_options=DesignOptions})};
 Error ->
 Error
@@ -463,7 +463,8 @@ open_db_group(DbName, GroupId) ->
 {ok, Db} ->
 case couch_db:open_doc(Db, GroupId) of
 {ok, Doc} ->
-{ok, Db, design_doc_to_view_group(Doc)};
+couch_db:close(Db),
+{ok, design_doc_to_view_group(Doc)};
 Else ->
 couch_db:close(Db),
 Else




svn commit: r1003706 - /couchdb/trunk/src/couchdb/couch_view_group.erl

2010-10-01 Thread jchris
Author: jchris
Date: Fri Oct  1 23:31:59 2010
New Revision: 1003706

URL: http://svn.apache.org/viewvc?rev=1003706&view=rev
Log:
remove vestigal db handle that will just be replaced by couch_view_updater 
anyway

Modified:
couchdb/trunk/src/couchdb/couch_view_group.erl

Modified: couchdb/trunk/src/couchdb/couch_view_group.erl
URL: 
http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_view_group.erl?rev=1003706&r1=1003705&r2=1003706&view=diff
==
--- couchdb/trunk/src/couchdb/couch_view_group.erl (original)
+++ couchdb/trunk/src/couchdb/couch_view_group.erl Fri Oct  1 23:31:59 2010
@@ -446,7 +446,7 @@ open_temp_group(DbName, Language, Design
 reduce_funs= if RedSrc==[] -> []; true -> [{<<"_temp">>, RedSrc}] 
end,
 options=DesignOptions},
 couch_db:close(Db),
-{ok, set_view_sig(#group{name = <<"_temp">>,lib={[]}, db=Db, 
views=[View],
+{ok, set_view_sig(#group{name = <<"_temp">>,lib={[]}, views=[View],
 def_lang=Language, design_options=DesignOptions})};
 Error ->
 Error




svn commit: r1003701 - in /couchdb/trunk/src/couchdb: couch_view.erl couch_view_group.erl

2010-10-01 Thread jchris
Author: jchris
Date: Fri Oct  1 23:05:30 2010
New Revision: 1003701

URL: http://svn.apache.org/viewvc?rev=1003701&view=rev
Log:
close db handles after using them to get view groups

Modified:
couchdb/trunk/src/couchdb/couch_view.erl
couchdb/trunk/src/couchdb/couch_view_group.erl

Modified: couchdb/trunk/src/couchdb/couch_view.erl
URL: 
http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_view.erl?rev=1003701&r1=1003700&r2=1003701&view=diff
==
--- couchdb/trunk/src/couchdb/couch_view.erl (original)
+++ couchdb/trunk/src/couchdb/couch_view.erl Fri Oct  1 23:05:30 2010
@@ -29,9 +29,7 @@ start_link() ->
 gen_server:start_link({local, couch_view}, couch_view, [], []).
 
 get_temp_updater(DbName, Language, DesignOptions, MapSrc, RedSrc) ->
-% make temp group
-% do we need to close this db?
-{ok, _Db, Group} =
+{ok, Group} =
 couch_view_group:open_temp_group(DbName, Language, DesignOptions, 
MapSrc, RedSrc),
 case gen_server:call(couch_view, {get_group_server, DbName, Group}) of
 {ok, Pid} ->
@@ -41,10 +39,8 @@ get_temp_updater(DbName, Language, Desig
 end.
 
 get_group_server(DbName, GroupId) ->
-% get signature for group
 case couch_view_group:open_db_group(DbName, GroupId) of
-% do we need to close this db?
-{ok, _Db, Group} ->
+{ok, Group} ->
 case gen_server:call(couch_view, {get_group_server, DbName, Group}) of
 {ok, Pid} ->
 Pid;

Modified: couchdb/trunk/src/couchdb/couch_view_group.erl
URL: 
http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_view_group.erl?rev=1003701&r1=1003700&r2=1003701&view=diff
==
--- couchdb/trunk/src/couchdb/couch_view_group.erl (original)
+++ couchdb/trunk/src/couchdb/couch_view_group.erl Fri Oct  1 23:05:30 2010
@@ -445,8 +445,8 @@ open_temp_group(DbName, Language, Design
 def=MapSrc,
 reduce_funs= if RedSrc==[] -> []; true -> [{<<"_temp">>, RedSrc}] 
end,
 options=DesignOptions},
-
-{ok, Db, set_view_sig(#group{name = <<"_temp">>,lib={[]}, db=Db, 
views=[View],
+couch_db:close(Db),
+{ok, set_view_sig(#group{name = <<"_temp">>,lib={[]}, db=Db, 
views=[View],
 def_lang=Language, design_options=DesignOptions})};
 Error ->
 Error
@@ -480,7 +480,8 @@ open_db_group(DbName, GroupId) ->
 {ok, Db} ->
 case couch_db:open_doc(Db, GroupId) of
 {ok, Doc} ->
-{ok, Db, design_doc_to_view_group(Doc)};
+couch_db:close(Db),
+{ok, design_doc_to_view_group(Doc)};
 Else ->
 couch_db:close(Db),
 Else




svn commit: r1003620 - /couchdb/trunk/src/couchdb/couch_httpd_auth.erl

2010-10-01 Thread jchris
Author: jchris
Date: Fri Oct  1 19:09:23 2010
New Revision: 1003620

URL: http://svn.apache.org/viewvc?rev=1003620&view=rev
Log:
downgrade log line from error to debug output

Modified:
couchdb/trunk/src/couchdb/couch_httpd_auth.erl

Modified: couchdb/trunk/src/couchdb/couch_httpd_auth.erl
URL: 
http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_httpd_auth.erl?rev=1003620&r1=1003619&r2=1003620&view=diff
==
--- couchdb/trunk/src/couchdb/couch_httpd_auth.erl (original)
+++ couchdb/trunk/src/couchdb/couch_httpd_auth.erl Fri Oct  1 19:09:23 2010
@@ -173,7 +173,7 @@ cookie_authentication_handler(#httpd{moc
 CurrentTime = make_cookie_time(),
 case couch_config:get("couch_httpd_auth", "secret", nil) of
 nil ->
-?LOG_ERROR("cookie auth secret is not set",[]),
+?LOG_DEBUG("cookie auth secret is not set",[]),
 Req;
 SecretStr ->
 Secret = ?l2b(SecretStr),




svn commit: r1001895 - in /couchdb/trunk: share/server/loop.js share/server/state.js share/www/script/test/design_docs.js src/couchdb/couch_db.hrl src/couchdb/couch_query_servers.erl src/couchdb/couch

2010-09-27 Thread jchris
Author: jchris
Date: Mon Sep 27 20:06:22 2010
New Revision: 1001895

URL: http://svn.apache.org/viewvc?rev=1001895&view=rev
Log:
CommonJS support in map functions

Modified:
couchdb/trunk/share/server/loop.js
couchdb/trunk/share/server/state.js
couchdb/trunk/share/www/script/test/design_docs.js
couchdb/trunk/src/couchdb/couch_db.hrl
couchdb/trunk/src/couchdb/couch_query_servers.erl
couchdb/trunk/src/couchdb/couch_view_group.erl
couchdb/trunk/src/couchdb/couch_view_updater.erl

Modified: couchdb/trunk/share/server/loop.js
URL: 
http://svn.apache.org/viewvc/couchdb/trunk/share/server/loop.js?rev=1001895&r1=1001894&r2=1001895&view=diff
==
--- couchdb/trunk/share/server/loop.js (original)
+++ couchdb/trunk/share/server/loop.js Mon Sep 27 20:06:22 2010
@@ -100,6 +100,7 @@ var Loop = function() {
 // "view": Views.handler,
 "reset": State.reset,
 "add_fun"  : State.addFun,
+"add_lib"  : State.addLib,
 "map_doc"  : Views.mapDoc,
 "reduce"   : Views.reduce,
 "rereduce" : Views.rereduce

Modified: couchdb/trunk/share/server/state.js
URL: 
http://svn.apache.org/viewvc/couchdb/trunk/share/server/state.js?rev=1001895&r1=1001894&r2=1001895&view=diff
==
--- couchdb/trunk/share/server/state.js (original)
+++ couchdb/trunk/share/server/state.js Mon Sep 27 20:06:22 2010
@@ -14,6 +14,7 @@ var State = {
   reset : function(config) {
 // clear the globals and run gc
 State.funs = [];
+State.lib = null;
 State.query_config = config || {};
 init_sandbox();
 gc();
@@ -21,7 +22,11 @@ var State = {
   },
   addFun : function(newFun) {
 // Compile to a function and add it to funs array
-State.funs.push(Couch.compileFunction(newFun));
+State.funs.push(Couch.compileFunction(newFun, {views : {lib : 
State.lib}}));
+print("true");
+  },
+  addLib : function(lib) {
+State.lib = lib;
 print("true");
   }
 }

Modified: couchdb/trunk/share/www/script/test/design_docs.js
URL: 
http://svn.apache.org/viewvc/couchdb/trunk/share/www/script/test/design_docs.js?rev=1001895&r1=1001894&r2=1001895&view=diff
==
--- couchdb/trunk/share/www/script/test/design_docs.js (original)
+++ couchdb/trunk/share/www/script/test/design_docs.js Mon Sep 27 20:06:22 2010
@@ -54,7 +54,18 @@ function() {
   summate2: {map:"function (doc) {emit(doc.integer, doc.integer)};",
 reduce:"function (keys, values) { return sum(values); };"},
   huge_src_and_results: {map: "function(doc) { if (doc._id == \"1\") { 
emit(\"" + makebigstring(16) + "\", null) }}",
-reduce:"function (keys, values) { return \"" + 
makebigstring(16) + "\"; };"}
+reduce:"function (keys, values) { return \"" + 
makebigstring(16) + "\"; };"},
+  lib : {
+baz : "exports.baz = 'bam';",
+foo : {
+  foo : "exports.foo = 'bar';",
+  boom : "exports.boom = 'ok';",
+  zoom : "exports.zoom = 'yeah';"
+}
+  },
+  commonjs : {
+map : "function(doc) { emit(null, require('views/lib/foo/boom').boom)}"
+  }
 },
 shows: {
   simple: "function() {return 'ok'};",
@@ -99,10 +110,14 @@ function() {
   var vinfo = dinfo.view_index;
   TEquals(51, vinfo.disk_size);
   TEquals(false, vinfo.compact_running);
-  TEquals("3f88e53b303e2342e49a66c538c30679", vinfo.signature);
+  TEquals("dc3264b45b74cc6d94666e3043e07154", vinfo.signature, 'ddoc sig');
 
   db.bulkSave(makeDocs(1, numDocs + 1));
 
+  // test commonjs in map functions
+  resp = db.view("test/commonjs", {limit:1});
+  T(resp.rows[0].value == 'ok');
+
   // test that the _all_docs view returns correctly with keys
   var results = db.allDocs({startkey:"_design", endkey:"_design0"});
   T(results.rows.length == 1);

Modified: couchdb/trunk/src/couchdb/couch_db.hrl
URL: 
http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_db.hrl?rev=1001895&r1=1001894&r2=1001895&view=diff
==
--- couchdb/trunk/src/couchdb/couch_db.hrl (original)
+++ couchdb/trunk/src/couchdb/couch_db.hrl Mon Sep 27 20:06:22 2010
@@ -231,6 +231,7 @@
 def_lang,
 design_options=[],
 views,
+lib,
 id_btree=nil,
 current_seq=0,
 purge_seq=0,

Modified: couchdb/trunk/src/couchdb

svn commit: r1001295 - /couchdb/trunk/share/www/script/test/update_documents.js

2010-09-25 Thread jchris
Author: jchris
Date: Sat Sep 25 18:55:23 2010
New Revision: 1001295

URL: http://svn.apache.org/viewvc?rev=1001295&view=rev
Log:
update documents test assertions

Modified:
couchdb/trunk/share/www/script/test/update_documents.js

Modified: couchdb/trunk/share/www/script/test/update_documents.js
URL: 
http://svn.apache.org/viewvc/couchdb/trunk/share/www/script/test/update_documents.js?rev=1001295&r1=1001294&r2=1001295&view=diff
==
--- couchdb/trunk/share/www/script/test/update_documents.js (original)
+++ couchdb/trunk/share/www/script/test/update_documents.js Sat Sep 25 18:55:23 
2010
@@ -113,9 +113,13 @@ couchTests.update_documents = function(d
   T(JSON.parse(xhr.responseText).error == "method_not_allowed");
 
   // // hello update world (non-existing docid)
+  xhr = CouchDB.request("GET", "/test_suite_db/nonExistingDoc");
+  T(xhr.status == 404);
   xhr = CouchDB.request("PUT", 
"/test_suite_db/_design/update/_update/hello/nonExistingDoc");
   T(xhr.status == 201);
   T(xhr.responseText == "New World");
+  xhr = CouchDB.request("GET", "/test_suite_db/nonExistingDoc");
+  T(xhr.status == 200);
 
   // in place update 
   xhr = CouchDB.request("PUT", 
"/test_suite_db/_design/update/_update/in-place/"+docid+'?field=title&value=test');




svn commit: r996270 - /couchdb/branches/1.0.x/share/www/script/test/design_docs.js

2010-09-12 Thread jchris
Author: jchris
Date: Sun Sep 12 09:03:43 2010
New Revision: 996270

URL: http://svn.apache.org/viewvc?rev=996270&view=rev
Log:
additional test for non-circular commonjs require. closes COUCHDB-869

Modified:
couchdb/branches/1.0.x/share/www/script/test/design_docs.js

Modified: couchdb/branches/1.0.x/share/www/script/test/design_docs.js
URL: 
http://svn.apache.org/viewvc/couchdb/branches/1.0.x/share/www/script/test/design_docs.js?rev=996270&r1=996269&r2=996270&view=diff
==
--- couchdb/branches/1.0.x/share/www/script/test/design_docs.js (original)
+++ couchdb/branches/1.0.x/share/www/script/test/design_docs.js Sun Sep 12 
09:03:43 2010
@@ -58,7 +58,8 @@ function() {
 },
 shows: {
   simple: "function() {return 'ok'};",
-  requirey : "function() { var lib = require('whatever/commonjs/upper'); 
return lib.testing; };"
+  requirey : "function() { var lib = require('whatever/commonjs/upper'); 
return lib.testing; };",
+  circular : "function() { var lib = require('whatever/commonjs/upper'); 
return JSON.stringify(this); };"
 }
   }; 
 
@@ -88,6 +89,10 @@ function() {
   T(xhr.status == 200);
   TEquals("PLANKTONwhatever/commonjs/upperplankton", xhr.responseText);
 
+  var xhr = CouchDB.request("GET", 
"/test_suite_db/_design/test/_show/circular");
+  T(xhr.status == 200);
+  TEquals("javascript", JSON.parse(xhr.responseText).language);
+
   // test that we get design doc info back
   var dinfo = db.designInfo("_design/test");
   TEquals("test", dinfo.name);




svn commit: r996269 - in /couchdb/branches/1.0.x/share: server/util.js www/script/test/design_docs.js

2010-09-12 Thread jchris
Author: jchris
Date: Sun Sep 12 09:03:38 2010
New Revision: 996269

URL: http://svn.apache.org/viewvc?rev=996269&view=rev
Log:
commonjs require no longer creates circular references

Modified:
couchdb/branches/1.0.x/share/server/util.js
couchdb/branches/1.0.x/share/www/script/test/design_docs.js

Modified: couchdb/branches/1.0.x/share/server/util.js
URL: 
http://svn.apache.org/viewvc/couchdb/branches/1.0.x/share/server/util.js?rev=996269&r1=996268&r2=996269&view=diff
==
--- couchdb/branches/1.0.x/share/server/util.js (original)
+++ couchdb/branches/1.0.x/share/server/util.js Sun Sep 12 09:03:38 2010
@@ -10,36 +10,50 @@
 // License for the specific language governing permissions and limitations 
under
 // the License.
 
-var resolveModule = function(names, parent, current, path) {
+var resolveModule = function(names, mod, root) {
   if (names.length == 0) {
-if (typeof current != "string") {
+if (typeof mod.current != "string") {
   throw ["error","invalid_require_path",
-'Must require a JavaScript string, not: '+(typeof current)];
+'Must require a JavaScript string, not: '+(typeof mod.current)];
+}
+return {
+  current : mod.current,
+  parent : mod.parent,
+  id : mod.id,
+  exports : {}
 }
-return [current, parent, path];
   }
   // we need to traverse the path
   var n = names.shift();
   if (n == '..') {
-if (!(parent && parent.parent)) {
-  throw ["error", "invalid_require_path", 'Object has no parent 
'+JSON.stringify(current)];
+if (!(mod.parent && mod.parent.parent)) {
+  throw ["error", "invalid_require_path", 'Object has no parent 
'+JSON.stringify(mod.current)];
 }
-path = path.slice(0, path.lastIndexOf('/'));
-return resolveModule(names, parent.parent.parent, parent.parent, path);
+return resolveModule(names, {
+  id : mod.id.slice(0, mod.id.lastIndexOf('/')),
+  parent : mod.parent.parent.parent,
+  current : mod.parent.parent.current
+});
   } else if (n == '.') {
-if (!parent) {
-  throw ["error", "invalid_require_path", 'Object has no parent 
'+JSON.stringify(current)];
+if (!mod.parent) {
+  throw ["error", "invalid_require_path", 'Object has no parent 
'+JSON.stringify(mod.current)];
 }
-return resolveModule(names, parent.parent, parent, path);
-  }
-  if (!current[n]) {
-throw ["error", "invalid_require_path", 'Object has no property "'+n+'". 
'+JSON.stringify(current)];
-  }
-  var p = current;
-  current = current[n];
-  current.parent = p;
-  path = path ? path + '/' + n : n;
-  return resolveModule(names, p, current, path);
+return resolveModule(names, {
+  parent : mod.parent.parent,
+  current : mod.parent.current,
+  id : mod.id
+});
+  } else if (root) {
+mod = {current : root};
+  }
+  if (!mod.current[n]) {
+throw ["error", "invalid_require_path", 'Object has no property "'+n+'". 
'+JSON.stringify(mod.current)];
+  }
+  return resolveModule(names, {
+current : mod.current[n],
+parent : mod,
+id : mod.id ? mod.id + '/' + n : n
+  });
 };
 
 var Couch = {
@@ -52,19 +66,17 @@ var Couch = {
 try {
   if (sandbox) {
 if (ddoc) {
-  var require = function(name, parent) {
-if (!parent) {parent = {}};
-var resolved = resolveModule(name.split('/'), parent.actual, ddoc, 
parent.id);
-var s = "function (module, exports, require) { " + resolved[0] + " 
}";
-var module = {id:resolved[2], actual:resolved[1]};
-module.exports = {};
+  var require = function(name, module) {
+module = module || {};
+var newModule = resolveModule(name.split('/'), module, ddoc);
+var s = "function (module, exports, require) { " + 
newModule.current + " }";
 try {
   var func = sandbox ? evalcx(s, sandbox) : eval(s);
-  func.apply(sandbox, [module, module.exports, function(name) 
{return require(name, module)}]);
+  func.apply(sandbox, [newModule, newModule.exports, 
function(name) {return require(name, newModule)}]);
 } catch(e) { 
   throw ["error","compilation_error","Module require('"+name+"') 
raised error "+e.toSource()]; 
 }
-return module.exports;
+return newModule.exports;
   }
   sandbox.require = require;
  

svn commit: r996267 - /couchdb/trunk/share/www/script/test/design_docs.js

2010-09-12 Thread jchris
Author: jchris
Date: Sun Sep 12 09:01:47 2010
New Revision: 996267

URL: http://svn.apache.org/viewvc?rev=996267&view=rev
Log:
additional test for non-circular commonjs require. closes COUCHDB-869

Modified:
couchdb/trunk/share/www/script/test/design_docs.js

Modified: couchdb/trunk/share/www/script/test/design_docs.js
URL: 
http://svn.apache.org/viewvc/couchdb/trunk/share/www/script/test/design_docs.js?rev=996267&r1=996266&r2=996267&view=diff
==
--- couchdb/trunk/share/www/script/test/design_docs.js (original)
+++ couchdb/trunk/share/www/script/test/design_docs.js Sun Sep 12 09:01:47 2010
@@ -58,7 +58,8 @@ function() {
 },
 shows: {
   simple: "function() {return 'ok'};",
-  requirey : "function() { var lib = require('whatever/commonjs/upper'); 
return lib.testing; };"
+  requirey : "function() { var lib = require('whatever/commonjs/upper'); 
return lib.testing; };",
+  circular : "function() { var lib = require('whatever/commonjs/upper'); 
return JSON.stringify(this); };"
 }
   }; 
 
@@ -88,6 +89,10 @@ function() {
   T(xhr.status == 200);
   TEquals("PLANKTONwhatever/commonjs/upperplankton", xhr.responseText);
 
+  var xhr = CouchDB.request("GET", 
"/test_suite_db/_design/test/_show/circular");
+  T(xhr.status == 200);
+  TEquals("javascript", JSON.parse(xhr.responseText).language);
+
   // test that we get design doc info back
   var dinfo = db.designInfo("_design/test");
   TEquals("test", dinfo.name);




svn commit: r996266 - in /couchdb/trunk/share: server/util.js www/script/test/design_docs.js

2010-09-12 Thread jchris
Author: jchris
Date: Sun Sep 12 08:56:17 2010
New Revision: 996266

URL: http://svn.apache.org/viewvc?rev=996266&view=rev
Log:
commonjs require no longer creates circular references

Modified:
couchdb/trunk/share/server/util.js
couchdb/trunk/share/www/script/test/design_docs.js

Modified: couchdb/trunk/share/server/util.js
URL: 
http://svn.apache.org/viewvc/couchdb/trunk/share/server/util.js?rev=996266&r1=996265&r2=996266&view=diff
==
--- couchdb/trunk/share/server/util.js (original)
+++ couchdb/trunk/share/server/util.js Sun Sep 12 08:56:17 2010
@@ -10,36 +10,50 @@
 // License for the specific language governing permissions and limitations 
under
 // the License.
 
-var resolveModule = function(names, parent, current, path) {
+var resolveModule = function(names, mod, root) {
   if (names.length == 0) {
-if (typeof current != "string") {
+if (typeof mod.current != "string") {
   throw ["error","invalid_require_path",
-'Must require a JavaScript string, not: '+(typeof current)];
+'Must require a JavaScript string, not: '+(typeof mod.current)];
+}
+return {
+  current : mod.current,
+  parent : mod.parent,
+  id : mod.id,
+  exports : {}
 }
-return [current, parent, path];
   }
   // we need to traverse the path
   var n = names.shift();
   if (n == '..') {
-if (!(parent && parent.parent)) {
-  throw ["error", "invalid_require_path", 'Object has no parent 
'+JSON.stringify(current)];
+if (!(mod.parent && mod.parent.parent)) {
+  throw ["error", "invalid_require_path", 'Object has no parent 
'+JSON.stringify(mod.current)];
 }
-path = path.slice(0, path.lastIndexOf('/'));
-return resolveModule(names, parent.parent.parent, parent.parent, path);
+return resolveModule(names, {
+  id : mod.id.slice(0, mod.id.lastIndexOf('/')),
+  parent : mod.parent.parent.parent,
+  current : mod.parent.parent.current
+});
   } else if (n == '.') {
-if (!parent) {
-  throw ["error", "invalid_require_path", 'Object has no parent 
'+JSON.stringify(current)];
+if (!mod.parent) {
+  throw ["error", "invalid_require_path", 'Object has no parent 
'+JSON.stringify(mod.current)];
 }
-return resolveModule(names, parent.parent, parent, path);
-  }
-  if (!current[n]) {
-throw ["error", "invalid_require_path", 'Object has no property "'+n+'". 
'+JSON.stringify(current)];
-  }
-  var p = current;
-  current = current[n];
-  current.parent = p;
-  path = path ? path + '/' + n : n;
-  return resolveModule(names, p, current, path);
+return resolveModule(names, {
+  parent : mod.parent.parent,
+  current : mod.parent.current,
+  id : mod.id
+});
+  } else if (root) {
+mod = {current : root};
+  }
+  if (!mod.current[n]) {
+throw ["error", "invalid_require_path", 'Object has no property "'+n+'". 
'+JSON.stringify(mod.current)];
+  }
+  return resolveModule(names, {
+current : mod.current[n],
+parent : mod,
+id : mod.id ? mod.id + '/' + n : n
+  });
 };
 
 var Couch = {
@@ -52,19 +66,17 @@ var Couch = {
 try {
   if (sandbox) {
 if (ddoc) {
-  var require = function(name, parent) {
-if (!parent) {parent = {}};
-var resolved = resolveModule(name.split('/'), parent.actual, ddoc, 
parent.id);
-var s = "function (module, exports, require) { " + resolved[0] + " 
}";
-var module = {id:resolved[2], actual:resolved[1]};
-module.exports = {};
+  var require = function(name, module) {
+module = module || {};
+var newModule = resolveModule(name.split('/'), module, ddoc);
+var s = "function (module, exports, require) { " + 
newModule.current + " }";
 try {
   var func = sandbox ? evalcx(s, sandbox) : eval(s);
-  func.apply(sandbox, [module, module.exports, function(name) 
{return require(name, module)}]);
+  func.apply(sandbox, [newModule, newModule.exports, 
function(name) {return require(name, newModule)}]);
 } catch(e) { 
   throw ["error","compilation_error","Module require('"+name+"') 
raised error "+e.toSource()]; 
 }
-return module.exports;
+return newModule.exports;
   }
   sandbox.require = require;
 }

Modified: couchdb/trunk/share/www/script/test/d

svn commit: r996199 - /couchdb/trunk/etc/couchdb/default.ini.tpl.in

2010-09-11 Thread jchris
Author: jchris
Date: Sat Sep 11 19:34:56 2010
New Revision: 996199

URL: http://svn.apache.org/viewvc?rev=996199&view=rev
Log:
raise the default session timeout to 12 hours

Modified:
couchdb/trunk/etc/couchdb/default.ini.tpl.in

Modified: couchdb/trunk/etc/couchdb/default.ini.tpl.in
URL: 
http://svn.apache.org/viewvc/couchdb/trunk/etc/couchdb/default.ini.tpl.in?rev=996199&r1=996198&r2=996199&view=diff
==
--- couchdb/trunk/etc/couchdb/default.ini.tpl.in (original)
+++ couchdb/trunk/etc/couchdb/default.ini.tpl.in Sat Sep 11 19:34:56 2010
@@ -35,7 +35,7 @@ include_sasl = true
 authentication_db = _users
 authentication_redirect = /_utils/session.html
 require_valid_user = false
-timeout = 600 ; number of seconds before automatic logout
+timeout = 43200 ; (default to 12 hours) number of seconds before automatic 
logout
 auth_cache_size = 50 ; size is number of cache entries
 
 [query_servers]




svn commit: r993229 - /couchdb/trunk/src/couchdb/couch_httpd_view.erl

2010-09-06 Thread jchris
Author: jchris
Date: Tue Sep  7 06:48:46 2010
New Revision: 993229

URL: http://svn.apache.org/viewvc?rev=993229&view=rev
Log:
remove extra log statement

Modified:
couchdb/trunk/src/couchdb/couch_httpd_view.erl

Modified: couchdb/trunk/src/couchdb/couch_httpd_view.erl
URL: 
http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_httpd_view.erl?rev=993229&r1=993228&r2=993229&view=diff
==
--- couchdb/trunk/src/couchdb/couch_httpd_view.erl (original)
+++ couchdb/trunk/src/couchdb/couch_httpd_view.erl Tue Sep  7 06:48:46 2010
@@ -321,7 +321,6 @@ warn_on_empty_key_range(#view_query_args
 ok;
 warn_on_empty_key_range(#view_query_args{
 start_key=StartKey, end_key=EndKey, direction=Dir}) ->
-?LOG_ERROR("view_query_args ~p", [{StartKey, EndKey, Dir}]),
 case {Dir, couch_view:less_json(StartKey, EndKey)} of
 {fwd, false} ->
 throw({query_parse_error,




svn commit: r993226 - in /couchdb/trunk: share/www/script/test/view_errors.js src/couchdb/couch_httpd_view.erl

2010-09-06 Thread jchris
Author: jchris
Date: Tue Sep  7 06:28:58 2010
New Revision: 993226

URL: http://svn.apache.org/viewvc?rev=993226&view=rev
Log:
warn when a view query will be empty due to backwards start and end keys

Modified:
couchdb/trunk/share/www/script/test/view_errors.js
couchdb/trunk/src/couchdb/couch_httpd_view.erl

Modified: couchdb/trunk/share/www/script/test/view_errors.js
URL: 
http://svn.apache.org/viewvc/couchdb/trunk/share/www/script/test/view_errors.js?rev=993226&r1=993225&r2=993226&view=diff
==
--- couchdb/trunk/share/www/script/test/view_errors.js (original)
+++ couchdb/trunk/share/www/script/test/view_errors.js Tue Sep  7 06:28:58 2010
@@ -158,5 +158,13 @@ couchTests.view_errors = function(debug)
   T(xhr.status == 500);
   result = JSON.parse(xhr.responseText);
   T(result.error == "reduce_overflow_error");
+
+  try {
+  db.query(function() {emit(null, null)}, null, {startkey: 2, 
endkey:1});
+  T(0 == 1);
+  } catch(e) {
+  T(e.error == "query_parse_error");
+  T(e.reason.match(/no rows can match/i));
+  }
 });
 };

Modified: couchdb/trunk/src/couchdb/couch_httpd_view.erl
URL: 
http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_httpd_view.erl?rev=993226&r1=993225&r2=993226&view=diff
==
--- couchdb/trunk/src/couchdb/couch_httpd_view.erl (original)
+++ couchdb/trunk/src/couchdb/couch_httpd_view.erl Tue Sep  7 06:28:58 2010
@@ -246,7 +246,7 @@ parse_view_params(Req, Keys, ViewType) -
 QueryArgs = lists:foldl(fun({K, V}, Args2) ->
 validate_view_query(K, V, Args2)
 end, Args, lists:reverse(QueryParams)), % Reverse to match QS order.
-
+warn_on_empty_key_range(QueryArgs),
 GroupLevel = QueryArgs#view_query_args.group_level,
 case {ViewType, GroupLevel, IsMultiGet} of
 {reduce, exact, true} ->
@@ -313,6 +313,25 @@ parse_view_param("callback", _) ->
 parse_view_param(Key, Value) ->
 [{extra, {Key, Value}}].
 
+warn_on_empty_key_range(#view_query_args{start_key=undefined}) ->
+ok;
+warn_on_empty_key_range(#view_query_args{end_key=undefined}) ->
+ok;
+warn_on_empty_key_range(#view_query_args{start_key=A, end_key=A}) ->
+ok;
+warn_on_empty_key_range(#view_query_args{
+start_key=StartKey, end_key=EndKey, direction=Dir}) ->
+?LOG_ERROR("view_query_args ~p", [{StartKey, EndKey, Dir}]),
+case {Dir, couch_view:less_json(StartKey, EndKey)} of
+{fwd, false} ->
+throw({query_parse_error,
+<<"No rows can match your key range, reverse your startkey and 
endkey or set descending=true">>});
+{rev, true} ->
+throw({query_parse_error,
+<<"No rows can match your key range, reverse your startkey and 
endkey or set descending=false">>});
+_ -> ok
+end.
+
 validate_view_query(start_key, Value, Args) ->
 case Args#view_query_args.multi_get of
 true ->




svn commit: r985407 - /couchdb/trunk/src/couchdb/couch_httpd.erl

2010-08-13 Thread jchris
Author: jchris
Date: Fri Aug 13 23:52:24 2010
New Revision: 985407

URL: http://svn.apache.org/viewvc?rev=985407&view=rev
Log:
more informative error messages on invalid json

Modified:
couchdb/trunk/src/couchdb/couch_httpd.erl

Modified: couchdb/trunk/src/couchdb/couch_httpd.erl
URL: 
http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_httpd.erl?rev=985407&r1=985406&r2=985407&view=diff
==
--- couchdb/trunk/src/couchdb/couch_httpd.erl (original)
+++ couchdb/trunk/src/couchdb/couch_httpd.erl Fri Aug 13 23:52:24 2010
@@ -289,7 +289,7 @@ handle_request_int(MochiReq, DefaultFun,
 throw:{invalid_json, S} ->
 ?LOG_ERROR("attempted upload of invalid JSON (set log_level to 
debug to log it)", []),
 ?LOG_DEBUG("Invalid JSON: ~p",[S]),
-send_error(HttpReq, {bad_request, "invalid UTF-8 JSON"});
+send_error(HttpReq, {bad_request, io_lib:format("invalid UTF-8 
JSON: ~p",[S])});
 throw:unacceptable_encoding ->
 ?LOG_ERROR("unsupported encoding method for the response", []),
 send_error(HttpReq, {not_acceptable, "unsupported encoding"});




svn commit: r983477 - /couchdb/branches/1.0.x/test/etap/160-vhosts.t

2010-08-08 Thread jchris
Author: jchris
Date: Sun Aug  8 20:00:53 2010
New Revision: 983477

URL: http://svn.apache.org/viewvc?rev=983477&view=rev
Log:
fix the db-info assertion to match with the new committed_update_seq field

Modified:
couchdb/branches/1.0.x/test/etap/160-vhosts.t

Modified: couchdb/branches/1.0.x/test/etap/160-vhosts.t
URL: 
http://svn.apache.org/viewvc/couchdb/branches/1.0.x/test/etap/160-vhosts.t?rev=983477&r1=983476&r2=983477&view=diff
==
--- couchdb/branches/1.0.x/test/etap/160-vhosts.t (original)
+++ couchdb/branches/1.0.x/test/etap/160-vhosts.t Sun Aug  8 20:00:53 2010
@@ -105,7 +105,7 @@ test_regular_request() ->
 test_vhost_request() ->
 case ibrowse:send_req(server(), [], get, [], [{host_header, 
"example.com"}]) of
 {ok, _, _, Body} ->
-{[{<<"db_name">>, <<"etap-test-db">>},_,_,_,_,_,_,_,_]}
+{[{<<"db_name">>, <<"etap-test-db">>},_,_,_,_,_,_,_,_,_]}
 = couch_util:json_decode(Body),
 etap:is(true, true, "should return database info");
 _Else -> false




svn commit: r983476 - /couchdb/trunk/test/etap/160-vhosts.t

2010-08-08 Thread jchris
Author: jchris
Date: Sun Aug  8 20:00:21 2010
New Revision: 983476

URL: http://svn.apache.org/viewvc?rev=983476&view=rev
Log:
fix the db-info assertion to match with the new committed_update_seq field

Modified:
couchdb/trunk/test/etap/160-vhosts.t

Modified: couchdb/trunk/test/etap/160-vhosts.t
URL: 
http://svn.apache.org/viewvc/couchdb/trunk/test/etap/160-vhosts.t?rev=983476&r1=983475&r2=983476&view=diff
==
--- couchdb/trunk/test/etap/160-vhosts.t (original)
+++ couchdb/trunk/test/etap/160-vhosts.t Sun Aug  8 20:00:21 2010
@@ -105,7 +105,7 @@ test_regular_request() ->
 test_vhost_request() ->
 case ibrowse:send_req(server(), [], get, [], [{host_header, 
"example.com"}]) of
 {ok, _, _, Body} ->
-{[{<<"db_name">>, <<"etap-test-db">>},_,_,_,_,_,_,_,_]}
+{[{<<"db_name">>, <<"etap-test-db">>},_,_,_,_,_,_,_,_,_]}
 = couch_util:json_decode(Body),
 etap:is(true, true, "should return database info");
 _Else -> false




svn commit: r983337 - in /couchdb/branches/1.0.x: THANKS share/www/script/test/view_update_seq.js src/couchdb/couch_httpd_db.erl src/couchdb/couch_httpd_view.erl

2010-08-07 Thread jchris
Author: jchris
Date: Sun Aug  8 02:25:40 2010
New Revision: 983337

URL: http://svn.apache.org/viewvc?rev=983337&view=rev
Log:
provide the update_seq in all_docs view even when it is zero

Modified:
couchdb/branches/1.0.x/THANKS
couchdb/branches/1.0.x/share/www/script/test/view_update_seq.js
couchdb/branches/1.0.x/src/couchdb/couch_httpd_db.erl
couchdb/branches/1.0.x/src/couchdb/couch_httpd_view.erl

Modified: couchdb/branches/1.0.x/THANKS
URL: 
http://svn.apache.org/viewvc/couchdb/branches/1.0.x/THANKS?rev=983337&r1=983336&r2=983337&view=diff
==
--- couchdb/branches/1.0.x/THANKS (original)
+++ couchdb/branches/1.0.x/THANKS Sun Aug  8 02:25:40 2010
@@ -64,5 +64,6 @@ suggesting improvements or submitting ch
  * Caleb Land 
  * Juhani Ränkimies 
  * Lim Yue Chuan 
+ * David Davis 
 
 For a list of authors see the `AUTHORS` file.

Modified: couchdb/branches/1.0.x/share/www/script/test/view_update_seq.js
URL: 
http://svn.apache.org/viewvc/couchdb/branches/1.0.x/share/www/script/test/view_update_seq.js?rev=983337&r1=983336&r2=983337&view=diff
==
--- couchdb/branches/1.0.x/share/www/script/test/view_update_seq.js (original)
+++ couchdb/branches/1.0.x/share/www/script/test/view_update_seq.js Sun Aug  8 
02:25:40 2010
@@ -18,6 +18,11 @@ couchTests.view_update_seq = function(de
 
   T(db.info().update_seq == 0);
 
+  resp = db.allDocs({update_seq:true});
+
+  T(resp.rows.length == 0);
+  T(resp.update_seq == 0);
+
   var designDoc = {
 _id:"_design/test",
 language: "javascript",
@@ -35,7 +40,7 @@ couchTests.view_update_seq = function(de
 
   T(db.info().update_seq == 1);
 
-  var resp = db.allDocs({update_seq:true});
+  resp = db.allDocs({update_seq:true});
 
   T(resp.rows.length == 1);
   T(resp.update_seq == 1);

Modified: couchdb/branches/1.0.x/src/couchdb/couch_httpd_db.erl
URL: 
http://svn.apache.org/viewvc/couchdb/branches/1.0.x/src/couchdb/couch_httpd_db.erl?rev=983337&r1=983336&r2=983337&view=diff
==
--- couchdb/branches/1.0.x/src/couchdb/couch_httpd_db.erl (original)
+++ couchdb/branches/1.0.x/src/couchdb/couch_httpd_db.erl Sun Aug  8 02:25:40 
2010
@@ -486,7 +486,13 @@ all_docs_view(Req, Db, Keys) ->
 true -> EndDocId
 end,
 FoldAccInit = {Limit, SkipCount, undefined, []},
-   UpdateSeq = couch_db:get_update_seq(Db),
+UpdateSeq = couch_db:get_update_seq(Db),
+JsonParams = case couch_httpd:qs_value(Req, "update_seq") of
+"true" ->
+[{update_seq, UpdateSeq}];
+_Else ->
+[]
+end,
 case Keys of
 nil ->
 FoldlFun = couch_httpd_view:make_view_fold_fun(Req, QueryArgs, 
CurrentEtag, Db, UpdateSeq,
@@ -504,7 +510,7 @@ all_docs_view(Req, Db, Keys) ->
 {ok, LastOffset, FoldResult} = couch_db:enum_docs(Db,
 AdapterFun, FoldAccInit, [{start_key, StartId}, {dir, Dir},
 {if Inclusive -> end_key; true -> end_key_gt end, EndId}]),
-couch_httpd_view:finish_view_fold(Req, TotalRowCount, LastOffset, 
FoldResult);
+couch_httpd_view:finish_view_fold(Req, TotalRowCount, LastOffset, 
FoldResult, JsonParams);
 _ ->
 FoldlFun = couch_httpd_view:make_view_fold_fun(Req, QueryArgs, 
CurrentEtag, Db, UpdateSeq,
 TotalRowCount, #view_fold_helper_funs{
@@ -533,7 +539,7 @@ all_docs_view(Req, Db, Keys) ->
 {_, FoldAcc2} = FoldlFun(Doc, 0, FoldAcc),
 FoldAcc2
 end, FoldAccInit, Keys),
-couch_httpd_view:finish_view_fold(Req, TotalRowCount, 0, 
FoldResult)
+couch_httpd_view:finish_view_fold(Req, TotalRowCount, 0, 
FoldResult, JsonParams)
 end
 end).
 

Modified: couchdb/branches/1.0.x/src/couchdb/couch_httpd_view.erl
URL: 
http://svn.apache.org/viewvc/couchdb/branches/1.0.x/src/couchdb/couch_httpd_view.erl?rev=983337&r1=983336&r2=983337&view=diff
==
--- couchdb/branches/1.0.x/src/couchdb/couch_httpd_view.erl (original)
+++ couchdb/branches/1.0.x/src/couchdb/couch_httpd_view.erl Sun Aug  8 02:25:40 
2010
@@ -16,7 +16,7 @@
 -export([handle_view_req/3,handle_temp_view_req/2]).
 
 -export([get_stale_type/1, get_reduce_type/1, parse_view_params/3]).
--export([make_view_fold_fun/7, finish_view_fold/4, view_row_obj/3]).
+-export([make_view_fold_fun/7, finish_view_fold/4, finish_view_fold/5, 
view_row_obj/3]).
 -export([view_group_etag/2, view_group_etag/3, make_reduce_fold_funs/6]).
 -export([design_doc_view/5, parse_bool_param/1, doc_member/2]).
 -export([make_key_options/1, load_view/4]).




svn commit: r983336 - in /couchdb/trunk: THANKS share/www/script/test/view_update_seq.js src/couchdb/couch_httpd_db.erl src/couchdb/couch_httpd_view.erl

2010-08-07 Thread jchris
Author: jchris
Date: Sun Aug  8 02:23:53 2010
New Revision: 983336

URL: http://svn.apache.org/viewvc?rev=983336&view=rev
Log:
provide the update_seq in all_docs view even when it is zero

Modified:
couchdb/trunk/THANKS
couchdb/trunk/share/www/script/test/view_update_seq.js
couchdb/trunk/src/couchdb/couch_httpd_db.erl
couchdb/trunk/src/couchdb/couch_httpd_view.erl

Modified: couchdb/trunk/THANKS
URL: 
http://svn.apache.org/viewvc/couchdb/trunk/THANKS?rev=983336&r1=983335&r2=983336&view=diff
==
--- couchdb/trunk/THANKS (original)
+++ couchdb/trunk/THANKS Sun Aug  8 02:23:53 2010
@@ -67,5 +67,6 @@ suggesting improvements or submitting ch
  * Jonathan D. Knezek 
  * David Rose 
  * Lim Yue Chuan 
+ * David Davis 
 
 For a list of authors see the `AUTHORS` file.

Modified: couchdb/trunk/share/www/script/test/view_update_seq.js
URL: 
http://svn.apache.org/viewvc/couchdb/trunk/share/www/script/test/view_update_seq.js?rev=983336&r1=983335&r2=983336&view=diff
==
--- couchdb/trunk/share/www/script/test/view_update_seq.js (original)
+++ couchdb/trunk/share/www/script/test/view_update_seq.js Sun Aug  8 02:23:53 
2010
@@ -18,6 +18,11 @@ couchTests.view_update_seq = function(de
 
   T(db.info().update_seq == 0);
 
+  resp = db.allDocs({update_seq:true});
+
+  T(resp.rows.length == 0);
+  T(resp.update_seq == 0);
+
   var designDoc = {
 _id:"_design/test",
 language: "javascript",
@@ -35,7 +40,7 @@ couchTests.view_update_seq = function(de
 
   T(db.info().update_seq == 1);
 
-  var resp = db.allDocs({update_seq:true});
+  resp = db.allDocs({update_seq:true});
 
   T(resp.rows.length == 1);
   T(resp.update_seq == 1);

Modified: couchdb/trunk/src/couchdb/couch_httpd_db.erl
URL: 
http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_httpd_db.erl?rev=983336&r1=983335&r2=983336&view=diff
==
--- couchdb/trunk/src/couchdb/couch_httpd_db.erl (original)
+++ couchdb/trunk/src/couchdb/couch_httpd_db.erl Sun Aug  8 02:23:53 2010
@@ -486,7 +486,13 @@ all_docs_view(Req, Db, Keys) ->
 true -> EndDocId
 end,
 FoldAccInit = {Limit, SkipCount, undefined, []},
-   UpdateSeq = couch_db:get_update_seq(Db),
+UpdateSeq = couch_db:get_update_seq(Db),
+JsonParams = case couch_httpd:qs_value(Req, "update_seq") of
+"true" ->
+[{update_seq, UpdateSeq}];
+_Else ->
+[]
+end,
 case Keys of
 nil ->
 FoldlFun = couch_httpd_view:make_view_fold_fun(Req, QueryArgs, 
CurrentEtag, Db, UpdateSeq,
@@ -504,7 +510,7 @@ all_docs_view(Req, Db, Keys) ->
 {ok, LastOffset, FoldResult} = couch_db:enum_docs(Db,
 AdapterFun, FoldAccInit, [{start_key, StartId}, {dir, Dir},
 {if Inclusive -> end_key; true -> end_key_gt end, EndId}]),
-couch_httpd_view:finish_view_fold(Req, TotalRowCount, LastOffset, 
FoldResult);
+couch_httpd_view:finish_view_fold(Req, TotalRowCount, LastOffset, 
FoldResult, JsonParams);
 _ ->
 FoldlFun = couch_httpd_view:make_view_fold_fun(Req, QueryArgs, 
CurrentEtag, Db, UpdateSeq,
 TotalRowCount, #view_fold_helper_funs{
@@ -533,7 +539,7 @@ all_docs_view(Req, Db, Keys) ->
 {_, FoldAcc2} = FoldlFun(Doc, 0, FoldAcc),
 FoldAcc2
 end, FoldAccInit, Keys),
-couch_httpd_view:finish_view_fold(Req, TotalRowCount, 0, 
FoldResult)
+couch_httpd_view:finish_view_fold(Req, TotalRowCount, 0, 
FoldResult, JsonParams)
 end
 end).
 

Modified: couchdb/trunk/src/couchdb/couch_httpd_view.erl
URL: 
http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_httpd_view.erl?rev=983336&r1=983335&r2=983336&view=diff
==
--- couchdb/trunk/src/couchdb/couch_httpd_view.erl (original)
+++ couchdb/trunk/src/couchdb/couch_httpd_view.erl Sun Aug  8 02:23:53 2010
@@ -16,7 +16,7 @@
 -export([handle_view_req/3,handle_temp_view_req/2]).
 
 -export([parse_view_params/3]).
--export([make_view_fold_fun/7, finish_view_fold/4, view_row_obj/3]).
+-export([make_view_fold_fun/7, finish_view_fold/4, finish_view_fold/5, 
view_row_obj/3]).
 -export([view_group_etag/2, view_group_etag/3, make_reduce_fold_funs/6]).
 -export([design_doc_view/5, parse_bool_param/1, doc_member/2]).
 -export([make_key_options/1, load_view/4]).




svn commit: r983307 - in /couchdb/branches/1.0.x: THANKS share/www/script/test/reduce_builtin.js src/couchdb/couch_query_servers.erl

2010-08-07 Thread jchris
Author: jchris
Date: Sat Aug  7 20:33:33 2010
New Revision: 983307

URL: http://svn.apache.org/viewvc?rev=983307&view=rev
Log:
builtin reduce functions more forgiving about trailing whitespace and other 
characters

Modified:
couchdb/branches/1.0.x/THANKS
couchdb/branches/1.0.x/share/www/script/test/reduce_builtin.js
couchdb/branches/1.0.x/src/couchdb/couch_query_servers.erl

Modified: couchdb/branches/1.0.x/THANKS
URL: 
http://svn.apache.org/viewvc/couchdb/branches/1.0.x/THANKS?rev=983307&r1=983306&r2=983307&view=diff
==
--- couchdb/branches/1.0.x/THANKS (original)
+++ couchdb/branches/1.0.x/THANKS Sat Aug  7 20:33:33 2010
@@ -63,5 +63,6 @@ suggesting improvements or submitting ch
  * Paul Bonser 
  * Caleb Land 
  * Juhani Ränkimies 
+ * Lim Yue Chuan 
 
 For a list of authors see the `AUTHORS` file.

Modified: couchdb/branches/1.0.x/share/www/script/test/reduce_builtin.js
URL: 
http://svn.apache.org/viewvc/couchdb/branches/1.0.x/share/www/script/test/reduce_builtin.js?rev=983307&r1=983306&r2=983307&view=diff
==
--- couchdb/branches/1.0.x/share/www/script/test/reduce_builtin.js (original)
+++ couchdb/branches/1.0.x/share/www/script/test/reduce_builtin.js Sat Aug  7 
20:33:33 2010
@@ -72,6 +72,26 @@ couchTests.reduce_builtin = function(deb
 T(result.rows[0].value == 2*(summate(numDocs-i) - summate(i-1)));
   }
 
+  // test for trailing characters after builtin functions, desired behaviour
+  // is to disregard any trailing characters
+  // I think the behavior should be a prefix test, so that even "_statsorama" 
+  // or "_stats\nare\awesome" should work just as "_stats" does. - JChris
+
+  var trailing = ["\u000a", "orama", "\nare\nawesome", " ", " \n  "];
+
+  for(var i=0; i < trailing.length; i++) {
+result = db.query(map, "_sum" + trailing[i]);
+T(result.rows[0].value == 2*summate(numDocs));
+result = db.query(map, "_count" + trailing[i]);
+T(result.rows[0].value == 1000);
+result = db.query(map, "_stats" + trailing[i]);
+T(result.rows[0].value.sum == 2*summate(numDocs));
+T(result.rows[0].value.count == 1000);
+T(result.rows[0].value.min == 1);
+T(result.rows[0].value.max == 500);
+T(result.rows[0].value.sumsqr == 2*sumsqr(numDocs));
+  }
+
   db.deleteDb();
   db.createDb();
 

Modified: couchdb/branches/1.0.x/src/couchdb/couch_query_servers.erl
URL: 
http://svn.apache.org/viewvc/couchdb/branches/1.0.x/src/couchdb/couch_query_servers.erl?rev=983307&r1=983306&r2=983307&view=diff
==
--- couchdb/branches/1.0.x/src/couchdb/couch_query_servers.erl (original)
+++ couchdb/branches/1.0.x/src/couchdb/couch_query_servers.erl Sat Aug  7 
20:33:33 2010
@@ -143,16 +143,16 @@ os_rereduce(Lang, OsRedSrcs, KVs) ->
 
 builtin_reduce(_Re, [], _KVs, Acc) ->
 {ok, lists:reverse(Acc)};
-builtin_reduce(Re, [<<"_sum">>|BuiltinReds], KVs, Acc) ->
+builtin_reduce(Re, [<<"_sum",_/binary>>|BuiltinReds], KVs, Acc) ->
 Sum = builtin_sum_rows(KVs),
 builtin_reduce(Re, BuiltinReds, KVs, [Sum|Acc]);
-builtin_reduce(reduce, [<<"_count">>|BuiltinReds], KVs, Acc) ->
+builtin_reduce(reduce, [<<"_count",_/binary>>|BuiltinReds], KVs, Acc) ->
 Count = length(KVs),
 builtin_reduce(reduce, BuiltinReds, KVs, [Count|Acc]);
-builtin_reduce(rereduce, [<<"_count">>|BuiltinReds], KVs, Acc) ->
+builtin_reduce(rereduce, [<<"_count",_/binary>>|BuiltinReds], KVs, Acc) ->
 Count = builtin_sum_rows(KVs),
 builtin_reduce(rereduce, BuiltinReds, KVs, [Count|Acc]);
-builtin_reduce(Re, [<<"_stats">>|BuiltinReds], KVs, Acc) ->
+builtin_reduce(Re, [<<"_stats",_/binary>>|BuiltinReds], KVs, Acc) ->
 Stats = builtin_stats(Re, KVs),
 builtin_reduce(Re, BuiltinReds, KVs, [Stats|Acc]).
 




svn commit: r983306 - in /couchdb/trunk: THANKS share/www/script/test/reduce_builtin.js src/couchdb/couch_query_servers.erl

2010-08-07 Thread jchris
Author: jchris
Date: Sat Aug  7 20:31:25 2010
New Revision: 983306

URL: http://svn.apache.org/viewvc?rev=983306&view=rev
Log:
builtin reduce functions more forgiving about trailing whitespace and other 
characters

Modified:
couchdb/trunk/THANKS
couchdb/trunk/share/www/script/test/reduce_builtin.js
couchdb/trunk/src/couchdb/couch_query_servers.erl

Modified: couchdb/trunk/THANKS
URL: 
http://svn.apache.org/viewvc/couchdb/trunk/THANKS?rev=983306&r1=983305&r2=983306&view=diff
==
--- couchdb/trunk/THANKS (original)
+++ couchdb/trunk/THANKS Sat Aug  7 20:31:25 2010
@@ -66,5 +66,6 @@ suggesting improvements or submitting ch
  * Kev Jackson 
  * Jonathan D. Knezek 
  * David Rose 
+ * Lim Yue Chuan 
 
 For a list of authors see the `AUTHORS` file.

Modified: couchdb/trunk/share/www/script/test/reduce_builtin.js
URL: 
http://svn.apache.org/viewvc/couchdb/trunk/share/www/script/test/reduce_builtin.js?rev=983306&r1=983305&r2=983306&view=diff
==
--- couchdb/trunk/share/www/script/test/reduce_builtin.js (original)
+++ couchdb/trunk/share/www/script/test/reduce_builtin.js Sat Aug  7 20:31:25 
2010
@@ -72,6 +72,26 @@ couchTests.reduce_builtin = function(deb
 T(result.rows[0].value == 2*(summate(numDocs-i) - summate(i-1)));
   }
 
+  // test for trailing characters after builtin functions, desired behaviour
+  // is to disregard any trailing characters
+  // I think the behavior should be a prefix test, so that even "_statsorama" 
+  // or "_stats\nare\awesome" should work just as "_stats" does. - JChris
+
+  var trailing = ["\u000a", "orama", "\nare\nawesome", " ", " \n  "];
+
+  for(var i=0; i < trailing.length; i++) {
+result = db.query(map, "_sum" + trailing[i]);
+T(result.rows[0].value == 2*summate(numDocs));
+result = db.query(map, "_count" + trailing[i]);
+T(result.rows[0].value == 1000);
+result = db.query(map, "_stats" + trailing[i]);
+T(result.rows[0].value.sum == 2*summate(numDocs));
+T(result.rows[0].value.count == 1000);
+T(result.rows[0].value.min == 1);
+T(result.rows[0].value.max == 500);
+T(result.rows[0].value.sumsqr == 2*sumsqr(numDocs));
+  }
+
   db.deleteDb();
   db.createDb();
 

Modified: couchdb/trunk/src/couchdb/couch_query_servers.erl
URL: 
http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_query_servers.erl?rev=983306&r1=983305&r2=983306&view=diff
==
--- couchdb/trunk/src/couchdb/couch_query_servers.erl (original)
+++ couchdb/trunk/src/couchdb/couch_query_servers.erl Sat Aug  7 20:31:25 2010
@@ -150,16 +150,16 @@ os_rereduce(Lang, OsRedSrcs, KVs) ->
 
 builtin_reduce(_Re, [], _KVs, Acc) ->
 {ok, lists:reverse(Acc)};
-builtin_reduce(Re, [<<"_sum">>|BuiltinReds], KVs, Acc) ->
+builtin_reduce(Re, [<<"_sum",_/binary>>|BuiltinReds], KVs, Acc) ->
 Sum = builtin_sum_rows(KVs),
 builtin_reduce(Re, BuiltinReds, KVs, [Sum|Acc]);
-builtin_reduce(reduce, [<<"_count">>|BuiltinReds], KVs, Acc) ->
+builtin_reduce(reduce, [<<"_count",_/binary>>|BuiltinReds], KVs, Acc) ->
 Count = length(KVs),
 builtin_reduce(reduce, BuiltinReds, KVs, [Count|Acc]);
-builtin_reduce(rereduce, [<<"_count">>|BuiltinReds], KVs, Acc) ->
+builtin_reduce(rereduce, [<<"_count",_/binary>>|BuiltinReds], KVs, Acc) ->
 Count = builtin_sum_rows(KVs),
 builtin_reduce(rereduce, BuiltinReds, KVs, [Count|Acc]);
-builtin_reduce(Re, [<<"_stats">>|BuiltinReds], KVs, Acc) ->
+builtin_reduce(Re, [<<"_stats",_/binary>>|BuiltinReds], KVs, Acc) ->
 Stats = builtin_stats(Re, KVs),
 builtin_reduce(Re, BuiltinReds, KVs, [Stats|Acc]).
 




svn commit: r983291 - in /couchdb/trunk: etc/couchdb/default.ini.tpl.in src/couchdb/couch_query_servers.erl

2010-08-07 Thread jchris
Author: jchris
Date: Sat Aug  7 19:26:50 2010
New Revision: 983291

URL: http://svn.apache.org/viewvc?rev=983291&view=rev
Log:
os_process_limit for query servers make them much more robust under concurrent 
load

Modified:
couchdb/trunk/etc/couchdb/default.ini.tpl.in
couchdb/trunk/src/couchdb/couch_query_servers.erl

Modified: couchdb/trunk/etc/couchdb/default.ini.tpl.in
URL: 
http://svn.apache.org/viewvc/couchdb/trunk/etc/couchdb/default.ini.tpl.in?rev=983291&r1=983290&r2=983291&view=diff
==
--- couchdb/trunk/etc/couchdb/default.ini.tpl.in (original)
+++ couchdb/trunk/etc/couchdb/default.ini.tpl.in Sat Aug  7 19:26:50 2010
@@ -46,6 +46,7 @@ javascript = %bindir%/%couchjs_command_n
 ; please let us know on the mailing list so we can fine tune the heuristic.
 [query_server_config]
 reduce_limit = true
+os_process_limit = 25
 
 ; enable external as an httpd handler, then link it with commands here.
 ; note, this api is still under consideration.

Modified: couchdb/trunk/src/couchdb/couch_query_servers.erl
URL: 
http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_query_servers.erl?rev=983291&r1=983290&r2=983291&view=diff
==
--- couchdb/trunk/src/couchdb/couch_query_servers.erl (original)
+++ couchdb/trunk/src/couchdb/couch_query_servers.erl Sat Aug  7 19:26:50 2010
@@ -35,6 +35,15 @@
 stop_fun
 }).
 
+-record(qserver, {
+langs, % Keyed by language name, value is {Mod,Func,Arg}
+pid_procs, % Keyed by PID, valus is a #proc record.
+lang_procs, % Keyed by language name, value is a #proc record
+lang_limits, % Keyed by language name, value is {Lang, Limit, Current}
+waitlist = [],
+config
+}).
+
 start_link() ->
 gen_server:start_link({local, couch_query_servers}, couch_query_servers, 
[], []).
 
@@ -242,81 +251,97 @@ init([]) ->
 supervisor:terminate_child(couch_secondary_services, 
query_servers),
 [supervisor:restart_child(couch_secondary_services, query_servers)]
 end),
+ok = couch_config:register(
+fun("query_server_config" ++ _, _) ->
+supervisor:terminate_child(couch_secondary_services, 
query_servers),
+supervisor:restart_child(couch_secondary_services, query_servers)
+end),
 
 Langs = ets:new(couch_query_server_langs, [set, private]),
+LangLimits = ets:new(couch_query_server_lang_limits, [set, private]),
 PidProcs = ets:new(couch_query_server_pid_langs, [set, private]),
 LangProcs = ets:new(couch_query_server_procs, [set, private]),
+
+ProcTimeout = list_to_integer(couch_config:get(
+"couchdb", "os_process_timeout", "5000")),
+ReduceLimit = list_to_atom(
+couch_config:get("query_server_config","reduce_limit","true")),
+OsProcLimit = list_to_integer(
+couch_config:get("query_server_config","os_process_limit","10")),
+
 % 'query_servers' specifies an OS command-line to execute.
 lists:foreach(fun({Lang, Command}) ->
+true = ets:insert(LangLimits, {?l2b(Lang), OsProcLimit, 0}),
 true = ets:insert(Langs, {?l2b(Lang),
   couch_os_process, start_link, [Command]})
 end, couch_config:get("query_servers")),
 % 'native_query_servers' specifies a {Module, Func, Arg} tuple.
 lists:foreach(fun({Lang, SpecStr}) ->
 {ok, {Mod, Fun, SpecArg}} = couch_util:parse_term(SpecStr),
+true = ets:insert(LangLimits, {?l2b(Lang), 0, 0}), % 0 means no limit
 true = ets:insert(Langs, {?l2b(Lang),
   Mod, Fun, SpecArg})
 end, couch_config:get("native_query_servers")),
+
+
 process_flag(trap_exit, true),
-{ok, {Langs, % Keyed by language name, value is {Mod,Func,Arg}
-  PidProcs, % Keyed by PID, valus is a #proc record.
-  LangProcs % Keyed by language name, value is a #proc record
-  }}.
+{ok, #qserver{
+langs = Langs, % Keyed by language name, value is {Mod,Func,Arg}
+pid_procs = PidProcs, % Keyed by PID, valus is a #proc record.
+lang_procs = LangProcs, % Keyed by language name, value is a #proc 
record
+lang_limits = LangLimits, % Keyed by language name, value is {Lang, 
Limit, Current}
+config = {[{<<"reduce_limit">>, ReduceLimit},{<<"timeout">>, 
ProcTimeout}]}
+}}.
 
-terminate(_Reason, {_Langs, PidProcs, _LangProcs}) ->
+terminate(_Reason, #qserver{pid_procs=PidProcs}) ->
 [couch_util:shutdown_sync(P) || {P,_} <- ets:tab2list(PidProcs)],
 ok.
 
-handle_call({get_proc, #doc{body={Props}}=DDoc, DDocKey}, _From, {Langs, 
PidProcs, LangProcs}=Server) ->
-  

svn commit: r982027 - in /couchdb/branches/0.11.x: CHANGES NEWS

2010-08-03 Thread jchris
Author: jchris
Date: Tue Aug  3 20:32:48 2010
New Revision: 982027

URL: http://svn.apache.org/viewvc?rev=982027&view=rev
Log:
NEWS and CHANGES for 0.11.2

Modified:
couchdb/branches/0.11.x/CHANGES
couchdb/branches/0.11.x/NEWS

Modified: couchdb/branches/0.11.x/CHANGES
URL: 
http://svn.apache.org/viewvc/couchdb/branches/0.11.x/CHANGES?rev=982027&r1=982026&r2=982027&view=diff
==
--- couchdb/branches/0.11.x/CHANGES (original)
+++ couchdb/branches/0.11.x/CHANGES Tue Aug  3 20:32:48 2010
@@ -1,6 +1,32 @@
 Apache CouchDB CHANGES
 ==
 
+Version 0.11.2
+--
+
+Replicator:
+
+  * Fix bug when pushing design docs by non-admins, which was hanging the 
+replicator for no good reason.
+  * Fix bug when pulling design documents from a source that requires 
+basic-auth.
+
+HTTP Interface:
+
+  * Better error messages on invalid URL requests.
+
+Authentication:
+
+  * User documents can now be deleted by admins or the user.
+
+Security:
+
+  * Avoid potential DOS attack by guarding all creation of atoms.
+  
+Futon:
+
+  * Add some Futon files that were missing from the Makefile.
+
 Version 0.11.1
 --
 

Modified: couchdb/branches/0.11.x/NEWS
URL: 
http://svn.apache.org/viewvc/couchdb/branches/0.11.x/NEWS?rev=982027&r1=982026&r2=982027&view=diff
==
--- couchdb/branches/0.11.x/NEWS (original)
+++ couchdb/branches/0.11.x/NEWS Tue Aug  3 20:32:48 2010
@@ -7,6 +7,15 @@ For details about backwards incompatible
 
 Each release section notes when backwards incompatible changes have been made.
 
+Version 0.11.2
+--
+
+  * Replicator buxfixes for replicating design documents from secured 
databases.
+  * Better error messages on invalid URL requests.
+  * User documents can now be deleted by admins or the user.
+  * Avoid potential DOS attack by guarding all creation of atoms.
+  * Some Futon and JavaScript library bugfixes.
+
 Version 0.11.1
 --
 




svn commit: r982026 - in /couchdb/branches/1.0.x: CHANGES NEWS

2010-08-03 Thread jchris
Author: jchris
Date: Tue Aug  3 20:27:32 2010
New Revision: 982026

URL: http://svn.apache.org/viewvc?rev=982026&view=rev
Log:
fix silly typo in news and changes

Modified:
couchdb/branches/1.0.x/CHANGES
couchdb/branches/1.0.x/NEWS

Modified: couchdb/branches/1.0.x/CHANGES
URL: 
http://svn.apache.org/viewvc/couchdb/branches/1.0.x/CHANGES?rev=982026&r1=982025&r2=982026&view=diff
==
--- couchdb/branches/1.0.x/CHANGES (original)
+++ couchdb/branches/1.0.x/CHANGES Tue Aug  3 20:27:32 2010
@@ -17,12 +17,12 @@ Replicator:
 HTTP Interface:
 
   * Show fields saved along with _deleted=true. Allows for auditing of deletes.
-  * Better error messages on bad URL requests.
+  * Better error messages on invalid URL requests.
   * More robust Accept-header detection.
 
 Authentication:
 
-  * Anable basic-auth popup when required to access the server, to prevent
+  * Enable basic-auth popup when required to access the server, to prevent
 people from getting locked out.
   * User documents can now be deleted by admins or the user.
 

Modified: couchdb/branches/1.0.x/NEWS
URL: 
http://svn.apache.org/viewvc/couchdb/branches/1.0.x/NEWS?rev=982026&r1=982025&r2=982026&view=diff
==
--- couchdb/branches/1.0.x/NEWS (original)
+++ couchdb/branches/1.0.x/NEWS Tue Aug  3 20:27:32 2010
@@ -14,8 +14,8 @@ Version 1.0.1
   * Fixed various replicator bugs for security and interop with older CouchDB 
 versions.
   * Show fields saved along with _deleted=true. Allows for auditing of deletes.
-  * Better error messages on bad URL requests.
-  * Anable basic-auth popup when required to access the server, to prevent
+  * Better error messages on invalid URL requests.
+  * Enable basic-auth popup when required to access the server, to prevent
 people from getting locked out.
   * Avoid potential DOS attack by guarding all creation of atoms.
   * User interface element for querying stale (cached) views.




svn commit: r982025 - in /couchdb/branches/1.0.x: CHANGES NEWS

2010-08-03 Thread jchris
Author: jchris
Date: Tue Aug  3 20:24:01 2010
New Revision: 982025

URL: http://svn.apache.org/viewvc?rev=982025&view=rev
Log:
update NEWS and CHANGES for 1.0.1 release

Modified:
couchdb/branches/1.0.x/CHANGES
couchdb/branches/1.0.x/NEWS

Modified: couchdb/branches/1.0.x/CHANGES
URL: 
http://svn.apache.org/viewvc/couchdb/branches/1.0.x/CHANGES?rev=982025&r1=982024&r2=982025&view=diff
==
--- couchdb/branches/1.0.x/CHANGES (original)
+++ couchdb/branches/1.0.x/CHANGES Tue Aug  3 20:24:01 2010
@@ -1,6 +1,40 @@
 Apache CouchDB CHANGES
 ==
 
+Version 1.0.1
+-
+
+Replicator:
+
+  * Added support for replication via an HTTP/HTTP proxy.
+  * Fix bug when pushing design docs by non-admins, which was hanging the 
+replicator for no good reason.
+  * Fix bug when pulling design documents from a source that requires 
+basic-auth.
+  * Fix pull replication of attachments from 0.11 to 1.0.x
+  * Make the _changes feed work with non-integer seqnums.
+
+HTTP Interface:
+
+  * Show fields saved along with _deleted=true. Allows for auditing of deletes.
+  * Better error messages on bad URL requests.
+  * More robust Accept-header detection.
+
+Authentication:
+
+  * Anable basic-auth popup when required to access the server, to prevent
+people from getting locked out.
+  * User documents can now be deleted by admins or the user.
+
+Security:
+
+  * Avoid potential DOS attack by guarding all creation of atoms.
+  
+Futon:
+
+  * Add some Futon files that were missing from the Makefile.
+  * User interface element for querying stale (cached) views.
+
 Version 1.0.0
 -
 

Modified: couchdb/branches/1.0.x/NEWS
URL: 
http://svn.apache.org/viewvc/couchdb/branches/1.0.x/NEWS?rev=982025&r1=982024&r2=982025&view=diff
==
--- couchdb/branches/1.0.x/NEWS (original)
+++ couchdb/branches/1.0.x/NEWS Tue Aug  3 20:24:01 2010
@@ -7,6 +7,19 @@ For details about backwards incompatible
 
 Each release section notes when backwards incompatible changes have been made.
 
+Version 1.0.1
+-
+
+  * Added support for replication via an HTTP/HTTP proxy.
+  * Fixed various replicator bugs for security and interop with older CouchDB 
+versions.
+  * Show fields saved along with _deleted=true. Allows for auditing of deletes.
+  * Better error messages on bad URL requests.
+  * Anable basic-auth popup when required to access the server, to prevent
+people from getting locked out.
+  * Avoid potential DOS attack by guarding all creation of atoms.
+  * User interface element for querying stale (cached) views.
+
 Version 1.0.0
 -
 




svn commit: r982002 - /couchdb/branches/1.0.x/src/couchdb/couch_rep.erl

2010-08-03 Thread jchris
Author: jchris
Date: Tue Aug  3 18:50:50 2010
New Revision: 982002

URL: http://svn.apache.org/viewvc?rev=982002&view=rev
Log:
Add support for replication through an HTTP/HTTPS proxy.

backported from trunk r980985

Modified:
couchdb/branches/1.0.x/src/couchdb/couch_rep.erl

Modified: couchdb/branches/1.0.x/src/couchdb/couch_rep.erl
URL: 
http://svn.apache.org/viewvc/couchdb/branches/1.0.x/src/couchdb/couch_rep.erl?rev=982002&r1=982001&r2=982002&view=diff
==
--- couchdb/branches/1.0.x/src/couchdb/couch_rep.erl (original)
+++ couchdb/branches/1.0.x/src/couchdb/couch_rep.erl Tue Aug  3 18:50:50 2010
@@ -118,8 +118,10 @@ do_init([RepId, {PostProps}, UserCtx] = 
 Continuous = couch_util:get_value(<<"continuous">>, PostProps, false),
 CreateTarget = couch_util:get_value(<<"create_target">>, PostProps, false),
 
-Source = open_db(SourceProps, UserCtx),
-Target = open_db(TargetProps, UserCtx, CreateTarget),
+ProxyParams = parse_proxy_params(
+couch_util:get_value(<<"proxy">>, PostProps, [])),
+Source = open_db(SourceProps, UserCtx, ProxyParams),
+Target = open_db(TargetProps, UserCtx, ProxyParams, CreateTarget),
 
 SourceInfo = dbinfo(Source),
 TargetInfo = dbinfo(Target),
@@ -517,26 +519,27 @@ open_replication_log(Db, RepId) ->
 #doc{id=DocId}
 end.
 
-open_db(Props, UserCtx) ->
-open_db(Props, UserCtx, false).
+open_db(Props, UserCtx, ProxyParams) ->
+open_db(Props, UserCtx, ProxyParams, false).
 
-open_db({Props}, _UserCtx, CreateTarget) ->
+open_db({Props}, _UserCtx, ProxyParams, CreateTarget) ->
 Url = maybe_add_trailing_slash(couch_util:get_value(<<"url">>, Props)),
 {AuthProps} = couch_util:get_value(<<"auth">>, Props, {[]}),
 {BinHeaders} = couch_util:get_value(<<"headers">>, Props, {[]}),
 Headers = [{?b2l(K),?b2l(V)} || {K,V} <- BinHeaders],
 DefaultHeaders = (#http_db{})#http_db.headers,
-Db = #http_db{
+Db1 = #http_db{
 url = Url,
 auth = AuthProps,
 headers = lists:ukeymerge(1, Headers, DefaultHeaders)
 },
+Db = Db1#http_db{options = Db1#http_db.options ++ ProxyParams},
 couch_rep_httpc:db_exists(Db, CreateTarget);
-open_db(<<"http://",_/binary>>=Url, _, CreateTarget) ->
-open_db({[{<<"url">>,Url}]}, [], CreateTarget);
-open_db(<<"https://",_/binary>>=Url, _, CreateTarget) ->
-open_db({[{<<"url">>,Url}]}, [], CreateTarget);
-open_db(<>, UserCtx, CreateTarget) ->
+open_db(<<"http://",_/binary>>=Url, _, ProxyParams, CreateTarget) ->
+open_db({[{<<"url">>,Url}]}, [], ProxyParams, CreateTarget);
+open_db(<<"https://",_/binary>>=Url, _, ProxyParams, CreateTarget) ->
+open_db({[{<<"url">>,Url}]}, [], ProxyParams, CreateTarget);
+open_db(<>, UserCtx, _ProxyParams, CreateTarget) ->
 case CreateTarget of
 true ->
 ok = couch_httpd:verify_is_server_admin(UserCtx),
@@ -728,3 +731,18 @@ up_to_date(Source, Seq) ->
 T = NewDb#db.update_seq == Seq,
 couch_db:close(NewDb),
 T.
+
+parse_proxy_params(ProxyUrl) when is_binary(ProxyUrl) ->
+parse_proxy_params(?b2l(ProxyUrl));
+parse_proxy_params([]) ->
+[];
+parse_proxy_params(ProxyUrl) ->
+{url, _, Base, Port, User, Passwd, _Path, _Proto} =
+ibrowse_lib:parse_url(ProxyUrl),
+[{proxy_host, Base}, {proxy_port, Port}] ++
+case is_list(User) andalso is_list(Passwd) of
+false ->
+[];
+true ->
+[{proxy_user, User}, {proxy_password, Passwd}]
+end.




svn commit: r980985 - /couchdb/trunk/src/couchdb/couch_rep.erl

2010-07-30 Thread jchris
Author: jchris
Date: Fri Jul 30 22:35:40 2010
New Revision: 980985

URL: http://svn.apache.org/viewvc?rev=980985&view=rev
Log:
Add support for replication through an HTTP/HTTPS proxy.

Modified:
couchdb/trunk/src/couchdb/couch_rep.erl

Modified: couchdb/trunk/src/couchdb/couch_rep.erl
URL: 
http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_rep.erl?rev=980985&r1=980984&r2=980985&view=diff
==
--- couchdb/trunk/src/couchdb/couch_rep.erl (original)
+++ couchdb/trunk/src/couchdb/couch_rep.erl Fri Jul 30 22:35:40 2010
@@ -122,8 +122,10 @@ do_init([RepId, {PostProps}, UserCtx] = 
 Continuous = couch_util:get_value(<<"continuous">>, PostProps, false),
 CreateTarget = couch_util:get_value(<<"create_target">>, PostProps, false),
 
-Source = open_db(SourceProps, UserCtx),
-Target = open_db(TargetProps, UserCtx, CreateTarget),
+ProxyParams = parse_proxy_params(
+couch_util:get_value(<<"proxy">>, PostProps, [])),
+Source = open_db(SourceProps, UserCtx, ProxyParams),
+Target = open_db(TargetProps, UserCtx, ProxyParams, CreateTarget),
 
 SourceInfo = dbinfo(Source),
 TargetInfo = dbinfo(Target),
@@ -554,26 +556,27 @@ open_replication_log(Db, DocId) ->
 {error, not_found}
 end.
 
-open_db(Props, UserCtx) ->
-open_db(Props, UserCtx, false).
+open_db(Props, UserCtx, ProxyParams) ->
+open_db(Props, UserCtx, ProxyParams, false).
 
-open_db({Props}, _UserCtx, CreateTarget) ->
+open_db({Props}, _UserCtx, ProxyParams, CreateTarget) ->
 Url = maybe_add_trailing_slash(couch_util:get_value(<<"url">>, Props)),
 {AuthProps} = couch_util:get_value(<<"auth">>, Props, {[]}),
 {BinHeaders} = couch_util:get_value(<<"headers">>, Props, {[]}),
 Headers = [{?b2l(K),?b2l(V)} || {K,V} <- BinHeaders],
 DefaultHeaders = (#http_db{})#http_db.headers,
-Db = #http_db{
+Db1 = #http_db{
 url = Url,
 auth = AuthProps,
 headers = lists:ukeymerge(1, Headers, DefaultHeaders)
 },
+Db = Db1#http_db{options = Db1#http_db.options ++ ProxyParams},
 couch_rep_httpc:db_exists(Db, CreateTarget);
-open_db(<<"http://",_/binary>>=Url, _, CreateTarget) ->
-open_db({[{<<"url">>,Url}]}, [], CreateTarget);
-open_db(<<"https://",_/binary>>=Url, _, CreateTarget) ->
-open_db({[{<<"url">>,Url}]}, [], CreateTarget);
-open_db(<>, UserCtx, CreateTarget) ->
+open_db(<<"http://",_/binary>>=Url, _, ProxyParams, CreateTarget) ->
+open_db({[{<<"url">>,Url}]}, [], ProxyParams, CreateTarget);
+open_db(<<"https://",_/binary>>=Url, _, ProxyParams, CreateTarget) ->
+open_db({[{<<"url">>,Url}]}, [], ProxyParams, CreateTarget);
+open_db(<>, UserCtx, _ProxyParams, CreateTarget) ->
 case CreateTarget of
 true ->
 ok = couch_httpd:verify_is_server_admin(UserCtx),
@@ -765,3 +768,18 @@ up_to_date(Source, Seq) ->
 T = NewDb#db.update_seq == Seq,
 couch_db:close(NewDb),
 T.
+
+parse_proxy_params(ProxyUrl) when is_binary(ProxyUrl) ->
+parse_proxy_params(?b2l(ProxyUrl));
+parse_proxy_params([]) ->
+[];
+parse_proxy_params(ProxyUrl) ->
+{url, _, Base, Port, User, Passwd, _Path, _Proto} =
+ibrowse_lib:parse_url(ProxyUrl),
+[{proxy_host, Base}, {proxy_port, Port}] ++
+case is_list(User) andalso is_list(Passwd) of
+false ->
+[];
+true ->
+[{proxy_user, User}, {proxy_password, Passwd}]
+end.




svn commit: r980321 - in /couchdb/branches/0.11.x: share/www/script/test/security_validation.js src/couchdb/couch_db.erl

2010-07-28 Thread jchris
Author: jchris
Date: Thu Jul 29 06:09:00 2010
New Revision: 980321

URL: http://svn.apache.org/viewvc?rev=980321&view=rev
Log:
fix the underlying issue that was giving replication problems attempting to 
push design docs as a non-admin. this is what my reverted commit should have 
been

Modified:
couchdb/branches/0.11.x/share/www/script/test/security_validation.js
couchdb/branches/0.11.x/src/couchdb/couch_db.erl

Modified: couchdb/branches/0.11.x/share/www/script/test/security_validation.js
URL: 
http://svn.apache.org/viewvc/couchdb/branches/0.11.x/share/www/script/test/security_validation.js?rev=980321&r1=980320&r2=980321&view=diff
==
--- couchdb/branches/0.11.x/share/www/script/test/security_validation.js 
(original)
+++ couchdb/branches/0.11.x/share/www/script/test/security_validation.js Thu 
Jul 29 06:09:00 2010
@@ -111,6 +111,18 @@ couchTests.security_validation = functio
 
   T(userDb.save(designDoc).ok);
 
+  var user2Db = new CouchDB("test_suite_db",
+{"WWW-Authenticate": "X-Couch-Test-Auth Jan Lehnardt:apple"}
+  );
+  // Attempt to save the design as a non-admin (in replication scenario)
+  try {
+user2Db.save(designDoc, {new_edits : false});
+T(false && "Can't get here. Should have thrown an error on design 
doc");
+  } catch (e) {
+T(e.error == "unauthorized");
+T(user2Db.last_req.status == 401);
+  }
+
   // test the _session API
   var resp = userDb.request("GET", "/_session");
   var user = JSON.parse(resp.responseText).userCtx;
@@ -134,10 +146,6 @@ couchTests.security_validation = functio
   }
 
   // Now attempt to update the document as a different user, Jan
-  var user2Db = new CouchDB("test_suite_db",
-{"WWW-Authenticate": "X-Couch-Test-Auth Jan Lehnardt:apple"}
-  );
-
   var doc = user2Db.open("testdoc");
   doc.foo=3;
   try {

Modified: couchdb/branches/0.11.x/src/couchdb/couch_db.erl
URL: 
http://svn.apache.org/viewvc/couchdb/branches/0.11.x/src/couchdb/couch_db.erl?rev=980321&r1=980320&r2=980321&view=diff
==
--- couchdb/branches/0.11.x/src/couchdb/couch_db.erl (original)
+++ couchdb/branches/0.11.x/src/couchdb/couch_db.erl Thu Jul 29 06:09:00 2010
@@ -368,6 +368,8 @@ update_doc(Db, Doc, Options, UpdateType)
 case update_docs(Db, [Doc], Options, UpdateType) of
 {ok, [{ok, NewRev}]} ->
 {ok, NewRev};
+{ok, [{{_Id, _Rev}, Error}]} ->
+throw(Error);
 {ok, [Error]} ->
 throw(Error);
 {ok, []} ->




svn commit: r980320 - in /couchdb/branches/1.0.x: share/www/script/test/security_validation.js src/couchdb/couch_db.erl

2010-07-28 Thread jchris
Author: jchris
Date: Thu Jul 29 06:05:01 2010
New Revision: 980320

URL: http://svn.apache.org/viewvc?rev=980320&view=rev
Log:
fix the underlying issue that was giving replication problems attempting to 
push design docs as a non-admin. this is what my reverted commit should have 
been

Modified:
couchdb/branches/1.0.x/share/www/script/test/security_validation.js
couchdb/branches/1.0.x/src/couchdb/couch_db.erl

Modified: couchdb/branches/1.0.x/share/www/script/test/security_validation.js
URL: 
http://svn.apache.org/viewvc/couchdb/branches/1.0.x/share/www/script/test/security_validation.js?rev=980320&r1=980319&r2=980320&view=diff
==
--- couchdb/branches/1.0.x/share/www/script/test/security_validation.js 
(original)
+++ couchdb/branches/1.0.x/share/www/script/test/security_validation.js Thu Jul 
29 06:05:01 2010
@@ -111,6 +111,18 @@ couchTests.security_validation = functio
 
   T(userDb.save(designDoc).ok);
 
+  var user2Db = new CouchDB("test_suite_db",
+{"WWW-Authenticate": "X-Couch-Test-Auth Jan Lehnardt:apple"}
+  );
+  // Attempt to save the design as a non-admin (in replication scenario)
+  try {
+user2Db.save(designDoc, {new_edits : false});
+T(false && "Can't get here. Should have thrown an error on design 
doc");
+  } catch (e) {
+T(e.error == "unauthorized");
+T(user2Db.last_req.status == 401);
+  }
+
   // test the _session API
   var resp = userDb.request("GET", "/_session");
   var user = JSON.parse(resp.responseText).userCtx;
@@ -134,10 +146,6 @@ couchTests.security_validation = functio
   }
 
   // Now attempt to update the document as a different user, Jan
-  var user2Db = new CouchDB("test_suite_db",
-{"WWW-Authenticate": "X-Couch-Test-Auth Jan Lehnardt:apple"}
-  );
-
   var doc = user2Db.open("testdoc");
   doc.foo=3;
   try {

Modified: couchdb/branches/1.0.x/src/couchdb/couch_db.erl
URL: 
http://svn.apache.org/viewvc/couchdb/branches/1.0.x/src/couchdb/couch_db.erl?rev=980320&r1=980319&r2=980320&view=diff
==
--- couchdb/branches/1.0.x/src/couchdb/couch_db.erl (original)
+++ couchdb/branches/1.0.x/src/couchdb/couch_db.erl Thu Jul 29 06:05:01 2010
@@ -368,6 +368,8 @@ update_doc(Db, Doc, Options, UpdateType)
 case update_docs(Db, [Doc], Options, UpdateType) of
 {ok, [{ok, NewRev}]} ->
 {ok, NewRev};
+{ok, [{{_Id, _Rev}, Error}]} ->
+throw(Error);
 {ok, [Error]} ->
 throw(Error);
 {ok, []} ->




svn commit: r980319 - in /couchdb/trunk: share/www/script/test/security_validation.js src/couchdb/couch_db.erl

2010-07-28 Thread jchris
Author: jchris
Date: Thu Jul 29 06:04:03 2010
New Revision: 980319

URL: http://svn.apache.org/viewvc?rev=980319&view=rev
Log:
fix the underlying issue that was giving replication problems attempting to 
push design docs as a non-admin. this is what my reverted commit should have 
been

Modified:
couchdb/trunk/share/www/script/test/security_validation.js
couchdb/trunk/src/couchdb/couch_db.erl

Modified: couchdb/trunk/share/www/script/test/security_validation.js
URL: 
http://svn.apache.org/viewvc/couchdb/trunk/share/www/script/test/security_validation.js?rev=980319&r1=980318&r2=980319&view=diff
==
--- couchdb/trunk/share/www/script/test/security_validation.js (original)
+++ couchdb/trunk/share/www/script/test/security_validation.js Thu Jul 29 
06:04:03 2010
@@ -111,6 +111,18 @@ couchTests.security_validation = functio
 
   T(userDb.save(designDoc).ok);
 
+  var user2Db = new CouchDB("test_suite_db",
+{"WWW-Authenticate": "X-Couch-Test-Auth Jan Lehnardt:apple"}
+  );
+  // Attempt to save the design as a non-admin (in replication scenario)
+  try {
+user2Db.save(designDoc, {new_edits : false});
+T(false && "Can't get here. Should have thrown an error on design 
doc");
+  } catch (e) {
+T(e.error == "unauthorized");
+T(user2Db.last_req.status == 401);
+  }
+
   // test the _session API
   var resp = userDb.request("GET", "/_session");
   var user = JSON.parse(resp.responseText).userCtx;
@@ -134,10 +146,6 @@ couchTests.security_validation = functio
   }
 
   // Now attempt to update the document as a different user, Jan
-  var user2Db = new CouchDB("test_suite_db",
-{"WWW-Authenticate": "X-Couch-Test-Auth Jan Lehnardt:apple"}
-  );
-
   var doc = user2Db.open("testdoc");
   doc.foo=3;
   try {

Modified: couchdb/trunk/src/couchdb/couch_db.erl
URL: 
http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_db.erl?rev=980319&r1=980318&r2=980319&view=diff
==
--- couchdb/trunk/src/couchdb/couch_db.erl (original)
+++ couchdb/trunk/src/couchdb/couch_db.erl Thu Jul 29 06:04:03 2010
@@ -368,6 +368,8 @@ update_doc(Db, Doc, Options, UpdateType)
 case update_docs(Db, [Doc], Options, UpdateType) of
 {ok, [{ok, NewRev}]} ->
 {ok, NewRev};
+{ok, [{{_Id, _Rev}, Error}]} ->
+throw(Error);
 {ok, [Error]} ->
 throw(Error);
 {ok, []} ->




svn commit: r980295 - /couchdb/branches/0.11.x/src/couchdb/couch_rep_httpc.erl

2010-07-28 Thread jchris
Author: jchris
Date: Thu Jul 29 02:37:32 2010
New Revision: 980295

URL: http://svn.apache.org/viewvc?rev=980295&view=rev
Log:
Revert "replicator was getting stuck on push replication to design docs by 
non-admins. this fix is a bit hackish but makes replication work. once the 
new_replicator is in place this hackish fix will not matter, so for now it is a 
good solution."

This reverts commit 86310f5d8dfcb7daaa1072979ace58df5774293e.

Modified:
couchdb/branches/0.11.x/src/couchdb/couch_rep_httpc.erl

Modified: couchdb/branches/0.11.x/src/couchdb/couch_rep_httpc.erl
URL: 
http://svn.apache.org/viewvc/couchdb/branches/0.11.x/src/couchdb/couch_rep_httpc.erl?rev=980295&r1=980294&r2=980295&view=diff
==
--- couchdb/branches/0.11.x/src/couchdb/couch_rep_httpc.erl (original)
+++ couchdb/branches/0.11.x/src/couchdb/couch_rep_httpc.erl Thu Jul 29 02:37:32 
2010
@@ -140,7 +140,7 @@ process_response({ok, Status, Headers, B
 do_request(redirected_request(Req, RedirectUrl));
 Code =:= 409 ->
 throw(conflict);
-Code >= 400, Code =< 500 ->
+Code >= 400, Code < 500 ->
 ?JSON_DECODE(maybe_decompress(Headers, Body));
 Code =:= 500; Code =:= 502; Code =:= 503 ->
 #http_db{pause = Pause, retries = Retries} = Req,




svn commit: r980294 - /couchdb/branches/1.0.x/src/couchdb/couch_rep_httpc.erl

2010-07-28 Thread jchris
Author: jchris
Date: Thu Jul 29 02:36:26 2010
New Revision: 980294

URL: http://svn.apache.org/viewvc?rev=980294&view=rev
Log:
Revert "replicator was getting stuck on push replication to design docs by 
non-admins. this fix is a bit hackish but makes replication work. once the 
new_replicator is in place this hackish fix will not matter, so for now it is a 
good solution."

This reverts commit bbdce1780b71840abe3197422d697048e708146b.

Modified:
couchdb/branches/1.0.x/src/couchdb/couch_rep_httpc.erl

Modified: couchdb/branches/1.0.x/src/couchdb/couch_rep_httpc.erl
URL: 
http://svn.apache.org/viewvc/couchdb/branches/1.0.x/src/couchdb/couch_rep_httpc.erl?rev=980294&r1=980293&r2=980294&view=diff
==
--- couchdb/branches/1.0.x/src/couchdb/couch_rep_httpc.erl (original)
+++ couchdb/branches/1.0.x/src/couchdb/couch_rep_httpc.erl Thu Jul 29 02:36:26 
2010
@@ -140,7 +140,7 @@ process_response({ok, Status, Headers, B
 do_request(redirected_request(Req, RedirectUrl));
 Code =:= 409 ->
 throw(conflict);
-Code >= 400, Code =< 500 ->
+Code >= 400, Code < 500 ->
 ?JSON_DECODE(maybe_decompress(Headers, Body));
 Code =:= 500; Code =:= 502; Code =:= 503 ->
 #http_db{pause = Pause, retries = Retries} = Req,




svn commit: r980293 - /couchdb/trunk/src/couchdb/couch_rep_httpc.erl

2010-07-28 Thread jchris
Author: jchris
Date: Thu Jul 29 02:35:13 2010
New Revision: 980293

URL: http://svn.apache.org/viewvc?rev=980293&view=rev
Log:
Revert "replicator was getting stuck on push replication to design docs by 
non-admins. this fix is a bit hackish but makes replication work. once the 
new_replicator is in place this hackish fix will not matter, so for now it is a 
good solution."

This was too much of a hack.

This reverts commit 7223697dafa234a9123e6f72b826ba11dc58e88f aka r979907

Modified:
couchdb/trunk/src/couchdb/couch_rep_httpc.erl

Modified: couchdb/trunk/src/couchdb/couch_rep_httpc.erl
URL: 
http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_rep_httpc.erl?rev=980293&r1=980292&r2=980293&view=diff
==
--- couchdb/trunk/src/couchdb/couch_rep_httpc.erl (original)
+++ couchdb/trunk/src/couchdb/couch_rep_httpc.erl Thu Jul 29 02:35:13 2010
@@ -140,7 +140,7 @@ process_response({ok, Status, Headers, B
 do_request(redirected_request(Req, RedirectUrl));
 Code =:= 409 ->
 throw(conflict);
-Code >= 400, Code =< 500 ->
+Code >= 400, Code < 500 ->
 ?JSON_DECODE(maybe_decompress(Headers, Body));
 Code =:= 500; Code =:= 502; Code =:= 503 ->
 #http_db{pause = Pause, retries = Retries} = Req,




svn commit: r979910 - /couchdb/branches/0.11.x/src/couchdb/couch_rep_httpc.erl

2010-07-27 Thread jchris
Author: jchris
Date: Tue Jul 27 23:08:44 2010
New Revision: 979910

URL: http://svn.apache.org/viewvc?rev=979910&view=rev
Log:
replicator was getting stuck on push replication to design docs by non-admins. 
this fix is a bit hackish but makes replication work. once the new_replicator 
is in place this hackish fix will not matter, so for now it is a good solution.

Modified:
couchdb/branches/0.11.x/src/couchdb/couch_rep_httpc.erl

Modified: couchdb/branches/0.11.x/src/couchdb/couch_rep_httpc.erl
URL: 
http://svn.apache.org/viewvc/couchdb/branches/0.11.x/src/couchdb/couch_rep_httpc.erl?rev=979910&r1=979909&r2=979910&view=diff
==
--- couchdb/branches/0.11.x/src/couchdb/couch_rep_httpc.erl (original)
+++ couchdb/branches/0.11.x/src/couchdb/couch_rep_httpc.erl Tue Jul 27 23:08:44 
2010
@@ -140,7 +140,7 @@ process_response({ok, Status, Headers, B
 do_request(redirected_request(Req, RedirectUrl));
 Code =:= 409 ->
 throw(conflict);
-Code >= 400, Code < 500 ->
+Code >= 400, Code =< 500 ->
 ?JSON_DECODE(maybe_decompress(Headers, Body));
 Code =:= 500; Code =:= 502; Code =:= 503 ->
 #http_db{pause = Pause, retries = Retries} = Req,




svn commit: r979908 - /couchdb/branches/1.0.x/src/couchdb/couch_rep_httpc.erl

2010-07-27 Thread jchris
Author: jchris
Date: Tue Jul 27 23:08:03 2010
New Revision: 979908

URL: http://svn.apache.org/viewvc?rev=979908&view=rev
Log:
replicator was getting stuck on push replication to design docs by non-admins. 
this fix is a bit hackish but makes replication work. once the new_replicator 
is in place this hackish fix will not matter, so for now it is a good solution.

Modified:
couchdb/branches/1.0.x/src/couchdb/couch_rep_httpc.erl

Modified: couchdb/branches/1.0.x/src/couchdb/couch_rep_httpc.erl
URL: 
http://svn.apache.org/viewvc/couchdb/branches/1.0.x/src/couchdb/couch_rep_httpc.erl?rev=979908&r1=979907&r2=979908&view=diff
==
--- couchdb/branches/1.0.x/src/couchdb/couch_rep_httpc.erl (original)
+++ couchdb/branches/1.0.x/src/couchdb/couch_rep_httpc.erl Tue Jul 27 23:08:03 
2010
@@ -140,7 +140,7 @@ process_response({ok, Status, Headers, B
 do_request(redirected_request(Req, RedirectUrl));
 Code =:= 409 ->
 throw(conflict);
-Code >= 400, Code < 500 ->
+Code >= 400, Code =< 500 ->
 ?JSON_DECODE(maybe_decompress(Headers, Body));
 Code =:= 500; Code =:= 502; Code =:= 503 ->
 #http_db{pause = Pause, retries = Retries} = Req,




svn commit: r979907 - /couchdb/trunk/src/couchdb/couch_rep_httpc.erl

2010-07-27 Thread jchris
Author: jchris
Date: Tue Jul 27 23:07:19 2010
New Revision: 979907

URL: http://svn.apache.org/viewvc?rev=979907&view=rev
Log:
replicator was getting stuck on push replication to design docs by non-admins. 
this fix is a bit hackish but makes replication work. once the new_replicator 
is in place this hackish fix will not matter, so for now it is a good solution.

Modified:
couchdb/trunk/src/couchdb/couch_rep_httpc.erl

Modified: couchdb/trunk/src/couchdb/couch_rep_httpc.erl
URL: 
http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_rep_httpc.erl?rev=979907&r1=979906&r2=979907&view=diff
==
--- couchdb/trunk/src/couchdb/couch_rep_httpc.erl (original)
+++ couchdb/trunk/src/couchdb/couch_rep_httpc.erl Tue Jul 27 23:07:19 2010
@@ -140,7 +140,7 @@ process_response({ok, Status, Headers, B
 do_request(redirected_request(Req, RedirectUrl));
 Code =:= 409 ->
 throw(conflict);
-Code >= 400, Code < 500 ->
+Code >= 400, Code =< 500 ->
 ?JSON_DECODE(maybe_decompress(Headers, Body));
 Code =:= 500; Code =:= 502; Code =:= 503 ->
 #http_db{pause = Pause, retries = Retries} = Req,




svn commit: r979083 - in /couchdb/branches/1.0.x: etc/couchdb/local.ini src/couchdb/couch_httpd.erl

2010-07-25 Thread jchris
Author: jchris
Date: Sun Jul 25 18:16:54 2010
New Revision: 979083

URL: http://svn.apache.org/viewvc?rev=979083&view=rev
Log:
send a basic-auth popup header if require_valid_user=true, to prevent lock-out

Modified:
couchdb/branches/1.0.x/etc/couchdb/local.ini
couchdb/branches/1.0.x/src/couchdb/couch_httpd.erl

Modified: couchdb/branches/1.0.x/etc/couchdb/local.ini
URL: 
http://svn.apache.org/viewvc/couchdb/branches/1.0.x/etc/couchdb/local.ini?rev=979083&r1=979082&r2=979083&view=diff
==
--- couchdb/branches/1.0.x/etc/couchdb/local.ini (original)
+++ couchdb/branches/1.0.x/etc/couchdb/local.ini Sun Jul 25 18:16:54 2010
@@ -14,7 +14,9 @@
 ;WWW-Authenticate = Basic realm="administrator"
 
 [couch_httpd_auth]
-; if you set this to true, you should also uncomment the WWW-Authenticate line 
above
+; If you set this to true, you should also uncomment the WWW-Authenticate line
+; above. If you don't configure a WWW-Authenticate header, CouchDB will send
+; Basic realm="server" in order to prevent you getting logged out.
 ; require_valid_user = false
 
 [log]

Modified: couchdb/branches/1.0.x/src/couchdb/couch_httpd.erl
URL: 
http://svn.apache.org/viewvc/couchdb/branches/1.0.x/src/couchdb/couch_httpd.erl?rev=979083&r1=979082&r2=979083&view=diff
==
--- couchdb/branches/1.0.x/src/couchdb/couch_httpd.erl (original)
+++ couchdb/branches/1.0.x/src/couchdb/couch_httpd.erl Sun Jul 25 18:16:54 2010
@@ -750,7 +750,8 @@ error_headers(#httpd{mochi_req=MochiReq}
 AuthRedirect ->
 case couch_config:get("couch_httpd_auth", 
"require_valid_user", "false") of
 "true" ->
-{Code, []};
+% send the browser popup header no matter what if 
we are require_valid_user
+{Code, [{"WWW-Authenticate", "Basic 
realm=\"server\""}]};
 _False ->
 % if the accept header matches html, then do the 
redirect. else proceed as usual.
 case re:run(MochiReq:get_header_value("Accept"), 
"html", [{capture, none}]) of




svn commit: r979070 - in /couchdb/trunk: etc/couchdb/local.ini src/couchdb/couch_httpd.erl

2010-07-25 Thread jchris
Author: jchris
Date: Sun Jul 25 17:01:37 2010
New Revision: 979070

URL: http://svn.apache.org/viewvc?rev=979070&view=rev
Log:
send a basic-auth popup header if require_valid_user=true, to prevent lock-out

Modified:
couchdb/trunk/etc/couchdb/local.ini
couchdb/trunk/src/couchdb/couch_httpd.erl

Modified: couchdb/trunk/etc/couchdb/local.ini
URL: 
http://svn.apache.org/viewvc/couchdb/trunk/etc/couchdb/local.ini?rev=979070&r1=979069&r2=979070&view=diff
==
--- couchdb/trunk/etc/couchdb/local.ini (original)
+++ couchdb/trunk/etc/couchdb/local.ini Sun Jul 25 17:01:37 2010
@@ -14,7 +14,9 @@
 ;WWW-Authenticate = Basic realm="administrator"
 
 [couch_httpd_auth]
-; if you set this to true, you should also uncomment the WWW-Authenticate line 
above
+; If you set this to true, you should also uncomment the WWW-Authenticate line
+; above. If you don't configure a WWW-Authenticate header, CouchDB will send
+; Basic realm="server" in order to prevent you getting logged out.
 ; require_valid_user = false
 
 [log]

Modified: couchdb/trunk/src/couchdb/couch_httpd.erl
URL: 
http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_httpd.erl?rev=979070&r1=979069&r2=979070&view=diff
==
--- couchdb/trunk/src/couchdb/couch_httpd.erl (original)
+++ couchdb/trunk/src/couchdb/couch_httpd.erl Sun Jul 25 17:01:37 2010
@@ -750,7 +750,8 @@ error_headers(#httpd{mochi_req=MochiReq}
 AuthRedirect ->
 case couch_config:get("couch_httpd_auth", 
"require_valid_user", "false") of
 "true" ->
-{Code, []};
+% send the browser popup header no matter what if 
we are require_valid_user
+{Code, [{"WWW-Authenticate", "Basic 
realm=\"server\""}]};
 _False ->
 % if the accept header matches html, then do the 
redirect. else proceed as usual.
 case re:run(MochiReq:get_header_value("Accept"), 
"html", [{capture, none}]) of




svn commit: r978964 - /couchdb/branches/0.11.x/share/Makefile.am

2010-07-24 Thread jchris
Author: jchris
Date: Sun Jul 25 02:16:36 2010
New Revision: 978964

URL: http://svn.apache.org/viewvc?rev=978964&view=rev
Log:
add _create_config.html to the makefile so it gets installed with make

Modified:
couchdb/branches/0.11.x/share/Makefile.am

Modified: couchdb/branches/0.11.x/share/Makefile.am
URL: 
http://svn.apache.org/viewvc/couchdb/branches/0.11.x/share/Makefile.am?rev=978964&r1=978963&r2=978964&view=diff
==
--- couchdb/branches/0.11.x/share/Makefile.am (original)
+++ couchdb/branches/0.11.x/share/Makefile.am Sun Jul 25 02:16:36 2010
@@ -49,6 +49,7 @@ nobase_dist_localdata_DATA = \
 www/dialog/_login.html \
 www/dialog/_signup.html \
 www/dialog/_create_database.html \
+www/dialog/_create_config.html \
 www/dialog/_delete_database.html \
 www/dialog/_delete_document.html \
 www/dialog/_database_security.html \




svn commit: r978962 - /couchdb/branches/1.0.x/share/Makefile.am

2010-07-24 Thread jchris
Author: jchris
Date: Sun Jul 25 02:13:41 2010
New Revision: 978962

URL: http://svn.apache.org/viewvc?rev=978962&view=rev
Log:
add _create_config.html to the makefile so it gets installed with make

Modified:
couchdb/branches/1.0.x/share/Makefile.am

Modified: couchdb/branches/1.0.x/share/Makefile.am
URL: 
http://svn.apache.org/viewvc/couchdb/branches/1.0.x/share/Makefile.am?rev=978962&r1=978961&r2=978962&view=diff
==
--- couchdb/branches/1.0.x/share/Makefile.am (original)
+++ couchdb/branches/1.0.x/share/Makefile.am Sun Jul 25 02:13:41 2010
@@ -49,6 +49,7 @@ nobase_dist_localdata_DATA = \
 www/dialog/_login.html \
 www/dialog/_signup.html \
 www/dialog/_create_database.html \
+www/dialog/_create_config.html \
 www/dialog/_delete_database.html \
 www/dialog/_delete_document.html \
 www/dialog/_database_security.html \




svn commit: r978961 - /couchdb/trunk/share/Makefile.am

2010-07-24 Thread jchris
Author: jchris
Date: Sun Jul 25 02:13:16 2010
New Revision: 978961

URL: http://svn.apache.org/viewvc?rev=978961&view=rev
Log:
add _create_config.html to the makefile so it gets installed with make

Modified:
couchdb/trunk/share/Makefile.am

Modified: couchdb/trunk/share/Makefile.am
URL: 
http://svn.apache.org/viewvc/couchdb/trunk/share/Makefile.am?rev=978961&r1=978960&r2=978961&view=diff
==
--- couchdb/trunk/share/Makefile.am (original)
+++ couchdb/trunk/share/Makefile.am Sun Jul 25 02:13:16 2010
@@ -49,6 +49,7 @@ nobase_dist_localdata_DATA = \
 www/dialog/_login.html \
 www/dialog/_signup.html \
 www/dialog/_create_database.html \
+www/dialog/_create_config.html \
 www/dialog/_delete_database.html \
 www/dialog/_delete_document.html \
 www/dialog/_database_security.html \




svn commit: r966971 - in /couchdb/trunk/share: server/json2.js www/script/json2.js

2010-07-22 Thread jchris
Author: jchris
Date: Fri Jul 23 05:44:51 2010
New Revision: 966971

URL: http://svn.apache.org/viewvc?rev=966971&view=rev
Log:
update json2.js to latest version

Modified:
couchdb/trunk/share/server/json2.js
couchdb/trunk/share/www/script/json2.js

Modified: couchdb/trunk/share/server/json2.js
URL: 
http://svn.apache.org/viewvc/couchdb/trunk/share/server/json2.js?rev=966971&r1=966970&r2=966971&view=diff
==
--- couchdb/trunk/share/server/json2.js [utf-8] (original)
+++ couchdb/trunk/share/server/json2.js [utf-8] Fri Jul 23 05:44:51 2010
@@ -1,6 +1,6 @@
 /*
 http://www.JSON.org/json2.js
-2009-09-29
+2010-03-20
 
 Public Domain.
 
@@ -433,6 +433,7 @@ if (!this.JSON) {
 // Unicode characters with escape sequences. JavaScript handles many characters
 // incorrectly, either silently deleting them, or treating them as line 
endings.
 
+text = String(text);
 cx.lastIndex = 0;
 if (cx.test(text)) {
 text = text.replace(cx, function (a) {

Modified: couchdb/trunk/share/www/script/json2.js
URL: 
http://svn.apache.org/viewvc/couchdb/trunk/share/www/script/json2.js?rev=966971&r1=966970&r2=966971&view=diff
==
--- couchdb/trunk/share/www/script/json2.js [utf-8] (original)
+++ couchdb/trunk/share/www/script/json2.js [utf-8] Fri Jul 23 05:44:51 2010
@@ -1,6 +1,6 @@
 /*
 http://www.JSON.org/json2.js
-2009-09-29
+2010-03-20
 
 Public Domain.
 
@@ -433,6 +433,7 @@ if (!this.JSON) {
 // Unicode characters with escape sequences. JavaScript handles many characters
 // incorrectly, either silently deleting them, or treating them as line 
endings.
 
+text = String(text);
 cx.lastIndex = 0;
 if (cx.test(text)) {
 text = text.replace(cx, function (a) {




svn commit: r966959 - /couchdb/branches/0.11.x/share/www/script/jquery.couch.js

2010-07-22 Thread jchris
Author: jchris
Date: Fri Jul 23 04:18:53 2010
New Revision: 966959

URL: http://svn.apache.org/viewvc?rev=966959&view=rev
Log:
Make the simple document versioning actually work. I have no idea how it passed 
my earlier tests, maybe there was a regression.

Modified:
couchdb/branches/0.11.x/share/www/script/jquery.couch.js

Modified: couchdb/branches/0.11.x/share/www/script/jquery.couch.js
URL: 
http://svn.apache.org/viewvc/couchdb/branches/0.11.x/share/www/script/jquery.couch.js?rev=966959&r1=966958&r2=966959&view=diff
==
--- couchdb/branches/0.11.x/share/www/script/jquery.couch.js [utf-8] (original)
+++ couchdb/branches/0.11.x/share/www/script/jquery.couch.js [utf-8] Fri Jul 23 
04:18:53 2010
@@ -341,7 +341,7 @@
 openDoc: function(docId, options, ajaxOptions) {
   options = options || {};
   if (db_opts.attachPrevRev || options.attachPrevRev) {
-$.extend(ajaxOptions, {
+$.extend(options, {
   beforeSuccess : function(req, doc) {
 rawDocs[doc._id] = {
   rev : doc._rev,
@@ -350,7 +350,7 @@
   }
 });
   } else {
-$.extend(ajaxOptions, {
+$.extend(options, {
   beforeSuccess : function(req, doc) {
 if (doc["jquery.couch.attachPrevRev"]) {
   rawDocs[doc._id] = {
@@ -649,7 +649,7 @@
 var buf = [];
 if (typeof(options) === "object" && options !== null) {
   for (var name in options) {
-if ($.inArray(name, ["error", "success", "ajaxStart"]) >= 0)
+if ($.inArray(name, ["error", "success", "beforeSuccess", 
"ajaxStart"]) >= 0)
   continue;
 var value = options[name];
 if ($.inArray(name, ["key", "startkey", "endkey"]) >= 0) {




svn commit: r966958 - /couchdb/branches/1.0.x/share/www/script/jquery.couch.js

2010-07-22 Thread jchris
Author: jchris
Date: Fri Jul 23 04:18:24 2010
New Revision: 966958

URL: http://svn.apache.org/viewvc?rev=966958&view=rev
Log:
Make the simple document versioning actually work. I have no idea how it passed 
my earlier tests, maybe there was a regression.

Modified:
couchdb/branches/1.0.x/share/www/script/jquery.couch.js

Modified: couchdb/branches/1.0.x/share/www/script/jquery.couch.js
URL: 
http://svn.apache.org/viewvc/couchdb/branches/1.0.x/share/www/script/jquery.couch.js?rev=966958&r1=966957&r2=966958&view=diff
==
--- couchdb/branches/1.0.x/share/www/script/jquery.couch.js [utf-8] (original)
+++ couchdb/branches/1.0.x/share/www/script/jquery.couch.js [utf-8] Fri Jul 23 
04:18:24 2010
@@ -341,7 +341,7 @@
 openDoc: function(docId, options, ajaxOptions) {
   options = options || {};
   if (db_opts.attachPrevRev || options.attachPrevRev) {
-$.extend(ajaxOptions, {
+$.extend(options, {
   beforeSuccess : function(req, doc) {
 rawDocs[doc._id] = {
   rev : doc._rev,
@@ -350,7 +350,7 @@
   }
 });
   } else {
-$.extend(ajaxOptions, {
+$.extend(options, {
   beforeSuccess : function(req, doc) {
 if (doc["jquery.couch.attachPrevRev"]) {
   rawDocs[doc._id] = {
@@ -649,7 +649,7 @@
 var buf = [];
 if (typeof(options) === "object" && options !== null) {
   for (var name in options) {
-if ($.inArray(name, ["error", "success", "ajaxStart"]) >= 0)
+if ($.inArray(name, ["error", "success", "beforeSuccess", 
"ajaxStart"]) >= 0)
   continue;
 var value = options[name];
 if ($.inArray(name, ["key", "startkey", "endkey"]) >= 0) {




svn commit: r966957 - /couchdb/trunk/share/www/script/jquery.couch.js

2010-07-22 Thread jchris
Author: jchris
Date: Fri Jul 23 04:17:38 2010
New Revision: 966957

URL: http://svn.apache.org/viewvc?rev=966957&view=rev
Log:
Make the simple document versioning actually work. I have no idea how it passed 
my earlier tests, maybe there was a regression.

Modified:
couchdb/trunk/share/www/script/jquery.couch.js

Modified: couchdb/trunk/share/www/script/jquery.couch.js
URL: 
http://svn.apache.org/viewvc/couchdb/trunk/share/www/script/jquery.couch.js?rev=966957&r1=966956&r2=966957&view=diff
==
--- couchdb/trunk/share/www/script/jquery.couch.js [utf-8] (original)
+++ couchdb/trunk/share/www/script/jquery.couch.js [utf-8] Fri Jul 23 04:17:38 
2010
@@ -341,7 +341,7 @@
 openDoc: function(docId, options, ajaxOptions) {
   options = options || {};
   if (db_opts.attachPrevRev || options.attachPrevRev) {
-$.extend(ajaxOptions, {
+$.extend(options, {
   beforeSuccess : function(req, doc) {
 rawDocs[doc._id] = {
   rev : doc._rev,
@@ -350,7 +350,7 @@
   }
 });
   } else {
-$.extend(ajaxOptions, {
+$.extend(options, {
   beforeSuccess : function(req, doc) {
 if (doc["jquery.couch.attachPrevRev"]) {
   rawDocs[doc._id] = {
@@ -649,7 +649,7 @@
 var buf = [];
 if (typeof(options) === "object" && options !== null) {
   for (var name in options) {
-if ($.inArray(name, ["error", "success", "ajaxStart"]) >= 0)
+if ($.inArray(name, ["error", "success", "beforeSuccess", 
"ajaxStart"]) >= 0)
   continue;
 var value = options[name];
 if ($.inArray(name, ["key", "startkey", "endkey"]) >= 0) {




svn commit: r966687 - /couchdb/branches/1.0.x/src/couchdb/couch_httpd_db.erl

2010-07-22 Thread jchris
Author: jchris
Date: Thu Jul 22 14:31:52 2010
New Revision: 966687

URL: http://svn.apache.org/viewvc?rev=966687&view=rev
Log:
humane error message on missing design handler

Modified:
couchdb/branches/1.0.x/src/couchdb/couch_httpd_db.erl

Modified: couchdb/branches/1.0.x/src/couchdb/couch_httpd_db.erl
URL: 
http://svn.apache.org/viewvc/couchdb/branches/1.0.x/src/couchdb/couch_httpd_db.erl?rev=966687&r1=966686&r2=966687&view=diff
==
--- couchdb/branches/1.0.x/src/couchdb/couch_httpd_db.erl (original)
+++ couchdb/branches/1.0.x/src/couchdb/couch_httpd_db.erl Thu Jul 22 14:31:52 
2010
@@ -144,7 +144,9 @@ handle_design_req(#httpd{
 % load ddoc
 DesignId = <<"_design/", DesignName/binary>>,
 DDoc = couch_httpd_db:couch_doc_open(Db, DesignId, nil, []),
-Handler = couch_util:dict_find(Action, DesignUrlHandlers, fun db_req/2),
+Handler = couch_util:dict_find(Action, DesignUrlHandlers, fun(A,B,C) -> 
+throw({not_found, <<"missing handler: ", Action/binary>>})
+end),
 Handler(Req, Db, DDoc);
 
 handle_design_req(Req, Db) ->




svn commit: r966689 - /couchdb/branches/0.11.x/src/couchdb/couch_httpd_db.erl

2010-07-22 Thread jchris
Author: jchris
Date: Thu Jul 22 14:32:10 2010
New Revision: 966689

URL: http://svn.apache.org/viewvc?rev=966689&view=rev
Log:
humane error message on missing design handler

Modified:
couchdb/branches/0.11.x/src/couchdb/couch_httpd_db.erl

Modified: couchdb/branches/0.11.x/src/couchdb/couch_httpd_db.erl
URL: 
http://svn.apache.org/viewvc/couchdb/branches/0.11.x/src/couchdb/couch_httpd_db.erl?rev=966689&r1=966688&r2=966689&view=diff
==
--- couchdb/branches/0.11.x/src/couchdb/couch_httpd_db.erl (original)
+++ couchdb/branches/0.11.x/src/couchdb/couch_httpd_db.erl Thu Jul 22 14:32:10 
2010
@@ -144,7 +144,9 @@ handle_design_req(#httpd{
 % load ddoc
 DesignId = <<"_design/", DesignName/binary>>,
 DDoc = couch_httpd_db:couch_doc_open(Db, DesignId, nil, []),
-Handler = couch_util:dict_find(Action, DesignUrlHandlers, fun db_req/2),
+Handler = couch_util:dict_find(Action, DesignUrlHandlers, fun(A,B,C) -> 
+throw({not_found, <<"missing handler: ", Action/binary>>})
+end),
 Handler(Req, Db, DDoc);
 
 handle_design_req(Req, Db) ->




svn commit: r966685 - /couchdb/trunk/src/couchdb/couch_httpd_db.erl

2010-07-22 Thread jchris
Author: jchris
Date: Thu Jul 22 14:29:30 2010
New Revision: 966685

URL: http://svn.apache.org/viewvc?rev=966685&view=rev
Log:
humane error message on missing design handler

Modified:
couchdb/trunk/src/couchdb/couch_httpd_db.erl

Modified: couchdb/trunk/src/couchdb/couch_httpd_db.erl
URL: 
http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_httpd_db.erl?rev=966685&r1=966684&r2=966685&view=diff
==
--- couchdb/trunk/src/couchdb/couch_httpd_db.erl (original)
+++ couchdb/trunk/src/couchdb/couch_httpd_db.erl Thu Jul 22 14:29:30 2010
@@ -144,7 +144,9 @@ handle_design_req(#httpd{
 % load ddoc
 DesignId = <<"_design/", DesignName/binary>>,
 DDoc = couch_httpd_db:couch_doc_open(Db, DesignId, nil, []),
-Handler = couch_util:dict_find(Action, DesignUrlHandlers, fun db_req/2),
+Handler = couch_util:dict_find(Action, DesignUrlHandlers, fun(A,B,C) -> 
+throw({not_found, <<"missing handler: ", Action/binary>>})
+end),
 Handler(Req, Db, DDoc);
 
 handle_design_req(Req, Db) ->




svn commit: r965703 - in /couchdb/branches/0.11.x: share/www/script/test/view_errors.js src/couchdb/couch_httpd_db.erl src/couchdb/couch_httpd_misc_handlers.erl src/couchdb/couch_httpd_view.erl src/co

2010-07-19 Thread jchris
Author: jchris
Date: Tue Jul 20 01:05:17 2010
New Revision: 965703

URL: http://svn.apache.org/viewvc?rev=965703&view=rev
Log:
require application/json content-type in the remaining places where a POST has 
side-effects

Modified:
couchdb/branches/0.11.x/share/www/script/test/view_errors.js
couchdb/branches/0.11.x/src/couchdb/couch_httpd_db.erl
couchdb/branches/0.11.x/src/couchdb/couch_httpd_misc_handlers.erl
couchdb/branches/0.11.x/src/couchdb/couch_httpd_view.erl
couchdb/branches/0.11.x/src/couchdb/couch_rep.erl

Modified: couchdb/branches/0.11.x/share/www/script/test/view_errors.js
URL: 
http://svn.apache.org/viewvc/couchdb/branches/0.11.x/share/www/script/test/view_errors.js?rev=965703&r1=965702&r2=965703&view=diff
==
--- couchdb/branches/0.11.x/share/www/script/test/view_errors.js (original)
+++ couchdb/branches/0.11.x/share/www/script/test/view_errors.js Tue Jul 20 
01:05:17 2010
@@ -56,14 +56,14 @@ couchTests.view_errors = function(debug)
   });
   T(JSON.parse(xhr.responseText).error == "bad_request");
 
-  // views should ignore Content-Type, like the rest of CouchDB
+  // content type must be json
   var xhr = CouchDB.request("POST", "/test_suite_db/_temp_view", {
 headers: {"Content-Type": "application/x-www-form-urlencoded"},
 body: JSON.stringify({language: "javascript",
   map : "function(doc){}"
 })
   });
-  T(xhr.status == 200);
+  T(xhr.status == 415);
 
   var map = function (doc) {emit(doc.integer, doc.integer);};
 

Modified: couchdb/branches/0.11.x/src/couchdb/couch_httpd_db.erl
URL: 
http://svn.apache.org/viewvc/couchdb/branches/0.11.x/src/couchdb/couch_httpd_db.erl?rev=965703&r1=965702&r2=965703&view=diff
==
--- couchdb/branches/0.11.x/src/couchdb/couch_httpd_db.erl (original)
+++ couchdb/branches/0.11.x/src/couchdb/couch_httpd_db.erl Tue Jul 20 01:05:17 
2010
@@ -261,6 +261,7 @@ db_req(#httpd{path_parts=[_DbName]}=Req,
 send_method_not_allowed(Req, "DELETE,GET,HEAD,POST");
 
 db_req(#httpd{method='POST',path_parts=[_,<<"_ensure_full_commit">>]}=Req, Db) 
->
+couch_httpd:validate_ctype(Req, "application/json"),
 UpdateSeq = couch_db:get_update_seq(Db),
 CommittedSeq = couch_db:get_committed_update_seq(Db),
 {ok, StartTime} =

Modified: couchdb/branches/0.11.x/src/couchdb/couch_httpd_misc_handlers.erl
URL: 
http://svn.apache.org/viewvc/couchdb/branches/0.11.x/src/couchdb/couch_httpd_misc_handlers.erl?rev=965703&r1=965702&r2=965703&view=diff
==
--- couchdb/branches/0.11.x/src/couchdb/couch_httpd_misc_handlers.erl (original)
+++ couchdb/branches/0.11.x/src/couchdb/couch_httpd_misc_handlers.erl Tue Jul 
20 01:05:17 2010
@@ -79,6 +79,7 @@ handle_task_status_req(Req) ->
 send_method_not_allowed(Req, "GET,HEAD").
 
 handle_replicate_req(#httpd{method='POST'}=Req) ->
+couch_httpd:validate_ctype(Req, "application/json"),
 PostBody = couch_httpd:json_body_obj(Req),
 try couch_rep:replicate(PostBody, Req#httpd.user_ctx) of
 {ok, {continuous, RepId}} ->
@@ -102,6 +103,7 @@ handle_replicate_req(Req) ->
 
 
 handle_restart_req(#httpd{method='POST'}=Req) ->
+couch_httpd:validate_ctype(Req, "application/json"),
 ok = couch_httpd:verify_is_server_admin(Req),
 couch_server_sup:restart_core_server(),
 send_json(Req, 200, {[{ok, true}]});
@@ -189,6 +191,7 @@ handle_config_req(Req) ->
 % httpd db handlers
 
 increment_update_seq_req(#httpd{method='POST'}=Req, Db) ->
+couch_httpd:validate_ctype(Req, "application/json"),
 {ok, NewSeq} = couch_db:increment_update_seq(Db),
 send_json(Req, {[{ok, true},
 {update_seq, NewSeq}

Modified: couchdb/branches/0.11.x/src/couchdb/couch_httpd_view.erl
URL: 
http://svn.apache.org/viewvc/couchdb/branches/0.11.x/src/couchdb/couch_httpd_view.erl?rev=965703&r1=965702&r2=965703&view=diff
==
--- couchdb/branches/0.11.x/src/couchdb/couch_httpd_view.erl (original)
+++ couchdb/branches/0.11.x/src/couchdb/couch_httpd_view.erl Tue Jul 20 
01:05:17 2010
@@ -59,6 +59,7 @@ handle_view_req(#httpd{method='GET',
 
 handle_view_req(#httpd{method='POST',
 path_parts=[_, _, DName, _, ViewName]}=Req, Db, _DDoc) ->
+couch_httpd:validate_ctype(Req, "application/json"),
 {Fields} = couch_httpd:json_body_obj(Req),
 case proplists:get_value(<<"keys">>, Fields, nil) of
 nil ->
@@ -75,6 +76,7 

svn commit: r965702 - in /couchdb/branches/1.0.x: share/www/script/test/view_errors.js src/couchdb/couch_httpd_db.erl src/couchdb/couch_httpd_misc_handlers.erl src/couchdb/couch_httpd_view.erl src/cou

2010-07-19 Thread jchris
Author: jchris
Date: Tue Jul 20 01:04:22 2010
New Revision: 965702

URL: http://svn.apache.org/viewvc?rev=965702&view=rev
Log:
require application/json content-type in the remaining places where a POST has 
side-effects

Modified:
couchdb/branches/1.0.x/share/www/script/test/view_errors.js
couchdb/branches/1.0.x/src/couchdb/couch_httpd_db.erl
couchdb/branches/1.0.x/src/couchdb/couch_httpd_misc_handlers.erl
couchdb/branches/1.0.x/src/couchdb/couch_httpd_view.erl
couchdb/branches/1.0.x/src/couchdb/couch_rep.erl

Modified: couchdb/branches/1.0.x/share/www/script/test/view_errors.js
URL: 
http://svn.apache.org/viewvc/couchdb/branches/1.0.x/share/www/script/test/view_errors.js?rev=965702&r1=965701&r2=965702&view=diff
==
--- couchdb/branches/1.0.x/share/www/script/test/view_errors.js (original)
+++ couchdb/branches/1.0.x/share/www/script/test/view_errors.js Tue Jul 20 
01:04:22 2010
@@ -56,14 +56,14 @@ couchTests.view_errors = function(debug)
   });
   T(JSON.parse(xhr.responseText).error == "bad_request");
 
-  // views should ignore Content-Type, like the rest of CouchDB
+  // content type must be json
   var xhr = CouchDB.request("POST", "/test_suite_db/_temp_view", {
 headers: {"Content-Type": "application/x-www-form-urlencoded"},
 body: JSON.stringify({language: "javascript",
   map : "function(doc){}"
 })
   });
-  T(xhr.status == 200);
+  T(xhr.status == 415);
 
   var map = function (doc) {emit(doc.integer, doc.integer);};
 

Modified: couchdb/branches/1.0.x/src/couchdb/couch_httpd_db.erl
URL: 
http://svn.apache.org/viewvc/couchdb/branches/1.0.x/src/couchdb/couch_httpd_db.erl?rev=965702&r1=965701&r2=965702&view=diff
==
--- couchdb/branches/1.0.x/src/couchdb/couch_httpd_db.erl (original)
+++ couchdb/branches/1.0.x/src/couchdb/couch_httpd_db.erl Tue Jul 20 01:04:22 
2010
@@ -242,6 +242,7 @@ db_req(#httpd{path_parts=[_DbName]}=Req,
 send_method_not_allowed(Req, "DELETE,GET,HEAD,POST");
 
 db_req(#httpd{method='POST',path_parts=[_,<<"_ensure_full_commit">>]}=Req, Db) 
->
+couch_httpd:validate_ctype(Req, "application/json"),
 UpdateSeq = couch_db:get_update_seq(Db),
 CommittedSeq = couch_db:get_committed_update_seq(Db),
 {ok, StartTime} =

Modified: couchdb/branches/1.0.x/src/couchdb/couch_httpd_misc_handlers.erl
URL: 
http://svn.apache.org/viewvc/couchdb/branches/1.0.x/src/couchdb/couch_httpd_misc_handlers.erl?rev=965702&r1=965701&r2=965702&view=diff
==
--- couchdb/branches/1.0.x/src/couchdb/couch_httpd_misc_handlers.erl (original)
+++ couchdb/branches/1.0.x/src/couchdb/couch_httpd_misc_handlers.erl Tue Jul 20 
01:04:22 2010
@@ -79,6 +79,7 @@ handle_task_status_req(Req) ->
 send_method_not_allowed(Req, "GET,HEAD").
 
 handle_replicate_req(#httpd{method='POST'}=Req) ->
+couch_httpd:validate_ctype(Req, "application/json"),
 PostBody = couch_httpd:json_body_obj(Req),
 try couch_rep:replicate(PostBody, Req#httpd.user_ctx) of
 {ok, {continuous, RepId}} ->
@@ -102,6 +103,7 @@ handle_replicate_req(Req) ->
 
 
 handle_restart_req(#httpd{method='POST'}=Req) ->
+couch_httpd:validate_ctype(Req, "application/json"),
 ok = couch_httpd:verify_is_server_admin(Req),
 couch_server_sup:restart_core_server(),
 send_json(Req, 200, {[{ok, true}]});
@@ -189,6 +191,7 @@ handle_config_req(Req) ->
 % httpd db handlers
 
 increment_update_seq_req(#httpd{method='POST'}=Req, Db) ->
+couch_httpd:validate_ctype(Req, "application/json"),
 {ok, NewSeq} = couch_db:increment_update_seq(Db),
 send_json(Req, {[{ok, true},
 {update_seq, NewSeq}

Modified: couchdb/branches/1.0.x/src/couchdb/couch_httpd_view.erl
URL: 
http://svn.apache.org/viewvc/couchdb/branches/1.0.x/src/couchdb/couch_httpd_view.erl?rev=965702&r1=965701&r2=965702&view=diff
==
--- couchdb/branches/1.0.x/src/couchdb/couch_httpd_view.erl (original)
+++ couchdb/branches/1.0.x/src/couchdb/couch_httpd_view.erl Tue Jul 20 01:04:22 
2010
@@ -61,6 +61,7 @@ handle_view_req(#httpd{method='GET',
 
 handle_view_req(#httpd{method='POST',
 path_parts=[_, _, DName, _, ViewName]}=Req, Db, _DDoc) ->
+couch_httpd:validate_ctype(Req, "application/json"),
 {Fields} = couch_httpd:json_body_obj(Req),
 case couch_util:get_value(<<"keys">>, Fields, nil) of
 nil ->
@@ -77,6 +78,7 

svn commit: r965700 - in /couchdb/trunk: share/www/script/test/view_errors.js src/couchdb/couch_httpd_db.erl src/couchdb/couch_httpd_misc_handlers.erl src/couchdb/couch_httpd_view.erl src/couchdb/couc

2010-07-19 Thread jchris
Author: jchris
Date: Tue Jul 20 01:03:10 2010
New Revision: 965700

URL: http://svn.apache.org/viewvc?rev=965700&view=rev
Log:
require application/json content-type in the remaining places where a POST has 
side-effects

Modified:
couchdb/trunk/share/www/script/test/view_errors.js
couchdb/trunk/src/couchdb/couch_httpd_db.erl
couchdb/trunk/src/couchdb/couch_httpd_misc_handlers.erl
couchdb/trunk/src/couchdb/couch_httpd_view.erl
couchdb/trunk/src/couchdb/couch_rep.erl

Modified: couchdb/trunk/share/www/script/test/view_errors.js
URL: 
http://svn.apache.org/viewvc/couchdb/trunk/share/www/script/test/view_errors.js?rev=965700&r1=965699&r2=965700&view=diff
==
--- couchdb/trunk/share/www/script/test/view_errors.js (original)
+++ couchdb/trunk/share/www/script/test/view_errors.js Tue Jul 20 01:03:10 2010
@@ -56,14 +56,14 @@ couchTests.view_errors = function(debug)
   });
   T(JSON.parse(xhr.responseText).error == "bad_request");
 
-  // views should ignore Content-Type, like the rest of CouchDB
+  // content type must be json
   var xhr = CouchDB.request("POST", "/test_suite_db/_temp_view", {
 headers: {"Content-Type": "application/x-www-form-urlencoded"},
 body: JSON.stringify({language: "javascript",
   map : "function(doc){}"
 })
   });
-  T(xhr.status == 200);
+  T(xhr.status == 415);
 
   var map = function (doc) {emit(doc.integer, doc.integer);};
 

Modified: couchdb/trunk/src/couchdb/couch_httpd_db.erl
URL: 
http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_httpd_db.erl?rev=965700&r1=965699&r2=965700&view=diff
==
--- couchdb/trunk/src/couchdb/couch_httpd_db.erl (original)
+++ couchdb/trunk/src/couchdb/couch_httpd_db.erl Tue Jul 20 01:03:10 2010
@@ -242,6 +242,7 @@ db_req(#httpd{path_parts=[_DbName]}=Req,
 send_method_not_allowed(Req, "DELETE,GET,HEAD,POST");
 
 db_req(#httpd{method='POST',path_parts=[_,<<"_ensure_full_commit">>]}=Req, Db) 
->
+couch_httpd:validate_ctype(Req, "application/json"),
 UpdateSeq = couch_db:get_update_seq(Db),
 CommittedSeq = couch_db:get_committed_update_seq(Db),
 {ok, StartTime} =

Modified: couchdb/trunk/src/couchdb/couch_httpd_misc_handlers.erl
URL: 
http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_httpd_misc_handlers.erl?rev=965700&r1=965699&r2=965700&view=diff
==
--- couchdb/trunk/src/couchdb/couch_httpd_misc_handlers.erl (original)
+++ couchdb/trunk/src/couchdb/couch_httpd_misc_handlers.erl Tue Jul 20 01:03:10 
2010
@@ -79,6 +79,7 @@ handle_task_status_req(Req) ->
 send_method_not_allowed(Req, "GET,HEAD").
 
 handle_replicate_req(#httpd{method='POST'}=Req) ->
+couch_httpd:validate_ctype(Req, "application/json"),
 PostBody = couch_httpd:json_body_obj(Req),
 try couch_rep:replicate(PostBody, Req#httpd.user_ctx) of
 {ok, {continuous, RepId}} ->
@@ -102,6 +103,7 @@ handle_replicate_req(Req) ->
 
 
 handle_restart_req(#httpd{method='POST'}=Req) ->
+couch_httpd:validate_ctype(Req, "application/json"),
 ok = couch_httpd:verify_is_server_admin(Req),
 couch_server_sup:restart_core_server(),
 send_json(Req, 200, {[{ok, true}]});
@@ -189,6 +191,7 @@ handle_config_req(Req) ->
 % httpd db handlers
 
 increment_update_seq_req(#httpd{method='POST'}=Req, Db) ->
+couch_httpd:validate_ctype(Req, "application/json"),
 {ok, NewSeq} = couch_db:increment_update_seq(Db),
 send_json(Req, {[{ok, true},
 {update_seq, NewSeq}

Modified: couchdb/trunk/src/couchdb/couch_httpd_view.erl
URL: 
http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_httpd_view.erl?rev=965700&r1=965699&r2=965700&view=diff
==
--- couchdb/trunk/src/couchdb/couch_httpd_view.erl (original)
+++ couchdb/trunk/src/couchdb/couch_httpd_view.erl Tue Jul 20 01:03:10 2010
@@ -61,6 +61,7 @@ handle_view_req(#httpd{method='GET',
 
 handle_view_req(#httpd{method='POST',
 path_parts=[_, _, DName, _, ViewName]}=Req, Db, _DDoc) ->
+couch_httpd:validate_ctype(Req, "application/json"),
 {Fields} = couch_httpd:json_body_obj(Req),
 case couch_util:get_value(<<"keys">>, Fields, nil) of
 nil ->
@@ -77,6 +78,7 @@ handle_view_req(Req, _Db, _DDoc) ->
 send_method_not_allowed(Req, "GET,POST,HEAD").
 
 handle_temp_view_req(#httpd{method='POST'}=Req, Db) ->
+couch_httpd:validate_c

svn commit: r965673 - in /couchdb/branches/1.0.x/src/couchdb: couch_db.hrl couch_doc.erl couch_httpd.erl couch_httpd_rewrite.erl couch_httpd_stats_handlers.erl couch_httpd_view.erl couch_os_process.er

2010-07-19 Thread jchris
Author: jchris
Date: Mon Jul 19 22:59:53 2010
New Revision: 965673

URL: http://svn.apache.org/viewvc?rev=965673&view=rev
Log:
remove unguarded atom creation to prevent DOS attacks. closes COUCHDB-829

Modified:
couchdb/branches/1.0.x/src/couchdb/couch_db.hrl
couchdb/branches/1.0.x/src/couchdb/couch_doc.erl
couchdb/branches/1.0.x/src/couchdb/couch_httpd.erl
couchdb/branches/1.0.x/src/couchdb/couch_httpd_rewrite.erl
couchdb/branches/1.0.x/src/couchdb/couch_httpd_stats_handlers.erl
couchdb/branches/1.0.x/src/couchdb/couch_httpd_view.erl
couchdb/branches/1.0.x/src/couchdb/couch_os_process.erl
couchdb/branches/1.0.x/src/couchdb/couch_rep.erl
couchdb/branches/1.0.x/src/couchdb/couch_util.erl

Modified: couchdb/branches/1.0.x/src/couchdb/couch_db.hrl
URL: 
http://svn.apache.org/viewvc/couchdb/branches/1.0.x/src/couchdb/couch_db.hrl?rev=965673&r1=965672&r2=965673&view=diff
==
--- couchdb/branches/1.0.x/src/couchdb/couch_db.hrl (original)
+++ couchdb/branches/1.0.x/src/couchdb/couch_db.hrl Mon Jul 19 22:59:53 2010
@@ -20,7 +20,6 @@
 -define(JSON_ENCODE(V), couch_util:json_encode(V)).
 -define(JSON_DECODE(V), couch_util:json_decode(V)).
 
--define(b2a(V), list_to_atom(binary_to_list(V))).
 -define(b2l(V), binary_to_list(V)).
 -define(l2b(V), list_to_binary(V)).
 

Modified: couchdb/branches/1.0.x/src/couchdb/couch_doc.erl
URL: 
http://svn.apache.org/viewvc/couchdb/branches/1.0.x/src/couchdb/couch_doc.erl?rev=965673&r1=965672&r2=965673&view=diff
==
--- couchdb/branches/1.0.x/src/couchdb/couch_doc.erl (original)
+++ couchdb/branches/1.0.x/src/couchdb/couch_doc.erl Mon Jul 19 22:59:53 2010
@@ -267,7 +267,7 @@ att_encoding_info(BinProps) ->
 {identity, DiskLen};
 Enc ->
 EncodedLen = couch_util:get_value(<<"encoded_length">>, BinProps, 
DiskLen),
-{list_to_atom(?b2l(Enc)), EncodedLen}
+{list_to_existing_atom(?b2l(Enc)), EncodedLen}
 end.
 
 to_doc_info(FullDocInfo) ->

Modified: couchdb/branches/1.0.x/src/couchdb/couch_httpd.erl
URL: 
http://svn.apache.org/viewvc/couchdb/branches/1.0.x/src/couchdb/couch_httpd.erl?rev=965673&r1=965672&r2=965673&view=diff
==
--- couchdb/branches/1.0.x/src/couchdb/couch_httpd.erl (original)
+++ couchdb/branches/1.0.x/src/couchdb/couch_httpd.erl Mon Jul 19 22:59:53 2010
@@ -225,7 +225,7 @@ handle_request_int(MochiReq, DefaultFun,
 true -> 
 ?LOG_INFO("MethodOverride: ~s (real method was ~s)", [MethodOverride, 
Method1]),
 case Method1 of
-'POST' -> list_to_atom(MethodOverride);
+'POST' -> couch_util:to_existing_atom(MethodOverride);
 _ -> 
 % Ignore X-HTTP-Method-Override when the original verb isn't POST.
 % I'd like to send a 406 error to the client, but that'd require a 
nasty refactor.

Modified: couchdb/branches/1.0.x/src/couchdb/couch_httpd_rewrite.erl
URL: 
http://svn.apache.org/viewvc/couchdb/branches/1.0.x/src/couchdb/couch_httpd_rewrite.erl?rev=965673&r1=965672&r2=965673&view=diff
==
--- couchdb/branches/1.0.x/src/couchdb/couch_httpd_rewrite.erl (original)
+++ couchdb/branches/1.0.x/src/couchdb/couch_httpd_rewrite.erl Mon Jul 19 
22:59:53 2010
@@ -20,7 +20,7 @@
 -include("couch_db.hrl").
 
 -define(SEPARATOR, $\/).
--define(MATCH_ALL, '*').
+-define(MATCH_ALL, {bind, <<"*">>}).
 
 
 %% doc The http rewrite handler. All rewriting is done from
@@ -118,7 +118,7 @@ handle_rewrite_req(#httpd{
 DesignId = <<"_design/", DesignName/binary>>,
 Prefix = <<"/", DbName/binary, "/", DesignId/binary>>,
 QueryList = couch_httpd:qs(Req),
-QueryList1 = [{to_atom(K), V} || {K, V} <- QueryList],
+QueryList1 = [{to_binding(K), V} || {K, V} <- QueryList],
 
 #doc{body={Props}} = DDoc,
 
@@ -132,12 +132,12 @@ handle_rewrite_req(#httpd{
 DispatchList =  [make_rule(Rule) || {Rule} <- Rules],
 
 %% get raw path by matching url to a rule.
-RawPath = case try_bind_path(DispatchList, Method, PathParts,
+RawPath = case try_bind_path(DispatchList, 
couch_util:to_binary(Method), PathParts,
 QueryList1) of
 no_dispatch_path ->
 throw(not_found);
 {NewPathParts, Bindings} ->
-Parts = [mochiweb_util:quote_plus(X) || X <- NewPathParts],
+Parts = [quote_plus(X) || X <- NewPathParts],
 

svn commit: r965669 - in /couchdb/branches/0.11.x/src/couchdb: couch_db.hrl couch_doc.erl couch_httpd.erl couch_httpd_rewrite.erl couch_httpd_stats_handlers.erl couch_httpd_view.erl couch_os_process.e

2010-07-19 Thread jchris
Author: jchris
Date: Mon Jul 19 22:58:18 2010
New Revision: 965669

URL: http://svn.apache.org/viewvc?rev=965669&view=rev
Log:
remove unguarded atom creation to prevent DOS attacks. closes COUCHDB-829
backport from r965667

Modified:
couchdb/branches/0.11.x/src/couchdb/couch_db.hrl
couchdb/branches/0.11.x/src/couchdb/couch_doc.erl
couchdb/branches/0.11.x/src/couchdb/couch_httpd.erl
couchdb/branches/0.11.x/src/couchdb/couch_httpd_rewrite.erl
couchdb/branches/0.11.x/src/couchdb/couch_httpd_stats_handlers.erl
couchdb/branches/0.11.x/src/couchdb/couch_httpd_view.erl
couchdb/branches/0.11.x/src/couchdb/couch_os_process.erl
couchdb/branches/0.11.x/src/couchdb/couch_rep.erl
couchdb/branches/0.11.x/src/couchdb/couch_util.erl

Modified: couchdb/branches/0.11.x/src/couchdb/couch_db.hrl
URL: 
http://svn.apache.org/viewvc/couchdb/branches/0.11.x/src/couchdb/couch_db.hrl?rev=965669&r1=965668&r2=965669&view=diff
==
--- couchdb/branches/0.11.x/src/couchdb/couch_db.hrl (original)
+++ couchdb/branches/0.11.x/src/couchdb/couch_db.hrl Mon Jul 19 22:58:18 2010
@@ -20,7 +20,6 @@
 -define(JSON_ENCODE(V), couch_util:json_encode(V)).
 -define(JSON_DECODE(V), couch_util:json_decode(V)).
 
--define(b2a(V), list_to_atom(binary_to_list(V))).
 -define(b2l(V), binary_to_list(V)).
 -define(l2b(V), list_to_binary(V)).
 

Modified: couchdb/branches/0.11.x/src/couchdb/couch_doc.erl
URL: 
http://svn.apache.org/viewvc/couchdb/branches/0.11.x/src/couchdb/couch_doc.erl?rev=965669&r1=965668&r2=965669&view=diff
==
--- couchdb/branches/0.11.x/src/couchdb/couch_doc.erl (original)
+++ couchdb/branches/0.11.x/src/couchdb/couch_doc.erl Mon Jul 19 22:58:18 2010
@@ -267,7 +267,7 @@ att_encoding_info(BinProps) ->
 {identity, DiskLen};
 Enc ->
 EncodedLen = proplists:get_value(<<"encoded_length">>, BinProps, 
DiskLen),
-{list_to_atom(?b2l(Enc)), EncodedLen}
+{list_to_existing_atom(?b2l(Enc)), EncodedLen}
 end.
 
 to_doc_info(FullDocInfo) ->

Modified: couchdb/branches/0.11.x/src/couchdb/couch_httpd.erl
URL: 
http://svn.apache.org/viewvc/couchdb/branches/0.11.x/src/couchdb/couch_httpd.erl?rev=965669&r1=965668&r2=965669&view=diff
==
--- couchdb/branches/0.11.x/src/couchdb/couch_httpd.erl (original)
+++ couchdb/branches/0.11.x/src/couchdb/couch_httpd.erl Mon Jul 19 22:58:18 2010
@@ -225,7 +225,7 @@ handle_request_int(MochiReq, DefaultFun,
 true -> 
 ?LOG_INFO("MethodOverride: ~s (real method was ~s)", [MethodOverride, 
Method1]),
 case Method1 of
-'POST' -> list_to_atom(MethodOverride);
+'POST' -> couch_util:to_existing_atom(MethodOverride);
 _ -> 
 % Ignore X-HTTP-Method-Override when the original verb isn't POST.
 % I'd like to send a 406 error to the client, but that'd require a 
nasty refactor.

Modified: couchdb/branches/0.11.x/src/couchdb/couch_httpd_rewrite.erl
URL: 
http://svn.apache.org/viewvc/couchdb/branches/0.11.x/src/couchdb/couch_httpd_rewrite.erl?rev=965669&r1=965668&r2=965669&view=diff
==
--- couchdb/branches/0.11.x/src/couchdb/couch_httpd_rewrite.erl (original)
+++ couchdb/branches/0.11.x/src/couchdb/couch_httpd_rewrite.erl Mon Jul 19 
22:58:18 2010
@@ -20,7 +20,7 @@
 -include("couch_db.hrl").
 
 -define(SEPARATOR, $\/).
--define(MATCH_ALL, '*').
+-define(MATCH_ALL, {bind, <<"*">>}).
 
 
 %% doc The http rewrite handler. All rewriting is done from
@@ -118,7 +118,7 @@ handle_rewrite_req(#httpd{
 DesignId = <<"_design/", DesignName/binary>>,
 Prefix = <<"/", DbName/binary, "/", DesignId/binary>>,
 QueryList = couch_httpd:qs(Req),
-QueryList1 = [{to_atom(K), V} || {K, V} <- QueryList],
+QueryList1 = [{to_binding(K), V} || {K, V} <- QueryList],
 
 #doc{body={Props}} = DDoc,
 
@@ -132,12 +132,12 @@ handle_rewrite_req(#httpd{
 DispatchList =  [make_rule(Rule) || {Rule} <- Rules],
 
 %% get raw path by matching url to a rule.
-RawPath = case try_bind_path(DispatchList, Method, PathParts,
+RawPath = case try_bind_path(DispatchList, 
couch_util:to_binary(Method), PathParts,
 QueryList1) of
 no_dispatch_path ->
 throw(not_found);
 {NewPathParts, Bindings} ->
-Parts = [mochiweb_util:quote_plus(X) || X <- NewPathParts],
+Parts = [quote_plus(X) || X <- New

svn commit: r965667 - in /couchdb/trunk/src/couchdb: couch_db.hrl couch_doc.erl couch_httpd.erl couch_httpd_rewrite.erl couch_httpd_stats_handlers.erl couch_httpd_view.erl couch_os_process.erl couch_r

2010-07-19 Thread jchris
Author: jchris
Date: Mon Jul 19 22:46:14 2010
New Revision: 965667

URL: http://svn.apache.org/viewvc?rev=965667&view=rev
Log:
remove unguarded atom creation to prevent DOS attacks. closes COUCHDB-829

Modified:
couchdb/trunk/src/couchdb/couch_db.hrl
couchdb/trunk/src/couchdb/couch_doc.erl
couchdb/trunk/src/couchdb/couch_httpd.erl
couchdb/trunk/src/couchdb/couch_httpd_rewrite.erl
couchdb/trunk/src/couchdb/couch_httpd_stats_handlers.erl
couchdb/trunk/src/couchdb/couch_httpd_view.erl
couchdb/trunk/src/couchdb/couch_os_process.erl
couchdb/trunk/src/couchdb/couch_rep.erl
couchdb/trunk/src/couchdb/couch_util.erl

Modified: couchdb/trunk/src/couchdb/couch_db.hrl
URL: 
http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_db.hrl?rev=965667&r1=965666&r2=965667&view=diff
==
--- couchdb/trunk/src/couchdb/couch_db.hrl (original)
+++ couchdb/trunk/src/couchdb/couch_db.hrl Mon Jul 19 22:46:14 2010
@@ -20,7 +20,6 @@
 -define(JSON_ENCODE(V), couch_util:json_encode(V)).
 -define(JSON_DECODE(V), couch_util:json_decode(V)).
 
--define(b2a(V), list_to_atom(binary_to_list(V))).
 -define(b2l(V), binary_to_list(V)).
 -define(l2b(V), list_to_binary(V)).
 

Modified: couchdb/trunk/src/couchdb/couch_doc.erl
URL: 
http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_doc.erl?rev=965667&r1=965666&r2=965667&view=diff
==
--- couchdb/trunk/src/couchdb/couch_doc.erl (original)
+++ couchdb/trunk/src/couchdb/couch_doc.erl Mon Jul 19 22:46:14 2010
@@ -267,7 +267,7 @@ att_encoding_info(BinProps) ->
 {identity, DiskLen};
 Enc ->
 EncodedLen = couch_util:get_value(<<"encoded_length">>, BinProps, 
DiskLen),
-{list_to_atom(?b2l(Enc)), EncodedLen}
+{list_to_existing_atom(?b2l(Enc)), EncodedLen}
 end.
 
 to_doc_info(FullDocInfo) ->

Modified: couchdb/trunk/src/couchdb/couch_httpd.erl
URL: 
http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_httpd.erl?rev=965667&r1=965666&r2=965667&view=diff
==
--- couchdb/trunk/src/couchdb/couch_httpd.erl (original)
+++ couchdb/trunk/src/couchdb/couch_httpd.erl Mon Jul 19 22:46:14 2010
@@ -225,7 +225,7 @@ handle_request_int(MochiReq, DefaultFun,
 true -> 
 ?LOG_INFO("MethodOverride: ~s (real method was ~s)", [MethodOverride, 
Method1]),
 case Method1 of
-'POST' -> list_to_atom(MethodOverride);
+'POST' -> couch_util:to_existing_atom(MethodOverride);
 _ -> 
 % Ignore X-HTTP-Method-Override when the original verb isn't POST.
 % I'd like to send a 406 error to the client, but that'd require a 
nasty refactor.

Modified: couchdb/trunk/src/couchdb/couch_httpd_rewrite.erl
URL: 
http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_httpd_rewrite.erl?rev=965667&r1=965666&r2=965667&view=diff
==
--- couchdb/trunk/src/couchdb/couch_httpd_rewrite.erl (original)
+++ couchdb/trunk/src/couchdb/couch_httpd_rewrite.erl Mon Jul 19 22:46:14 2010
@@ -20,7 +20,7 @@
 -include("couch_db.hrl").
 
 -define(SEPARATOR, $\/).
--define(MATCH_ALL, '*').
+-define(MATCH_ALL, {bind, <<"*">>}).
 
 
 %% doc The http rewrite handler. All rewriting is done from
@@ -118,7 +118,7 @@ handle_rewrite_req(#httpd{
 DesignId = <<"_design/", DesignName/binary>>,
 Prefix = <<"/", DbName/binary, "/", DesignId/binary>>,
 QueryList = couch_httpd:qs(Req),
-QueryList1 = [{to_atom(K), V} || {K, V} <- QueryList],
+QueryList1 = [{to_binding(K), V} || {K, V} <- QueryList],
 
 #doc{body={Props}} = DDoc,
 
@@ -132,12 +132,12 @@ handle_rewrite_req(#httpd{
 DispatchList =  [make_rule(Rule) || {Rule} <- Rules],
 
 %% get raw path by matching url to a rule.
-RawPath = case try_bind_path(DispatchList, Method, PathParts,
+RawPath = case try_bind_path(DispatchList, 
couch_util:to_binary(Method), PathParts,
 QueryList1) of
 no_dispatch_path ->
 throw(not_found);
 {NewPathParts, Bindings} ->
-Parts = [mochiweb_util:quote_plus(X) || X <- NewPathParts],
+Parts = [quote_plus(X) || X <- NewPathParts],
 
 % build new path, reencode query args, eventually convert
 % them to json
@@ -183,7 +183,10 @@ handle_rewrite_req(#httpd{
 UrlHandlers, DbUrlHandlers, DesignUrlHandlers)
 end.
 
-
+quote_plus({bind

svn commit: r964987 - /couchdb/trunk/share/www/couch_tests.html

2010-07-16 Thread jchris
Author: jchris
Date: Sat Jul 17 00:11:00 2010
New Revision: 964987

URL: http://svn.apache.org/viewvc?rev=964987&view=rev
Log:
note about firefox support in test suite

Modified:
couchdb/trunk/share/www/couch_tests.html

Modified: couchdb/trunk/share/www/couch_tests.html
URL: 
http://svn.apache.org/viewvc/couchdb/trunk/share/www/couch_tests.html?rev=964987&r1=964986&r2=964987&view=diff
==
--- couchdb/trunk/share/www/couch_tests.html [utf-8] (original)
+++ couchdb/trunk/share/www/couch_tests.html [utf-8] Sat Jul 17 00:11:00 2010
@@ -68,7 +68,10 @@ specific language governing permissions 
 Note: Each of the tests will block the browser. If the
 connection to your CouchDB server is slow, running the tests will take
 some time, and you'll not be able to do much with your browser while
-a test is being executed.
+a test is being executed. Also: The test suite is 
designed
+to work with Firefox (with Firebug disabled). Patches are welcome for 
+convenience compatibility with other browsers, but official support is
+for Firefox (latest stable version) only.
   
 
   




svn commit: r963742 - in /couchdb/branches/0.11.x: share/www/script/test/users_db.js src/couchdb/couch_httpd_auth.erl

2010-07-13 Thread jchris
Author: jchris
Date: Tue Jul 13 14:46:38 2010
New Revision: 963742

URL: http://svn.apache.org/viewvc?rev=963742&view=rev
Log:
backport r963723 (ability to delete user docs) from trunk

Modified:
couchdb/branches/0.11.x/share/www/script/test/users_db.js
couchdb/branches/0.11.x/src/couchdb/couch_httpd_auth.erl

Modified: couchdb/branches/0.11.x/share/www/script/test/users_db.js
URL: 
http://svn.apache.org/viewvc/couchdb/branches/0.11.x/share/www/script/test/users_db.js?rev=963742&r1=963741&r2=963742&view=diff
==
--- couchdb/branches/0.11.x/share/www/script/test/users_db.js (original)
+++ couchdb/branches/0.11.x/share/www/script/test/users_db.js Tue Jul 13 
14:46:38 2010
@@ -85,7 +85,11 @@ couchTests.users_db = function(debug) {
   T(e.error == "unauthorized")
   T(/conflict/.test(e.reason))
 }
-
+// you can delete a user doc
+s = CouchDB.session().userCtx;
+T(s.name == null);
+T(s.roles.indexOf("_admin") !== -1);
+T(usersDb.deleteDoc(jchrisWithConflict).ok);
   };
   
   run_on_modified_server(

Modified: couchdb/branches/0.11.x/src/couchdb/couch_httpd_auth.erl
URL: 
http://svn.apache.org/viewvc/couchdb/branches/0.11.x/src/couchdb/couch_httpd_auth.erl?rev=963742&r1=963741&r2=963742&view=diff
==
--- couchdb/branches/0.11.x/src/couchdb/couch_httpd_auth.erl (original)
+++ couchdb/branches/0.11.x/src/couchdb/couch_httpd_auth.erl Tue Jul 13 
14:46:38 2010
@@ -237,18 +237,21 @@ auth_design_doc(DocId) ->
 {
 <<"validate_doc_update">>,
 <<"function(newDoc, oldDoc, userCtx) {
-if ((oldDoc || newDoc).type != 'user') {
-throw({forbidden : 'doc.type must be user'});
-} // we only validate user docs for now
 if (newDoc._deleted === true) {
-// allow deletes by admins and matching users 
+// allow deletes by admins and matching users
 // without checking the other fields
-if ((userCtx.roles.indexOf('_admin') != -1) || 
(userCtx.name == oldDoc.name)) {
+if ((userCtx.roles.indexOf('_admin') !== -1) ||
+(userCtx.name == oldDoc.name)) {
 return;
 } else {
-throw({forbidden : 'Only admins may delete other user 
docs.'});
+throw({forbidden: 'Only admins may delete other user 
docs.'});
 }
 }
+
+if ((oldDoc && oldDoc.type !== 'user') || newDoc.type !== 
'user') {
+throw({forbidden : 'doc.type must be user'});
+} // we only allow user docs for now
+
 if (!newDoc.name) {
 throw({forbidden : 'doc.name is required'});
 }




svn commit: r963732 - /couchdb/branches/1.0.x/src/couchdb/couch_doc.erl

2010-07-13 Thread jchris
Author: jchris
Date: Tue Jul 13 14:30:42 2010
New Revision: 963732

URL: http://svn.apache.org/viewvc?rev=963732&view=rev
Log:
show the complete document body even when the document is deleted (Couch lets 
you store data with a delete but did not render it to JSON)

Modified:
couchdb/branches/1.0.x/src/couchdb/couch_doc.erl

Modified: couchdb/branches/1.0.x/src/couchdb/couch_doc.erl
URL: 
http://svn.apache.org/viewvc/couchdb/branches/1.0.x/src/couchdb/couch_doc.erl?rev=963732&r1=963731&r2=963732&view=diff
==
--- couchdb/branches/1.0.x/src/couchdb/couch_doc.erl (original)
+++ couchdb/branches/1.0.x/src/couchdb/couch_doc.erl Tue Jul 13 14:30:42 2010
@@ -27,8 +27,8 @@ to_json_rev(0, []) ->
 to_json_rev(Start, [FirstRevId|_]) ->
 [{<<"_rev">>, 
?l2b([integer_to_list(Start),"-",revid_to_str(FirstRevId)])}].
 
-to_json_body(true, _Body) ->
-[{<<"_deleted">>, true}];
+to_json_body(true, {Body}) ->
+Body ++ [{<<"_deleted">>, true}];
 to_json_body(false, {Body}) ->
 Body.
 




svn commit: r963731 - in /couchdb/branches/1.0.x: share/www/script/test/users_db.js src/couchdb/couch_js_functions.hrl

2010-07-13 Thread jchris
Author: jchris
Date: Tue Jul 13 14:30:38 2010
New Revision: 963731

URL: http://svn.apache.org/viewvc?rev=963731&view=rev
Log:
test and fix for deleting users documents

Modified:
couchdb/branches/1.0.x/share/www/script/test/users_db.js
couchdb/branches/1.0.x/src/couchdb/couch_js_functions.hrl

Modified: couchdb/branches/1.0.x/share/www/script/test/users_db.js
URL: 
http://svn.apache.org/viewvc/couchdb/branches/1.0.x/share/www/script/test/users_db.js?rev=963731&r1=963730&r2=963731&view=diff
==
--- couchdb/branches/1.0.x/share/www/script/test/users_db.js (original)
+++ couchdb/branches/1.0.x/share/www/script/test/users_db.js Tue Jul 13 
14:30:38 2010
@@ -85,8 +85,13 @@ couchTests.users_db = function(debug) {
   T(/conflict/.test(e.reason))
 }
 
+// you can delete a user doc
+s = CouchDB.session().userCtx;
+T(s.name == null);
+T(s.roles.indexOf("_admin") !== -1);
+T(usersDb.deleteDoc(jchrisWithConflict).ok);
   };
-  
+
   usersDb.deleteDb();
   run_on_modified_server(
 [{section: "couch_httpd_auth",

Modified: couchdb/branches/1.0.x/src/couchdb/couch_js_functions.hrl
URL: 
http://svn.apache.org/viewvc/couchdb/branches/1.0.x/src/couchdb/couch_js_functions.hrl?rev=963731&r1=963730&r2=963731&view=diff
==
--- couchdb/branches/1.0.x/src/couchdb/couch_js_functions.hrl (original)
+++ couchdb/branches/1.0.x/src/couchdb/couch_js_functions.hrl Tue Jul 13 
14:30:38 2010
@@ -12,10 +12,6 @@
 
 -define(AUTH_DB_DOC_VALIDATE_FUNCTION, <<"
 function(newDoc, oldDoc, userCtx) {
-if ((oldDoc && oldDoc.type !== 'user') || newDoc.type !== 'user') {
-throw({forbidden : 'doc.type must be user'});
-} // we only allow user docs for now
-
 if (newDoc._deleted === true) {
 // allow deletes by admins and matching users
 // without checking the other fields
@@ -27,6 +23,10 @@
 }
 }
 
+if ((oldDoc && oldDoc.type !== 'user') || newDoc.type !== 'user') {
+throw({forbidden : 'doc.type must be user'});
+} // we only allow user docs for now
+
 if (!newDoc.name) {
 throw({forbidden: 'doc.name is required'});
 }




svn commit: r963723 - in /couchdb/trunk: share/www/script/test/users_db.js src/couchdb/couch_js_functions.hrl

2010-07-13 Thread jchris
Author: jchris
Date: Tue Jul 13 14:25:03 2010
New Revision: 963723

URL: http://svn.apache.org/viewvc?rev=963723&view=rev
Log:
test and fix for deleting users documents

Modified:
couchdb/trunk/share/www/script/test/users_db.js
couchdb/trunk/src/couchdb/couch_js_functions.hrl

Modified: couchdb/trunk/share/www/script/test/users_db.js
URL: 
http://svn.apache.org/viewvc/couchdb/trunk/share/www/script/test/users_db.js?rev=963723&r1=963722&r2=963723&view=diff
==
--- couchdb/trunk/share/www/script/test/users_db.js (original)
+++ couchdb/trunk/share/www/script/test/users_db.js Tue Jul 13 14:25:03 2010
@@ -85,8 +85,13 @@ couchTests.users_db = function(debug) {
   T(/conflict/.test(e.reason))
 }
 
+// you can delete a user doc
+s = CouchDB.session().userCtx;
+T(s.name == null);
+T(s.roles.indexOf("_admin") !== -1);
+T(usersDb.deleteDoc(jchrisWithConflict).ok);
   };
-  
+
   usersDb.deleteDb();
   run_on_modified_server(
 [{section: "couch_httpd_auth",

Modified: couchdb/trunk/src/couchdb/couch_js_functions.hrl
URL: 
http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_js_functions.hrl?rev=963723&r1=963722&r2=963723&view=diff
==
--- couchdb/trunk/src/couchdb/couch_js_functions.hrl (original)
+++ couchdb/trunk/src/couchdb/couch_js_functions.hrl Tue Jul 13 14:25:03 2010
@@ -12,10 +12,6 @@
 
 -define(AUTH_DB_DOC_VALIDATE_FUNCTION, <<"
 function(newDoc, oldDoc, userCtx) {
-if ((oldDoc && oldDoc.type !== 'user') || newDoc.type !== 'user') {
-throw({forbidden : 'doc.type must be user'});
-} // we only allow user docs for now
-
 if (newDoc._deleted === true) {
 // allow deletes by admins and matching users
 // without checking the other fields
@@ -27,6 +23,10 @@
 }
 }
 
+if ((oldDoc && oldDoc.type !== 'user') || newDoc.type !== 'user') {
+throw({forbidden : 'doc.type must be user'});
+} // we only allow user docs for now
+
 if (!newDoc.name) {
 throw({forbidden: 'doc.name is required'});
 }




svn commit: r963725 - /couchdb/trunk/src/couchdb/couch_doc.erl

2010-07-13 Thread jchris
Author: jchris
Date: Tue Jul 13 14:25:06 2010
New Revision: 963725

URL: http://svn.apache.org/viewvc?rev=963725&view=rev
Log:
show the complete document body even when the document is deleted (Couch lets 
you store data with a delete but did not render it to JSON)

Modified:
couchdb/trunk/src/couchdb/couch_doc.erl

Modified: couchdb/trunk/src/couchdb/couch_doc.erl
URL: 
http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_doc.erl?rev=963725&r1=963724&r2=963725&view=diff
==
--- couchdb/trunk/src/couchdb/couch_doc.erl (original)
+++ couchdb/trunk/src/couchdb/couch_doc.erl Tue Jul 13 14:25:06 2010
@@ -27,8 +27,8 @@ to_json_rev(0, []) ->
 to_json_rev(Start, [FirstRevId|_]) ->
 [{<<"_rev">>, 
?l2b([integer_to_list(Start),"-",revid_to_str(FirstRevId)])}].
 
-to_json_body(true, _Body) ->
-[{<<"_deleted">>, true}];
+to_json_body(true, {Body}) ->
+Body ++ [{<<"_deleted">>, true}];
 to_json_body(false, {Body}) ->
 Body.
 




svn commit: r961907 - /couchdb/branches/0.11.x/src/couchdb/couch_httpd_db.erl

2010-07-08 Thread jchris
Author: jchris
Date: Thu Jul  8 19:50:29 2010
New Revision: 961907

URL: http://svn.apache.org/viewvc?rev=961907&view=rev
Log:
validate admin and content type for compact requests

Modified:
couchdb/branches/0.11.x/src/couchdb/couch_httpd_db.erl

Modified: couchdb/branches/0.11.x/src/couchdb/couch_httpd_db.erl
URL: 
http://svn.apache.org/viewvc/couchdb/branches/0.11.x/src/couchdb/couch_httpd_db.erl?rev=961907&r1=961906&r2=961907&view=diff
==
--- couchdb/branches/0.11.x/src/couchdb/couch_httpd_db.erl (original)
+++ couchdb/branches/0.11.x/src/couchdb/couch_httpd_db.erl Thu Jul  8 19:50:29 
2010
@@ -111,12 +111,15 @@ handle_changes_req(#httpd{method='GET'}=
 handle_changes_req(#httpd{path_parts=[_,<<"_changes">>]}=Req, _Db) ->
 send_method_not_allowed(Req, "GET,HEAD").
 
-handle_compact_req(#httpd{method='POST',path_parts=[DbName,_,Id|_]}=Req, _Db) 
->
+handle_compact_req(#httpd{method='POST',path_parts=[DbName,_,Id|_]}=Req, Db) ->
+ok = couch_db:check_is_admin(Db),
 couch_httpd:validate_ctype(Req, "application/json"),
 ok = couch_view_compactor:start_compact(DbName, Id),
 send_json(Req, 202, {[{ok, true}]});
 
 handle_compact_req(#httpd{method='POST'}=Req, Db) ->
+ok = couch_db:check_is_admin(Db),
+couch_httpd:validate_ctype(Req, "application/json"),
 ok = couch_db:start_compact(Db),
 send_json(Req, 202, {[{ok, true}]});
 
@@ -125,6 +128,8 @@ handle_compact_req(Req, _Db) ->
 
 handle_view_cleanup_req(#httpd{method='POST'}=Req, Db) ->
 % delete unreferenced index files
+ok = couch_db:check_is_admin(Db),
+couch_httpd:validate_ctype(Req, "application/json"),
 ok = couch_view:cleanup_index_files(Db),
 send_json(Req, 202, {[{ok, true}]});
 




svn commit: r961906 - in /couchdb/branches/0.11.x/src/couchdb: couch_db.erl couch_db_updater.erl

2010-07-08 Thread jchris
Author: jchris
Date: Thu Jul  8 19:50:26 2010
New Revision: 961906

URL: http://svn.apache.org/viewvc?rev=961906&view=rev
Log:
Fix for occasional failed tests caused by responding with 202 success to 
compaction requests before the compaction actually begins.

Modified:
couchdb/branches/0.11.x/src/couchdb/couch_db.erl
couchdb/branches/0.11.x/src/couchdb/couch_db_updater.erl

Modified: couchdb/branches/0.11.x/src/couchdb/couch_db.erl
URL: 
http://svn.apache.org/viewvc/couchdb/branches/0.11.x/src/couchdb/couch_db.erl?rev=961906&r1=961905&r2=961906&view=diff
==
--- couchdb/branches/0.11.x/src/couchdb/couch_db.erl (original)
+++ couchdb/branches/0.11.x/src/couchdb/couch_db.erl Thu Jul  8 19:50:26 2010
@@ -103,7 +103,7 @@ monitor(#db{main_pid=MainPid}) ->
 erlang:monitor(process, MainPid).
 
 start_compact(#db{update_pid=Pid}) ->
-gen_server:cast(Pid, start_compact).
+gen_server:call(Pid, start_compact).
 
 delete_doc(Db, Id, Revisions) ->
 DeletedDocs = [#doc{id=Id, revs=[Rev], deleted=true} || Rev <- Revisions],

Modified: couchdb/branches/0.11.x/src/couchdb/couch_db_updater.erl
URL: 
http://svn.apache.org/viewvc/couchdb/branches/0.11.x/src/couchdb/couch_db_updater.erl?rev=961906&r1=961905&r2=961906&view=diff
==
--- couchdb/branches/0.11.x/src/couchdb/couch_db_updater.erl (original)
+++ couchdb/branches/0.11.x/src/couchdb/couch_db_updater.erl Thu Jul  8 
19:50:26 2010
@@ -133,21 +133,22 @@ handle_call({purge_docs, IdRevs}, _From,
 
 ok = gen_server:call(Db2#db.main_pid, {db_updated, Db2}),
 couch_db_update_notifier:notify({updated, Db#db.name}),
-{reply, {ok, (Db2#db.header)#db_header.purge_seq, IdRevsPurged}, Db2}.
-
-
-handle_cast(start_compact, Db) ->
+{reply, {ok, (Db2#db.header)#db_header.purge_seq, IdRevsPurged}, Db2};
+handle_call(start_compact, _From, Db) ->
 case Db#db.compactor_pid of
 nil ->
 ?LOG_INFO("Starting compaction for db \"~s\"", [Db#db.name]),
 Pid = spawn_link(fun() -> start_copy_compact(Db) end),
 Db2 = Db#db{compactor_pid=Pid},
 ok = gen_server:call(Db#db.main_pid, {db_updated, Db2}),
-{noreply, Db2};
+{reply, ok, Db2};
 _ ->
 % compact currently running, this is a no-op
-{noreply, Db}
-end;
+{reply, ok, Db}
+end.
+
+
+
 handle_cast({compact_done, CompactFilepath}, #db{filepath=Filepath}=Db) ->
 {ok, NewFd} = couch_file:open(CompactFilepath),
 {ok, NewHeader} = couch_file:read_header(NewFd),




svn commit: r961905 - /couchdb/branches/1.0.x/src/couchdb/couch_httpd_db.erl

2010-07-08 Thread jchris
Author: jchris
Date: Thu Jul  8 19:47:43 2010
New Revision: 961905

URL: http://svn.apache.org/viewvc?rev=961905&view=rev
Log:
validate admin and content type for compact requests

Modified:
couchdb/branches/1.0.x/src/couchdb/couch_httpd_db.erl

Modified: couchdb/branches/1.0.x/src/couchdb/couch_httpd_db.erl
URL: 
http://svn.apache.org/viewvc/couchdb/branches/1.0.x/src/couchdb/couch_httpd_db.erl?rev=961905&r1=961904&r2=961905&view=diff
==
--- couchdb/branches/1.0.x/src/couchdb/couch_httpd_db.erl (original)
+++ couchdb/branches/1.0.x/src/couchdb/couch_httpd_db.erl Thu Jul  8 19:47:43 
2010
@@ -111,12 +111,15 @@ handle_changes_req(#httpd{method='GET'}=
 handle_changes_req(#httpd{path_parts=[_,<<"_changes">>]}=Req, _Db) ->
 send_method_not_allowed(Req, "GET,HEAD").
 
-handle_compact_req(#httpd{method='POST',path_parts=[DbName,_,Id|_]}=Req, _Db) 
->
+handle_compact_req(#httpd{method='POST',path_parts=[DbName,_,Id|_]}=Req, Db) ->
+ok = couch_db:check_is_admin(Db),
 couch_httpd:validate_ctype(Req, "application/json"),
 ok = couch_view_compactor:start_compact(DbName, Id),
 send_json(Req, 202, {[{ok, true}]});
 
 handle_compact_req(#httpd{method='POST'}=Req, Db) ->
+ok = couch_db:check_is_admin(Db),
+couch_httpd:validate_ctype(Req, "application/json"),
 ok = couch_db:start_compact(Db),
 send_json(Req, 202, {[{ok, true}]});
 
@@ -125,6 +128,8 @@ handle_compact_req(Req, _Db) ->
 
 handle_view_cleanup_req(#httpd{method='POST'}=Req, Db) ->
 % delete unreferenced index files
+ok = couch_db:check_is_admin(Db),
+couch_httpd:validate_ctype(Req, "application/json"),
 ok = couch_view:cleanup_index_files(Db),
 send_json(Req, 202, {[{ok, true}]});
 




svn commit: r961904 - /couchdb/trunk/src/couchdb/couch_httpd_db.erl

2010-07-08 Thread jchris
Author: jchris
Date: Thu Jul  8 19:47:08 2010
New Revision: 961904

URL: http://svn.apache.org/viewvc?rev=961904&view=rev
Log:
validate admin and content type for compact requests

Modified:
couchdb/trunk/src/couchdb/couch_httpd_db.erl

Modified: couchdb/trunk/src/couchdb/couch_httpd_db.erl
URL: 
http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_httpd_db.erl?rev=961904&r1=961903&r2=961904&view=diff
==
--- couchdb/trunk/src/couchdb/couch_httpd_db.erl (original)
+++ couchdb/trunk/src/couchdb/couch_httpd_db.erl Thu Jul  8 19:47:08 2010
@@ -111,12 +111,15 @@ handle_changes_req(#httpd{method='GET'}=
 handle_changes_req(#httpd{path_parts=[_,<<"_changes">>]}=Req, _Db) ->
 send_method_not_allowed(Req, "GET,HEAD").
 
-handle_compact_req(#httpd{method='POST',path_parts=[DbName,_,Id|_]}=Req, _Db) 
->
+handle_compact_req(#httpd{method='POST',path_parts=[DbName,_,Id|_]}=Req, Db) ->
+ok = couch_db:check_is_admin(Db),
 couch_httpd:validate_ctype(Req, "application/json"),
 ok = couch_view_compactor:start_compact(DbName, Id),
 send_json(Req, 202, {[{ok, true}]});
 
 handle_compact_req(#httpd{method='POST'}=Req, Db) ->
+ok = couch_db:check_is_admin(Db),
+couch_httpd:validate_ctype(Req, "application/json"),
 ok = couch_db:start_compact(Db),
 send_json(Req, 202, {[{ok, true}]});
 
@@ -125,6 +128,8 @@ handle_compact_req(Req, _Db) ->
 
 handle_view_cleanup_req(#httpd{method='POST'}=Req, Db) ->
 % delete unreferenced index files
+ok = couch_db:check_is_admin(Db),
+couch_httpd:validate_ctype(Req, "application/json"),
 ok = couch_view:cleanup_index_files(Db),
 send_json(Req, 202, {[{ok, true}]});
 




svn commit: r961857 - in /couchdb/branches/1.0.x/src/couchdb: couch_db.erl couch_db_updater.erl

2010-07-08 Thread jchris
Author: jchris
Date: Thu Jul  8 18:11:47 2010
New Revision: 961857

URL: http://svn.apache.org/viewvc?rev=961857&view=rev
Log:
Fix for occasional failed tests caused by responding with 202 success to 
compaction requests before the compaction actually begins.

Modified:
couchdb/branches/1.0.x/src/couchdb/couch_db.erl
couchdb/branches/1.0.x/src/couchdb/couch_db_updater.erl

Modified: couchdb/branches/1.0.x/src/couchdb/couch_db.erl
URL: 
http://svn.apache.org/viewvc/couchdb/branches/1.0.x/src/couchdb/couch_db.erl?rev=961857&r1=961856&r2=961857&view=diff
==
--- couchdb/branches/1.0.x/src/couchdb/couch_db.erl (original)
+++ couchdb/branches/1.0.x/src/couchdb/couch_db.erl Thu Jul  8 18:11:47 2010
@@ -103,7 +103,7 @@ monitor(#db{main_pid=MainPid}) ->
 erlang:monitor(process, MainPid).
 
 start_compact(#db{update_pid=Pid}) ->
-gen_server:cast(Pid, start_compact).
+gen_server:call(Pid, start_compact).
 
 delete_doc(Db, Id, Revisions) ->
 DeletedDocs = [#doc{id=Id, revs=[Rev], deleted=true} || Rev <- Revisions],

Modified: couchdb/branches/1.0.x/src/couchdb/couch_db_updater.erl
URL: 
http://svn.apache.org/viewvc/couchdb/branches/1.0.x/src/couchdb/couch_db_updater.erl?rev=961857&r1=961856&r2=961857&view=diff
==
--- couchdb/branches/1.0.x/src/couchdb/couch_db_updater.erl (original)
+++ couchdb/branches/1.0.x/src/couchdb/couch_db_updater.erl Thu Jul  8 18:11:47 
2010
@@ -143,21 +143,22 @@ handle_call({purge_docs, IdRevs}, _From,
 
 ok = gen_server:call(Db2#db.main_pid, {db_updated, Db2}),
 couch_db_update_notifier:notify({updated, Db#db.name}),
-{reply, {ok, (Db2#db.header)#db_header.purge_seq, IdRevsPurged}, Db2}.
-
-
-handle_cast(start_compact, Db) ->
+{reply, {ok, (Db2#db.header)#db_header.purge_seq, IdRevsPurged}, Db2};
+handle_call(start_compact, _From, Db) ->
 case Db#db.compactor_pid of
 nil ->
 ?LOG_INFO("Starting compaction for db \"~s\"", [Db#db.name]),
 Pid = spawn_link(fun() -> start_copy_compact(Db) end),
 Db2 = Db#db{compactor_pid=Pid},
 ok = gen_server:call(Db#db.main_pid, {db_updated, Db2}),
-{noreply, Db2};
+{reply, ok, Db2};
 _ ->
 % compact currently running, this is a no-op
-{noreply, Db}
-end;
+{reply, ok, Db}
+end.
+
+
+
 handle_cast({compact_done, CompactFilepath}, #db{filepath=Filepath}=Db) ->
 {ok, NewFd} = couch_file:open(CompactFilepath),
 {ok, NewHeader} = couch_file:read_header(NewFd),




svn commit: r961856 - /couchdb/branches/1.0.x/share/www/script/jquery.couch.js

2010-07-08 Thread jchris
Author: jchris
Date: Thu Jul  8 18:10:56 2010
New Revision: 961856

URL: http://svn.apache.org/viewvc?rev=961856&view=rev
Log:
use json as the default content-type for requests from jquery.couch.js

Modified:
couchdb/branches/1.0.x/share/www/script/jquery.couch.js

Modified: couchdb/branches/1.0.x/share/www/script/jquery.couch.js
URL: 
http://svn.apache.org/viewvc/couchdb/branches/1.0.x/share/www/script/jquery.couch.js?rev=961856&r1=961855&r2=961856&view=diff
==
--- couchdb/branches/1.0.x/share/www/script/jquery.couch.js [utf-8] (original)
+++ couchdb/branches/1.0.x/share/www/script/jquery.couch.js [utf-8] Thu Jul  8 
18:10:56 2010
@@ -595,6 +595,7 @@
 
   function ajax(obj, options, errorMessage, ajaxOptions) {
 options = $.extend({successStatus: 200}, options);
+ajaxOptions = $.extend({contentType: "application/json"}, ajaxOptions);
 errorMessage = errorMessage || "Unknown error";
 $.ajax($.extend($.extend({
   type: "GET", dataType: "json", cache : !$.browser.msie,




svn commit: r961855 - /couchdb/branches/0.11.x/share/www/script/jquery.couch.js

2010-07-08 Thread jchris
Author: jchris
Date: Thu Jul  8 18:10:13 2010
New Revision: 961855

URL: http://svn.apache.org/viewvc?rev=961855&view=rev
Log:
use json as the default content-type for requests from jquery.couch.js

Modified:
couchdb/branches/0.11.x/share/www/script/jquery.couch.js

Modified: couchdb/branches/0.11.x/share/www/script/jquery.couch.js
URL: 
http://svn.apache.org/viewvc/couchdb/branches/0.11.x/share/www/script/jquery.couch.js?rev=961855&r1=961854&r2=961855&view=diff
==
--- couchdb/branches/0.11.x/share/www/script/jquery.couch.js [utf-8] (original)
+++ couchdb/branches/0.11.x/share/www/script/jquery.couch.js [utf-8] Thu Jul  8 
18:10:13 2010
@@ -595,6 +595,7 @@
 
   function ajax(obj, options, errorMessage, ajaxOptions) {
 options = $.extend({successStatus: 200}, options);
+ajaxOptions = $.extend({contentType: "application/json"}, ajaxOptions);
 errorMessage = errorMessage || "Unknown error";
 $.ajax($.extend($.extend({
   type: "GET", dataType: "json", cache : !$.browser.msie,




svn commit: r961854 - /couchdb/trunk/share/www/script/jquery.couch.js

2010-07-08 Thread jchris
Author: jchris
Date: Thu Jul  8 18:09:20 2010
New Revision: 961854

URL: http://svn.apache.org/viewvc?rev=961854&view=rev
Log:
use json as the default content-type for requests from jquery.couch.js

Modified:
couchdb/trunk/share/www/script/jquery.couch.js

Modified: couchdb/trunk/share/www/script/jquery.couch.js
URL: 
http://svn.apache.org/viewvc/couchdb/trunk/share/www/script/jquery.couch.js?rev=961854&r1=961853&r2=961854&view=diff
==
--- couchdb/trunk/share/www/script/jquery.couch.js [utf-8] (original)
+++ couchdb/trunk/share/www/script/jquery.couch.js [utf-8] Thu Jul  8 18:09:20 
2010
@@ -595,6 +595,7 @@
 
   function ajax(obj, options, errorMessage, ajaxOptions) {
 options = $.extend({successStatus: 200}, options);
+ajaxOptions = $.extend({contentType: "application/json"}, ajaxOptions);
 errorMessage = errorMessage || "Unknown error";
 $.ajax($.extend($.extend({
   type: "GET", dataType: "json", cache : !$.browser.msie,




svn commit: r961491 - in /couchdb/branches/1.0.x: CHANGES NEWS

2010-07-07 Thread jchris
Author: jchris
Date: Wed Jul  7 20:01:51 2010
New Revision: 961491

URL: http://svn.apache.org/viewvc?rev=961491&view=rev
Log:
fixup news and changes for 1.0

Modified:
couchdb/branches/1.0.x/CHANGES
couchdb/branches/1.0.x/NEWS

Modified: couchdb/branches/1.0.x/CHANGES
URL: 
http://svn.apache.org/viewvc/couchdb/branches/1.0.x/CHANGES?rev=961491&r1=961490&r2=961491&view=diff
==
--- couchdb/branches/1.0.x/CHANGES (original)
+++ couchdb/branches/1.0.x/CHANGES Wed Jul  7 20:01:51 2010
@@ -4,6 +4,27 @@ Apache CouchDB CHANGES
 Version 1.0.0
 --
 
+Security:
+
+* Added authentication caching, to avoid repeated opening and closing of the
+  users database for each request requiring authentication.
+
+Storage System:
+
+* Small optimization for reordering result lists.
+* More efficient header commits.
+* Use O_APPEND to save lseeks.
+* Faster implementation of pread_iolist(). Further improves performance on
+  concurrent reads.
+
+View Server:
+
+* Faster default view collation.
+* Added option to include update_seq in view responses.
+
+Version 0.11.1
+--
+
 HTTP Interface:
 
  * Mask passwords in active tasks and logging.
@@ -38,8 +59,6 @@ Build and System Integration:
 Security:
 
  * Added authentication redirect URL to log in clients.
- * Added authentication caching, to avoid repeated opening and closing of the
-   users database for each request requiring authentication.
  * Fixed query parameter encoding issue in oauth.js.
  * Made authentication timeout configurable.
  * Temporary views are now admin-only resources.
@@ -51,14 +70,9 @@ Storage System:
it's correct.
  * Make file deletions async to avoid pauses during compaction and db
deletion.
- * Small optimization for reordering result lists.
  * Fixed for wrong offset when writing headers and converting them to blocks,
only triggered when header is larger than 4k.
- * More efficient header commits.
  * Preserve _revs_limit and instance_start_time after compaction.
- * Use O_APPEND to save lseeks.
- * Faster implementation of pread_iolist(). Further improves performance on
-   concurrent reads.
 
 Configuration System:
 
@@ -79,9 +93,7 @@ View Server:
 
  * Provide a UUID to update functions (and all other functions) that they can
use to create new docs.
- * Faster default view collation.
  * Upgrade CommonJS modules support to 1.1.1.
- * Added option to include update_seq in view responses.
  * Fixed erlang filter funs and normalize filter fun API.
  * Fixed hang in view shutdown.
 

Modified: couchdb/branches/1.0.x/NEWS
URL: 
http://svn.apache.org/viewvc/couchdb/branches/1.0.x/NEWS?rev=961491&r1=961490&r2=961491&view=diff
==
--- couchdb/branches/1.0.x/NEWS (original)
+++ couchdb/branches/1.0.x/NEWS Wed Jul  7 20:01:51 2010
@@ -10,6 +10,21 @@ Each release section notes when backward
 Version 1.0.0
 --
 
+This version has not yet been released.
+
+* More efficient header commits.
+* Use O_APPEND to save lseeks.
+* Faster implementation of pread_iolist(). Further improves performance on
+  concurrent reads.
+* Added authentication caching
+* Faster default view collation.
+* Added option to include update_seq in view responses.
+
+Version 0.11.1
+--
+
+This version has not yet been released.
+
  * Mask passwords in active tasks and logging.
  * Update mochijson2 to allow output of BigNums not in float form.
  * Added support for X-HTTP-METHOD-OVERRIDE.
@@ -36,11 +51,7 @@ Version 1.0.0
deletion.
  * Fixed for wrong offset when writing headers and converting them to blocks,
only triggered when header is larger than 4k.
- * More efficient header commits.
  * Preserve _revs_limit and instance_start_time after compaction.
- * Use O_APPEND to save lseeks.
- * Faster implementation of pread_iolist(). Further improves performance on
-   concurrent reads.
  * Fixed timeout with large .ini files.
  * Added tests for couch.js and jquery.couch.js
  * Added various API features to jquery.couch.js




svn commit: r961488 - /couchdb/branches/0.11.x/NEWS

2010-07-07 Thread jchris
Author: jchris
Date: Wed Jul  7 19:54:06 2010
New Revision: 961488

URL: http://svn.apache.org/viewvc?rev=961488&view=rev
Log:
fix version number

Modified:
couchdb/branches/0.11.x/NEWS

Modified: couchdb/branches/0.11.x/NEWS
URL: 
http://svn.apache.org/viewvc/couchdb/branches/0.11.x/NEWS?rev=961488&r1=961487&r2=961488&view=diff
==
--- couchdb/branches/0.11.x/NEWS (original)
+++ couchdb/branches/0.11.x/NEWS Wed Jul  7 19:54:06 2010
@@ -7,7 +7,7 @@ For details about backwards incompatible
 
 Each release section notes when backwards incompatible changes have been made.
 
-Version 1.0.0
+Version 0.11.1
 -
 
 This Version has not been released yet.




svn commit: r961395 - /couchdb/trunk/share/www/config.html

2010-07-07 Thread jchris
Author: jchris
Date: Wed Jul  7 14:47:47 2010
New Revision: 961395

URL: http://svn.apache.org/viewvc?rev=961395&view=rev
Log:
link to wiki discussion of delayed_commits configuration from the config page 
of Futon

Modified:
couchdb/trunk/share/www/config.html

Modified: couchdb/trunk/share/www/config.html
URL: 
http://svn.apache.org/viewvc/couchdb/trunk/share/www/config.html?rev=961395&r1=961394&r2=961395&view=diff
==
--- couchdb/trunk/share/www/config.html (original)
+++ couchdb/trunk/share/www/config.html Wed Jul  7 14:47:47 2010
@@ -116,7 +116,9 @@ specific language governing permissions 
 Note: Some configuration options may require
 restarting the server to take effect after modification.
   
-
+  
+   For the strongest consistency guarantees, delayed_commits 
should be set to false. The default value of true is designed 
for single-user performance. For more details see http://wiki.apache.org/couchdb/Durability_Matrix";>a discussion of 
durability on the CouchDB wiki.
+  
   
 Configuration
 




svn commit: r961052 - /couchdb/trunk/share/www/script/futon.browse.js

2010-07-06 Thread jchris
Author: jchris
Date: Wed Jul  7 01:05:01 2010
New Revision: 961052

URL: http://svn.apache.org/viewvc?rev=961052&view=rev
Log:
avoid Futon popup when listing databases that cant be accessed

Modified:
couchdb/trunk/share/www/script/futon.browse.js

Modified: couchdb/trunk/share/www/script/futon.browse.js
URL: 
http://svn.apache.org/viewvc/couchdb/trunk/share/www/script/futon.browse.js?rev=961052&r1=961051&r2=961052&view=diff
==
--- couchdb/trunk/share/www/script/futon.browse.js [utf-8] (original)
+++ couchdb/trunk/share/www/script/futon.browse.js [utf-8] Wed Jul  7 01:05:01 
2010
@@ -62,7 +62,8 @@
 
.find("td.size").text($.futon.formatSize(info.disk_size)).end()
 .find("td.count").text(info.doc_count).end()
 .find("td.seq").text(info.update_seq);
-}
+},
+error : function() {}
   });
 });
 $("#databases tbody tr:odd").addClass("odd");




svn commit: r961050 - /couchdb/branches/0.11.x/share/www/script/jquery.couch.js

2010-07-06 Thread jchris
Author: jchris
Date: Wed Jul  7 00:31:12 2010
New Revision: 961050

URL: http://svn.apache.org/viewvc?rev=961050&view=rev
Log:
finish backport jquery.couch.js client code to 0.11.x. closes COUCHDB-819. 
Thanks Nome Consulting for pointing out the bug

Modified:
couchdb/branches/0.11.x/share/www/script/jquery.couch.js

Modified: couchdb/branches/0.11.x/share/www/script/jquery.couch.js
URL: 
http://svn.apache.org/viewvc/couchdb/branches/0.11.x/share/www/script/jquery.couch.js?rev=961050&r1=961049&r2=961050&view=diff
==
--- couchdb/branches/0.11.x/share/www/script/jquery.couch.js [utf-8] (original)
+++ couchdb/branches/0.11.x/share/www/script/jquery.couch.js [utf-8] Wed Jul  7 
00:31:12 2010
@@ -290,8 +290,19 @@
   return promise;
 },
 allDocs: function(options) {
-  ajax(
-{url: this.uri + "_all_docs" + encodeOptions(options)},
+  var type = "GET";
+  var data = null;
+  if (options["keys"]) {
+type = "POST";
+var keys = options["keys"];
+delete options["keys"];
+data = toJSON({ "keys": keys });
+  }
+  ajax({
+  type: type,
+  data: data,
+  url: this.uri + "_all_docs" + encodeOptions(options)
+},
 options,
 "An error occurred retrieving a list of all documents"
   );
@@ -330,7 +341,7 @@
 openDoc: function(docId, options, ajaxOptions) {
   options = options || {};
   if (db_opts.attachPrevRev || options.attachPrevRev) {
-$.extend(options, {
+$.extend(ajaxOptions, {
   beforeSuccess : function(req, doc) {
 rawDocs[doc._id] = {
   rev : doc._rev,
@@ -339,7 +350,7 @@
   }
 });
   } else {
-$.extend(options, {
+$.extend(ajaxOptions, {
   beforeSuccess : function(req, doc) {
 if (doc["jquery.couch.attachPrevRev"]) {
   rawDocs[doc._id] = {
@@ -372,6 +383,7 @@
 type: method, url: uri + encodeOptions(options),
 contentType: "application/json",
 dataType: "json", data: toJSON(doc),
+beforeSend : beforeSend,
 complete: function(req) {
   var resp = $.httpData(req, "json");
   if (req.status == 200 || req.status == 201 || req.status == 202) 
{
@@ -397,7 +409,8 @@
   });
 },
 bulkSave: function(docs, options) {
-  $.extend(options, {successStatus: 201});
+  var beforeSend = fullCommit(options);
+  $.extend(options, {successStatus: 201, beforeSend : beforeSend});
   ajax({
   type: "POST",
   url: this.uri + "_bulk_docs" + encodeOptions(options),
@@ -549,7 +562,7 @@
 },
 
 replicate: function(source, target, ajaxOptions, repOpts) {
-  $.extend(repOpts, {source: source, target: target});
+  repOpts = $.extend({source: source, target: target}, repOpts);
   if (repOpts.continuous) {
 ajaxOptions.successStatus = 202;
   }
@@ -618,6 +631,17 @@
 }, obj), ajaxOptions));
   }
 
+  function fullCommit(options) {
+var options = options || {};
+if (typeof options.ensure_full_commit !== "undefined") {
+  var commit = options.ensure_full_commit;
+  delete options.ensure_full_commit;
+  return function(xhr) {
+xhr.setRequestHeader("X-Couch-Full-Commit", commit.toString());
+  };
+}
+  };
+
   // Convert a options object to an url query string.
   // ex: {key:'value',key2:'value2'} becomes '?key="value"&key2="value2"'
   function encodeOptions(options) {




svn commit: r960975 - /couchdb/trunk/src/couchdb/couch_httpd.erl

2010-07-06 Thread jchris
Author: jchris
Date: Tue Jul  6 18:36:27 2010
New Revision: 960975

URL: http://svn.apache.org/viewvc?rev=960975&view=rev
Log:
dont redirect endlessly when require_valid_user=true

Modified:
couchdb/trunk/src/couchdb/couch_httpd.erl

Modified: couchdb/trunk/src/couchdb/couch_httpd.erl
URL: 
http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_httpd.erl?rev=960975&r1=960974&r2=960975&view=diff
==
--- couchdb/trunk/src/couchdb/couch_httpd.erl (original)
+++ couchdb/trunk/src/couchdb/couch_httpd.erl Tue Jul  6 18:36:27 2010
@@ -748,15 +748,20 @@ error_headers(#httpd{mochi_req=MochiReq}
 case couch_config:get("couch_httpd_auth", 
"authentication_redirect", nil) of
 nil -> {Code, []};
 AuthRedirect ->
-% if the accept header matches html, then do the 
redirect. else proceed as usual.
-case re:run(MochiReq:get_header_value("Accept"), 
"html", [{capture, none}]) of
-nomatch ->
+case couch_config:get("couch_httpd_auth", 
"require_valid_user", "false") of
+"true" ->
 {Code, []};
-match ->
-AuthRedirectBin = ?l2b(AuthRedirect),
-UrlReturn = 
?l2b(couch_util:url_encode(MochiReq:get(path))),
-UrlReason = ?l2b(couch_util:url_encode(ReasonStr)),
-{302, [{"Location", couch_httpd:absolute_uri(Req, 
<
+{Code, []};
+match ->
+AuthRedirectBin = ?l2b(AuthRedirect),
+UrlReturn = 
?l2b(couch_util:url_encode(MochiReq:get(path))),
+UrlReason = 
?l2b(couch_util:url_encode(ReasonStr)),
+{302, [{"Location", 
couch_httpd:absolute_uri(Req, 
<

svn commit: r960369 - /couchdb/branches/0.11.x/src/couchdb/couch_httpd_misc_handlers.erl

2010-07-04 Thread jchris
Author: jchris
Date: Sun Jul  4 17:41:29 2010
New Revision: 960369

URL: http://svn.apache.org/viewvc?rev=960369&view=rev
Log:
_log should be an admin-only resource

Modified:
couchdb/branches/0.11.x/src/couchdb/couch_httpd_misc_handlers.erl

Modified: couchdb/branches/0.11.x/src/couchdb/couch_httpd_misc_handlers.erl
URL: 
http://svn.apache.org/viewvc/couchdb/branches/0.11.x/src/couchdb/couch_httpd_misc_handlers.erl?rev=960369&r1=960368&r2=960369&view=diff
==
--- couchdb/branches/0.11.x/src/couchdb/couch_httpd_misc_handlers.erl (original)
+++ couchdb/branches/0.11.x/src/couchdb/couch_httpd_misc_handlers.erl Sun Jul  
4 17:41:29 2010
@@ -199,6 +199,7 @@ increment_update_seq_req(Req, _Db) ->
 % httpd log handlers
 
 handle_log_req(#httpd{method='GET'}=Req) ->
+ok = couch_httpd:verify_is_server_admin(Req),
 Bytes = list_to_integer(couch_httpd:qs_value(Req, "bytes", "1000")),
 Offset = list_to_integer(couch_httpd:qs_value(Req, "offset", "0")),
 Chunk = couch_log:read(Bytes, Offset),




svn commit: r960363 - /couchdb/trunk/src/couchdb/couch_httpd_misc_handlers.erl

2010-07-04 Thread jchris
Author: jchris
Date: Sun Jul  4 17:22:22 2010
New Revision: 960363

URL: http://svn.apache.org/viewvc?rev=960363&view=rev
Log:
_log should be an admin-only resource

Modified:
couchdb/trunk/src/couchdb/couch_httpd_misc_handlers.erl

Modified: couchdb/trunk/src/couchdb/couch_httpd_misc_handlers.erl
URL: 
http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_httpd_misc_handlers.erl?rev=960363&r1=960362&r2=960363&view=diff
==
--- couchdb/trunk/src/couchdb/couch_httpd_misc_handlers.erl (original)
+++ couchdb/trunk/src/couchdb/couch_httpd_misc_handlers.erl Sun Jul  4 17:22:22 
2010
@@ -199,6 +199,7 @@ increment_update_seq_req(Req, _Db) ->
 % httpd log handlers
 
 handle_log_req(#httpd{method='GET'}=Req) ->
+ok = couch_httpd:verify_is_server_admin(Req),
 Bytes = list_to_integer(couch_httpd:qs_value(Req, "bytes", "1000")),
 Offset = list_to_integer(couch_httpd:qs_value(Req, "offset", "0")),
 Chunk = couch_log:read(Bytes, Offset),




svn commit: r960148 - /couchdb/trunk/share/www/script/jquery.couch.js

2010-07-02 Thread jchris
Author: jchris
Date: Sat Jul  3 01:24:12 2010
New Revision: 960148

URL: http://svn.apache.org/viewvc?rev=960148&view=rev
Log:
fix jquery.couch.js replicate options

Modified:
couchdb/trunk/share/www/script/jquery.couch.js

Modified: couchdb/trunk/share/www/script/jquery.couch.js
URL: 
http://svn.apache.org/viewvc/couchdb/trunk/share/www/script/jquery.couch.js?rev=960148&r1=960147&r2=960148&view=diff
==
--- couchdb/trunk/share/www/script/jquery.couch.js [utf-8] (original)
+++ couchdb/trunk/share/www/script/jquery.couch.js [utf-8] Sat Jul  3 01:24:12 
2010
@@ -562,7 +562,7 @@
 },
 
 replicate: function(source, target, ajaxOptions, repOpts) {
-  $.extend(repOpts, {source: source, target: target});
+  repOpts = $.extend({source: source, target: target}, repOpts);
   if (repOpts.continuous) {
 ajaxOptions.successStatus = 202;
   }




svn commit: r960086 - /couchdb/trunk/NEWS

2010-07-02 Thread jchris
Author: jchris
Date: Fri Jul  2 18:56:05 2010
New Revision: 960086

URL: http://svn.apache.org/viewvc?rev=960086&view=rev
Log:
make NEWS reflect that the next release will be 1.0.0

Modified:
couchdb/trunk/NEWS

Modified: couchdb/trunk/NEWS
URL: 
http://svn.apache.org/viewvc/couchdb/trunk/NEWS?rev=960086&r1=960085&r2=960086&view=diff
==
--- couchdb/trunk/NEWS (original)
+++ couchdb/trunk/NEWS Fri Jul  2 18:56:05 2010
@@ -7,7 +7,7 @@ For details about backwards incompatible
 
 Each release section notes when backwards incompatible changes have been made.
 
-Version 1.1.0
+Version 1.0.0
 --
 
 This version has not been released yet.




svn commit: r960085 - /couchdb/trunk/etc/couchdb/local.ini

2010-07-02 Thread jchris
Author: jchris
Date: Fri Jul  2 18:39:17 2010
New Revision: 960085

URL: http://svn.apache.org/viewvc?rev=960085&view=rev
Log:
helpful note about configuring require_valid_user=true

Modified:
couchdb/trunk/etc/couchdb/local.ini

Modified: couchdb/trunk/etc/couchdb/local.ini
URL: 
http://svn.apache.org/viewvc/couchdb/trunk/etc/couchdb/local.ini?rev=960085&r1=960084&r2=960085&view=diff
==
--- couchdb/trunk/etc/couchdb/local.ini (original)
+++ couchdb/trunk/etc/couchdb/local.ini Fri Jul  2 18:39:17 2010
@@ -13,6 +13,10 @@
 ; Uncomment next line to trigger basic-auth popup on unauthorized requests.
 ;WWW-Authenticate = Basic realm="administrator"
 
+[couch_httpd_auth]
+; if you set this to true, you should also uncomment the WWW-Authenticate line 
above
+; require_valid_user = false
+
 [log]
 ;level = debug
 




svn commit: r960084 - /couchdb/trunk/src/couchdb/couch_js_functions.hrl

2010-07-02 Thread jchris
Author: jchris
Date: Fri Jul  2 18:39:15 2010
New Revision: 960084

URL: http://svn.apache.org/viewvc?rev=960084&view=rev
Log:
fix edge case in users db validation fun

Modified:
couchdb/trunk/src/couchdb/couch_js_functions.hrl

Modified: couchdb/trunk/src/couchdb/couch_js_functions.hrl
URL: 
http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_js_functions.hrl?rev=960084&r1=960083&r2=960084&view=diff
==
--- couchdb/trunk/src/couchdb/couch_js_functions.hrl (original)
+++ couchdb/trunk/src/couchdb/couch_js_functions.hrl Fri Jul  2 18:39:15 2010
@@ -12,9 +12,9 @@
 
 -define(AUTH_DB_DOC_VALIDATE_FUNCTION, <<"
 function(newDoc, oldDoc, userCtx) {
-if ((oldDoc || newDoc).type !== 'user') {
+if ((oldDoc && oldDoc.type !== 'user') || newDoc.type !== 'user') {
 throw({forbidden : 'doc.type must be user'});
-} // we only validate user docs for now
+} // we only allow user docs for now
 
 if (newDoc._deleted === true) {
 // allow deletes by admins and matching users




svn commit: r960078 - /couchdb/trunk/share/www/script/test/list_views.js

2010-07-02 Thread jchris
Author: jchris
Date: Fri Jul  2 18:05:18 2010
New Revision: 960078

URL: http://svn.apache.org/viewvc?rev=960078&view=rev
Log:
fix a query parameter in the list_views.js test

Modified:
couchdb/trunk/share/www/script/test/list_views.js

Modified: couchdb/trunk/share/www/script/test/list_views.js
URL: 
http://svn.apache.org/viewvc/couchdb/trunk/share/www/script/test/list_views.js?rev=960078&r1=960077&r2=960078&view=diff
==
--- couchdb/trunk/share/www/script/test/list_views.js (original)
+++ couchdb/trunk/share/www/script/test/list_views.js Fri Jul  2 18:05:18 2010
@@ -220,7 +220,7 @@ couchTests.list_views = function(debug) 
   T(etag1 != etag2, "POST to map _list generates key-depdendent ETags");
 
   // test the richness of the arguments
-  xhr = CouchDB.request("GET", 
"/test_suite_db/_design/lists/_list/basicJSON/basicView");
+  xhr = CouchDB.request("GET", 
"/test_suite_db/_design/lists/_list/basicJSON/basicView?update_seq=true");
   T(xhr.status == 200, "standard get should be 200");
   var resp = JSON.parse(xhr.responseText);
   TEquals(10, resp.head.total_rows);




svn commit: r960067 - /couchdb/trunk/share/www/script/jquery.editinline.js

2010-07-02 Thread jchris
Author: jchris
Date: Fri Jul  2 17:42:06 2010
New Revision: 960067

URL: http://svn.apache.org/viewvc?rev=960067&view=rev
Log:
Revert "click to edit config in Futon instead of double click. thanks Aaron 
Miller"
Turns out this has some issues. Getting Futon to work nicely on tap-style 
mobile browsers will require a deeper look.

This reverts commit be39860688e01e0d0749fdbefdd226d790133219.

Modified:
couchdb/trunk/share/www/script/jquery.editinline.js

Modified: couchdb/trunk/share/www/script/jquery.editinline.js
URL: 
http://svn.apache.org/viewvc/couchdb/trunk/share/www/script/jquery.editinline.js?rev=960067&r1=960066&r2=960067&view=diff
==
--- couchdb/trunk/share/www/script/jquery.editinline.js (original)
+++ couchdb/trunk/share/www/script/jquery.editinline.js Fri Jul  2 17:42:06 2010
@@ -90,7 +90,7 @@
   allowEmpty: true,
   acceptLabel: "",
   cancelLabel: "",
-  toolTip: "Click to edit",
+  toolTip: "Double click to edit",
   acceptOnBlur: true,
 
   // callbacks
@@ -105,7 +105,7 @@
 }, options || {});
 
 return this.each(function() {
-  $(this).attr("title", options.toolTip).click(function() {
+  $(this).attr("title", options.toolTip).dblclick(function() {
 startEditing(this, options);
   });
 });




svn commit: r959814 - /couchdb/trunk/share/www/script/test/uuids.js

2010-07-01 Thread jchris
Author: jchris
Date: Thu Jul  1 23:47:04 2010
New Revision: 959814

URL: http://svn.apache.org/viewvc?rev=959814&view=rev
Log:
more robust uuids test

Modified:
couchdb/trunk/share/www/script/test/uuids.js

Modified: couchdb/trunk/share/www/script/test/uuids.js
URL: 
http://svn.apache.org/viewvc/couchdb/trunk/share/www/script/test/uuids.js?rev=959814&r1=959813&r2=959814&view=diff
==
--- couchdb/trunk/share/www/script/test/uuids.js (original)
+++ couchdb/trunk/share/www/script/test/uuids.js Thu Jul  1 23:47:04 2010
@@ -93,12 +93,20 @@ couchTests.uuids = function(debug) {
 xhr = CouchDB.request("GET", "/_uuids?count=1000");
 T(xhr.status == 200);
 result = JSON.parse(xhr.responseText);
-for(var i = 1; i < result.uuids.length; i++) {
-  T(result.uuids[i].length == 32);
-  var u1 = result.uuids[i-1].substr(0, 13);
-  var u2 = result.uuids[i].substr(0, 13);
-  T(u1 < u2, "UTC uuids are only roughly ordered, so this assertion may 
fail occasionally. Don't sweat it.");
+T(result.uuids[1].length == 32);
+
+// no collisions
+var seen = {};
+for(var i in result.uuids) {
+  var id = result.uuids[i];
+  T(seen[id] === undefined);
+  seen[id] = 1;
 }
+
+// roughly ordered
+var u1 = result.uuids[1].substr(0, 13);
+var u2 = result.uuids[result.uuids.length-1].substr(0, 13);
+T(u1 < u2, "UTC uuids are only roughly ordered, so this assertion may fail 
occasionally. Don't sweat it.");
   };
 
   run_on_modified_server([{




svn commit: r959791 - /couchdb/trunk/src/couchdb/couch_db_updater.erl

2010-07-01 Thread jchris
Author: jchris
Date: Thu Jul  1 21:37:49 2010
New Revision: 959791

URL: http://svn.apache.org/viewvc?rev=959791&view=rev
Log:
prevent zero byte files, closes COUCHDB-647

Modified:
couchdb/trunk/src/couchdb/couch_db_updater.erl

Modified: couchdb/trunk/src/couchdb/couch_db_updater.erl
URL: 
http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_db_updater.erl?rev=959791&r1=959790&r2=959791&view=diff
==
--- couchdb/trunk/src/couchdb/couch_db_updater.erl (original)
+++ couchdb/trunk/src/couchdb/couch_db_updater.erl Thu Jul  1 21:37:49 2010
@@ -30,7 +30,16 @@ init({MainPid, DbName, Filepath, Fd, Opt
 couch_file:delete(Filepath ++ ".compact");
 false ->
 ok = couch_file:upgrade_old_header(Fd, <<$g, $m, $k, 0>>), % 09 
UPGRADE CODE
-{ok, Header} = couch_file:read_header(Fd)
+case couch_file:read_header(Fd) of
+{ok, Header} ->
+ok;
+no_valid_header ->
+% create a new header and writes it to the file
+Header =  #db_header{},
+ok = couch_file:write_header(Fd, Header),
+% delete any old compaction files that might be hanging around
+file:delete(Filepath ++ ".compact")
+end
 end,
 
 Db = init_db(DbName, Filepath, Fd, Header),




svn commit: r959788 - /couchdb/trunk/share/www/script/jquery.editinline.js

2010-07-01 Thread jchris
Author: jchris
Date: Thu Jul  1 21:25:48 2010
New Revision: 959788

URL: http://svn.apache.org/viewvc?rev=959788&view=rev
Log:
click to edit config in Futon instead of double click. thanks Aaron Miller

Modified:
couchdb/trunk/share/www/script/jquery.editinline.js

Modified: couchdb/trunk/share/www/script/jquery.editinline.js
URL: 
http://svn.apache.org/viewvc/couchdb/trunk/share/www/script/jquery.editinline.js?rev=959788&r1=959787&r2=959788&view=diff
==
--- couchdb/trunk/share/www/script/jquery.editinline.js (original)
+++ couchdb/trunk/share/www/script/jquery.editinline.js Thu Jul  1 21:25:48 2010
@@ -90,7 +90,7 @@
   allowEmpty: true,
   acceptLabel: "",
   cancelLabel: "",
-  toolTip: "Double click to edit",
+  toolTip: "Click to edit",
   acceptOnBlur: true,
 
   // callbacks
@@ -105,7 +105,7 @@
 }, options || {});
 
 return this.each(function() {
-  $(this).attr("title", options.toolTip).dblclick(function() {
+  $(this).attr("title", options.toolTip).click(function() {
 startEditing(this, options);
   });
 });




svn commit: r958786 - in /couchdb/branches/0.11.x/etc/couchdb: default.ini.tpl.in local.ini

2010-06-28 Thread jchris
Author: jchris
Date: Mon Jun 28 23:21:27 2010
New Revision: 958786

URL: http://svn.apache.org/viewvc?rev=958786&view=rev
Log:
preserve 0.11 behavior while making 1.0-style authentication redirects 
configurable

Modified:
couchdb/branches/0.11.x/etc/couchdb/default.ini.tpl.in
couchdb/branches/0.11.x/etc/couchdb/local.ini

Modified: couchdb/branches/0.11.x/etc/couchdb/default.ini.tpl.in
URL: 
http://svn.apache.org/viewvc/couchdb/branches/0.11.x/etc/couchdb/default.ini.tpl.in?rev=958786&r1=958785&r2=958786&view=diff
==
--- couchdb/branches/0.11.x/etc/couchdb/default.ini.tpl.in (original)
+++ couchdb/branches/0.11.x/etc/couchdb/default.ini.tpl.in Mon Jun 28 23:21:27 
2010
@@ -28,7 +28,7 @@ level = info
 
 [couch_httpd_auth]
 authentication_db = _users
-authentication_redirect = /_utils/session.html
+authentication_redirect =
 require_valid_user = false
 timeout = 600 ; number of seconds before automatic logout
 

Modified: couchdb/branches/0.11.x/etc/couchdb/local.ini
URL: 
http://svn.apache.org/viewvc/couchdb/branches/0.11.x/etc/couchdb/local.ini?rev=958786&r1=958785&r2=958786&view=diff
==
--- couchdb/branches/0.11.x/etc/couchdb/local.ini (original)
+++ couchdb/branches/0.11.x/etc/couchdb/local.ini Mon Jun 28 23:21:27 2010
@@ -16,6 +16,10 @@
 [log]
 ;level = debug
 
+[couch_httpd_auth]
+; uncomment next line for 1.0-style user-friendly login redirects
+; authentication_redirect = /_utils/session.html
+
 
 ; To enable Virtual Hosts in CouchDB, add a vhost = path directive. All 
requests to
 ; the Virual Host will be redirected to the path. In the example below all 
requests




svn commit: r958054 - /couchdb/trunk/bin/couchdb.tpl.in

2010-06-25 Thread jchris
Author: jchris
Date: Fri Jun 25 17:59:47 2010
New Revision: 958054

URL: http://svn.apache.org/viewvc?rev=958054&view=rev
Log:
Increasing async threadpool.

Modified:
couchdb/trunk/bin/couchdb.tpl.in

Modified: couchdb/trunk/bin/couchdb.tpl.in
URL: 
http://svn.apache.org/viewvc/couchdb/trunk/bin/couchdb.tpl.in?rev=958054&r1=958053&r2=958054&view=diff
==
--- couchdb/trunk/bin/couchdb.tpl.in (original)
+++ couchdb/trunk/bin/couchdb.tpl.in Fri Jun 25 17:59:47 2010
@@ -221,7 +221,7 @@ start_couchdb () {
 touch $PID_FILE
 interactive_option="+Bd -noinput"
 fi
-command="%ERL% $interactive_option -sasl errlog_type error +K true \
+command="%ERL% $interactive_option -sasl errlog_type error +K true +A 4 \ 
 -env ERL_LIBS %localerlanglibdir% -couch_ini $start_arguments -s couch"
 if test "$BACKGROUND" = "true" -a "$RECURSED" = "false"; then
 $0 $background_start_arguments -b -r $RESPAWN_TIMEOUT -p $PID_FILE \




svn commit: r957808 - /couchdb/trunk/share/www/script/futon.js

2010-06-24 Thread jchris
Author: jchris
Date: Fri Jun 25 05:41:13 2010
New Revision: 957808

URL: http://svn.apache.org/viewvc?rev=957808&view=rev
Log:
fix the Futon issue where you have to cancel the admin dialog box after putting 
back admins that were removed to run the tests

Modified:
couchdb/trunk/share/www/script/futon.js

Modified: couchdb/trunk/share/www/script/futon.js
URL: 
http://svn.apache.org/viewvc/couchdb/trunk/share/www/script/futon.js?rev=957808&r1=957807&r2=957808&view=diff
==
--- couchdb/trunk/share/www/script/futon.js (original)
+++ couchdb/trunk/share/www/script/futon.js Fri Jun 25 05:41:13 2010
@@ -87,7 +87,11 @@ function $$(node) {
   return;
 }
 doSignup(data.name, null, function(errors) {
-  callback(errors);
+  if (errors && errors.name && errors.name.indexOf && 
errors.name.indexOf("taken") == -1) {
+callback(errors);
+  } else {
+callback();
+  }
   }, false);
 });
 }




svn commit: r957805 - in /couchdb/trunk: etc/couchdb/default.ini.tpl.in src/couchdb/couch_httpd.erl src/couchdb/couch_rep_writer.erl

2010-06-24 Thread jchris
Author: jchris
Date: Fri Jun 25 05:30:51 2010
New Revision: 957805

URL: http://svn.apache.org/viewvc?rev=957805&view=rev
Log:
make the authentication redirect URL configurable. setting it to the empty 
string yields the 0.11 behavior

Modified:
couchdb/trunk/etc/couchdb/default.ini.tpl.in
couchdb/trunk/src/couchdb/couch_httpd.erl
couchdb/trunk/src/couchdb/couch_rep_writer.erl

Modified: couchdb/trunk/etc/couchdb/default.ini.tpl.in
URL: 
http://svn.apache.org/viewvc/couchdb/trunk/etc/couchdb/default.ini.tpl.in?rev=957805&r1=957804&r2=957805&view=diff
==
--- couchdb/trunk/etc/couchdb/default.ini.tpl.in (original)
+++ couchdb/trunk/etc/couchdb/default.ini.tpl.in Fri Jun 25 05:30:51 2010
@@ -29,6 +29,7 @@ include_sasl = true
 
 [couch_httpd_auth]
 authentication_db = _users
+authentication_redirect = /_utils/session.html
 require_valid_user = false
 timeout = 600 ; number of seconds before automatic logout
 auth_cache_size = 50 ; size is number of cache entries

Modified: couchdb/trunk/src/couchdb/couch_httpd.erl
URL: 
http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_httpd.erl?rev=957805&r1=957804&r2=957805&view=diff
==
--- couchdb/trunk/src/couchdb/couch_httpd.erl (original)
+++ couchdb/trunk/src/couchdb/couch_httpd.erl Fri Jun 25 05:30:51 2010
@@ -745,14 +745,19 @@ error_headers(#httpd{mochi_req=MochiReq}
 % redirect to the session page.
 case ErrorStr of
 <<"unauthorized">> ->
-% if the accept header matches html, then do the redirect. 
else proceed as usual.
-case re:run(MochiReq:get_header_value("Accept"), "html", 
[{capture, none}]) of
-nomatch ->
-{Code, []};
-match ->
-UrlReturn = 
?l2b(couch_util:url_encode(MochiReq:get(path))),
-UrlReason = ?l2b(couch_util:url_encode(ReasonStr)),
-{302, [{"Location", couch_httpd:absolute_uri(Req, 
<<"/_utils/session.html?return=",UrlReturn/binary,"&reason=",UrlReason/binary>>)}]}
+case couch_config:get("couch_httpd_auth", 
"authentication_redirect", nil) of
+nil -> {Code, []};
+AuthRedirect ->
+% if the accept header matches html, then do the 
redirect. else proceed as usual.
+case re:run(MochiReq:get_header_value("Accept"), 
"html", [{capture, none}]) of
+nomatch ->
+{Code, []};
+match ->
+AuthRedirectBin = ?l2b(AuthRedirect),
+UrlReturn = 
?l2b(couch_util:url_encode(MochiReq:get(path))),
+UrlReason = ?l2b(couch_util:url_encode(ReasonStr)),
+{302, [{"Location", couch_httpd:absolute_uri(Req, 
<http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_rep_writer.erl?rev=957805&r1=957804&r2=957805&view=diff
==
--- couchdb/trunk/src/couchdb/couch_rep_writer.erl (original)
+++ couchdb/trunk/src/couchdb/couch_rep_writer.erl Fri Jun 25 05:30:51 2010
@@ -78,7 +78,6 @@ write_bulk_docs(#http_db{headers = Heade
 body = {[{new_edits, false}, {docs, JsonDocs}]},
 headers = couch_util:proplist_apply_field({"Content-Type", 
"application/json"}, [{"X-Couch-Full-Commit", "false"} | Headers])
 },
-?LOG_ERROR("headers ~p",[Request#http_db.headers]),
 ErrorsJson = case couch_rep_httpc:request(Request) of
 {FailProps} ->
 exit({target_error, couch_util:get_value(<<"error">>, FailProps)});




svn commit: r957799 - in /couchdb/trunk/share/www/script: couch.js test/content_negotiation.js test/list_views.js

2010-06-24 Thread jchris
Author: jchris
Date: Fri Jun 25 05:17:30 2010
New Revision: 957799

URL: http://svn.apache.org/viewvc?rev=957799&view=rev
Log:
use proper Accept headers in the test suite

Modified:
couchdb/trunk/share/www/script/couch.js
couchdb/trunk/share/www/script/test/content_negotiation.js
couchdb/trunk/share/www/script/test/list_views.js

Modified: couchdb/trunk/share/www/script/couch.js
URL: 
http://svn.apache.org/viewvc/couchdb/trunk/share/www/script/couch.js?rev=957799&r1=957798&r2=957799&view=diff
==
--- couchdb/trunk/share/www/script/couch.js [utf-8] (original)
+++ couchdb/trunk/share/www/script/couch.js [utf-8] Fri Jun 25 05:17:30 2010
@@ -399,7 +399,8 @@ CouchDB.newXhr = function() {
 CouchDB.request = function(method, uri, options) {
   options = options || {};
   options.headers = options.headers || {};
-  options.headers["Content-Type"] = options.headers["Content-Type"] || 
"application/json";
+  options.headers["Content-Type"] = options.headers["Content-Type"] || 
options.headers["content-type"] || "application/json";
+  options.headers["Accept"] = options.headers["Accept"] || 
options.headers["accept"] || "application/json";
   var req = CouchDB.newXhr();
   if(uri.substr(0, "http://".length) != "http://";) {
 uri = CouchDB.urlPrefix + uri

Modified: couchdb/trunk/share/www/script/test/content_negotiation.js
URL: 
http://svn.apache.org/viewvc/couchdb/trunk/share/www/script/test/content_negotiation.js?rev=957799&r1=957798&r2=957799&view=diff
==
--- couchdb/trunk/share/www/script/test/content_negotiation.js (original)
+++ couchdb/trunk/share/www/script/test/content_negotiation.js Fri Jun 25 
05:17:30 2010
@@ -17,11 +17,14 @@ couchTests.content_negotiation = functio
   if (debug) debugger;
   var xhr;
 
-  xhr = CouchDB.request("GET", "/test_suite_db/");
-  TEquals("text/plain;charset=utf-8", xhr.getResponseHeader("Content-Type"));
+  // with no accept header
+  var req = CouchDB.newXhr();
+  req.open("GET", "/test_suite_db/", false);
+  req.send("");
+  TEquals("text/plain;charset=utf-8", req.getResponseHeader("Content-Type"));
 
   // make sure JSON responses end in a newline
-  var text = xhr.responseText;
+  var text = req.responseText;
   TEquals("\n", text[text.length-1]);
 
   xhr = CouchDB.request("GET", "/test_suite_db/", {

Modified: couchdb/trunk/share/www/script/test/list_views.js
URL: 
http://svn.apache.org/viewvc/couchdb/trunk/share/www/script/test/list_views.js?rev=957799&r1=957798&r2=957799&view=diff
==
--- couchdb/trunk/share/www/script/test/list_views.js (original)
+++ couchdb/trunk/share/www/script/test/list_views.js Fri Jun 25 05:17:30 2010
@@ -346,13 +346,21 @@ couchTests.list_views = function(debug) 
   // T(xhr.getResponseHeader("Content-Type") == "text/plain");
   T(xhr.responseText.match(/^head 0 1 2 tail$/) && "basic stop");
 
-  xhr = CouchDB.request("GET", 
"/test_suite_db/_design/lists/_list/stopIter2/basicView");
+  xhr = CouchDB.request("GET", 
"/test_suite_db/_design/lists/_list/stopIter2/basicView", {
+headers : {
+  "Accept" : "text/html"
+}
+  });
   T(xhr.responseText.match(/^head 0 1 2 tail$/) && "stop 2");
 
   // aborting iteration with reduce
   var xhr = CouchDB.request("GET", 
"/test_suite_db/_design/lists/_list/stopIter/withReduce?group=true");
   T(xhr.responseText.match(/^head 0 1 2 tail$/) && "reduce stop");
-  xhr = CouchDB.request("GET", 
"/test_suite_db/_design/lists/_list/stopIter2/withReduce?group=true");
+  xhr = CouchDB.request("GET", 
"/test_suite_db/_design/lists/_list/stopIter2/withReduce?group=true", {
+headers : {
+  "Accept" : "text/html"
+}
+  });
   T(xhr.responseText.match(/^head 0 1 2 tail$/) && "reduce stop 2");
 
   // with accept headers for HTML




svn commit: r957656 - /couchdb/trunk/src/mochiweb/mochijson2.erl

2010-06-24 Thread jchris
Author: jchris
Date: Thu Jun 24 18:07:00 2010
New Revision: 957656

URL: http://svn.apache.org/viewvc?rev=957656&view=rev
Log:
patch mochijson2 to allow output of big integers not in float form (it stores 
them just fine)

Modified:
couchdb/trunk/src/mochiweb/mochijson2.erl

Modified: couchdb/trunk/src/mochiweb/mochijson2.erl
URL: 
http://svn.apache.org/viewvc/couchdb/trunk/src/mochiweb/mochijson2.erl?rev=957656&r1=957655&r2=957656&view=diff
==
--- couchdb/trunk/src/mochiweb/mochijson2.erl (original)
+++ couchdb/trunk/src/mochiweb/mochijson2.erl Thu Jun 24 18:07:00 2010
@@ -98,11 +98,8 @@ json_encode(false, _State) ->
 <<"false">>;
 json_encode(null, _State) ->
 <<"null">>;
-json_encode(I, _State) when is_integer(I) andalso I >= -2147483648 andalso I 
=< 2147483647 ->
-%% Anything outside of 32-bit integers should be encoded as a float
-integer_to_list(I);
 json_encode(I, _State) when is_integer(I) ->
-mochinum:digits(float(I));
+integer_to_list(I);
 json_encode(F, _State) when is_float(F) ->
 mochinum:digits(F);
 json_encode(S, State) when is_binary(S); is_atom(S) ->




svn commit: r957653 - in /couchdb/trunk: THANKS share/www/script/test/attachments.js src/couchdb/couch_doc.erl

2010-06-24 Thread jchris
Author: jchris
Date: Thu Jun 24 17:56:41 2010
New Revision: 957653

URL: http://svn.apache.org/viewvc?rev=957653&view=rev
Log:
don't require a revpos attribute for stubs. closes COUCHDB-809 thanks Caleb Land

Modified:
couchdb/trunk/THANKS
couchdb/trunk/share/www/script/test/attachments.js
couchdb/trunk/src/couchdb/couch_doc.erl

Modified: couchdb/trunk/THANKS
URL: 
http://svn.apache.org/viewvc/couchdb/trunk/THANKS?rev=957653&r1=957652&r2=957653&view=diff
==
--- couchdb/trunk/THANKS (original)
+++ couchdb/trunk/THANKS Thu Jun 24 17:56:41 2010
@@ -63,5 +63,6 @@ suggesting improvements or submitting ch
  * Zachary Zolton 
  * Brian Jenkins 
  * Paul Bonser 
+ * Caleb Land 
 
 For a list of authors see the `AUTHORS` file.

Modified: couchdb/trunk/share/www/script/test/attachments.js
URL: 
http://svn.apache.org/viewvc/couchdb/trunk/share/www/script/test/attachments.js?rev=957653&r1=957652&r2=957653&view=diff
==
--- couchdb/trunk/share/www/script/test/attachments.js (original)
+++ couchdb/trunk/share/www/script/test/attachments.js Thu Jun 24 17:56:41 2010
@@ -244,4 +244,24 @@ couchTests.attachments= function(debug) 
 body: "THIS IS AN ATTACHMENT. BOOYA!"
   });
   TEquals(400, xhr.status, "should return error code 400 Bad Request");
+
+  // test COUCHDB-809 - stubs should only require the 'stub' field
+  var bin_doc6 = {
+_id: "bin_doc6",
+_attachments:{
+  "foo.txt": {
+content_type:"text/plain",
+data: "VGhpcyBpcyBhIGJhc2U2NCBlbmNvZGVkIHRleHQ="
+  }
+}
+  }
+  var save_response = db.save(bin_doc6);
+  bin_doc6._rev = save_response["rev"];
+  // stub out the attachment
+  bin_doc6._attachments["foo.txt"] = { stub: true };
+
+  var xhr = CouchDB.request("PUT", "/test_suite_db/bin_doc6", {
+body: JSON.stringify(bin_doc6)
+  });
+  TEquals(201, xhr.status, "should send 201 Created when attachment stub 
contains only the 'stub' field");
 };

Modified: couchdb/trunk/src/couchdb/couch_doc.erl
URL: 
http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_doc.erl?rev=957653&r1=957652&r2=957653&view=diff
==
--- couchdb/trunk/src/couchdb/couch_doc.erl (original)
+++ couchdb/trunk/src/couchdb/couch_doc.erl Thu Jun 24 17:56:41 2010
@@ -357,9 +357,9 @@ has_stubs([_Att|Rest]) ->
 merge_stubs(#doc{id=Id,atts=MemBins}=StubsDoc, #doc{atts=DiskBins}) ->
 BinDict = dict:from_list([{Name, Att} || #att{name=Name}=Att <- DiskBins]),
 MergedBins = lists:map(
-fun(#att{name=Name, data=stub, revpos=RevPos}) ->
+fun(#att{name=Name, data=stub}) ->
 case dict:find(Name, BinDict) of
-{ok, #att{revpos=RevPos}=DiskAtt} ->
+{ok, #att{}=DiskAtt} ->
 DiskAtt;
 _ ->
 throw({missing_stub,




svn commit: r957622 - in /couchdb/trunk: THANKS share/www/script/futon.browse.js share/www/script/futon.format.js

2010-06-24 Thread jchris
Author: jchris
Date: Thu Jun 24 16:53:43 2010
New Revision: 957622

URL: http://svn.apache.org/viewvc?rev=957622&view=rev
Log:
proper docid escaping in Futon view display, thanks Paul Bonser. Closes 
COUCHDB-748

Modified:
couchdb/trunk/THANKS
couchdb/trunk/share/www/script/futon.browse.js
couchdb/trunk/share/www/script/futon.format.js

Modified: couchdb/trunk/THANKS
URL: 
http://svn.apache.org/viewvc/couchdb/trunk/THANKS?rev=957622&r1=957621&r2=957622&view=diff
==
--- couchdb/trunk/THANKS (original)
+++ couchdb/trunk/THANKS Thu Jun 24 16:53:43 2010
@@ -62,5 +62,6 @@ suggesting improvements or submitting ch
  * Dmitry Unkovsky 
  * Zachary Zolton 
  * Brian Jenkins 
+ * Paul Bonser 
 
 For a list of authors see the `AUTHORS` file.

Modified: couchdb/trunk/share/www/script/futon.browse.js
URL: 
http://svn.apache.org/viewvc/couchdb/trunk/share/www/script/futon.browse.js?rev=957622&r1=957621&r2=957622&view=diff
==
--- couchdb/trunk/share/www/script/futon.browse.js [utf-8] (original)
+++ couchdb/trunk/share/www/script/futon.browse.js [utf-8] Thu Jun 24 16:53:43 
2010
@@ -152,7 +152,7 @@
 page.viewName.indexOf("/_view"));
 db.compactView(groupname, {success: function(resp) { 
callback() }});
 break;
-  case "view_cleanup": 
+  case "view_cleanup":
 db.viewCleanup({success: function(resp) { callback() }});
 break;
 }
@@ -178,7 +178,7 @@
   }
 });
   }
-  
+
   this.databaseSecurity = function() {
 $.showDialog("dialog/_database_security.html", {
   load : function(d) {
@@ -672,7 +672,7 @@
 if (row.id) {
   $("" +
-"ID: " + row.id + "")
+"ID: " + $.futon.escape(row.id) + 
"")
 .find("strong").text(key).end()
 .appendTo(tr);
 } else {
@@ -851,7 +851,7 @@
   return true;
 } catch (err) {
   var msg = err.message;
-  if (msg == "parseJSON" || msg == "JSON.parse") { 
+  if (msg == "parseJSON" || msg == "JSON.parse") {
 msg = "There is a syntax error in the document.";
   }
   $("").text(msg).appendTo(this);

Modified: couchdb/trunk/share/www/script/futon.format.js
URL: 
http://svn.apache.org/viewvc/couchdb/trunk/share/www/script/futon.format.js?rev=957622&r1=957621&r2=957622&view=diff
==
--- couchdb/trunk/share/www/script/futon.format.js [utf-8] (original)
+++ couchdb/trunk/share/www/script/futon.format.js [utf-8] Thu Jun 24 16:53:43 
2010
@@ -13,6 +13,11 @@
 (function($) {
   $.futon = $.futon || {};
   $.extend($.futon, {
+escape: function(string) {
+  return string.replace(/&/g, "&")
+   .replace(//g, ">");
+},
 
 // JSON pretty printing
 formatJSON: function(val, options) {
@@ -24,12 +29,6 @@
   }, options || {});
   var itemsep = options.linesep.length ? "," + options.linesep : ", ";
 
-  function escape(string) {
-return string.replace(/&/g, "&")
- .replace(//g, ">");
-  }
-
   function format(val, depth) {
 var tab = [];
 for (var i = 0; i < options.indent * depth; i++) tab.push("");
@@ -45,7 +44,7 @@
   retval = indentLines(retval.replace(/\r\n/g, "\n"), 
tab.substr(options.indent));
 } else {
   if (options.html) {
-retval = escape(JSON.stringify(val));
+retval = $.futon.escape(JSON.stringify(val));
   } else {
 retval = JSON.stringify(val);
   }
@@ -92,7 +91,7 @@
   if (options.quoteKeys) {
 keyDisplay = keyDisplay.substr(1, keyDisplay.length - 2);
   }
-  keyDisplay = "" + escape(keyDisplay) + 
"";
+  keyDisplay = "" + 
$.futon.escape(keyDisplay) + "";
   if (options.quoteKeys) {
 keyDisplay = '"' + keyDisplay + '"';
   }
@@ -118,7 +117,7 @@
   function indentLines(text, tab) {
 var lines = text.split("\n");
 for (var i in lines) {
-  lines[i] = (i > 0 ? tab : "") + escape(lines[i]);
+  lines[i] = (i > 0 ? tab : "") + $.futon.escape(lines[i]);
 }
 return lines.join("");
   }




svn commit: r957619 - /couchdb/trunk/share/www/script/futon.js

2010-06-24 Thread jchris
Author: jchris
Date: Thu Jun 24 16:47:18 2010
New Revision: 957619

URL: http://svn.apache.org/viewvc?rev=957619&view=rev
Log:
add $.couch.urlPrefix to link to users db. closes COUCHDB-742

Modified:
couchdb/trunk/share/www/script/futon.js

Modified: couchdb/trunk/share/www/script/futon.js
URL: 
http://svn.apache.org/viewvc/couchdb/trunk/share/www/script/futon.js?rev=957619&r1=957618&r2=957619&view=diff
==
--- couchdb/trunk/share/www/script/futon.js (original)
+++ couchdb/trunk/share/www/script/futon.js Thu Jun 24 16:47:18 2010
@@ -140,7 +140,7 @@ function $$(node) {
   var userCtx = r.userCtx;
   $$("#userCtx").userCtx = userCtx;
   if (userCtx.name) {
-$("#userCtx .name").text(userCtx.name).attr({href : 
"/_utils/document.html?"+encodeURIComponent(r.info.authentication_db)+"/org.couchdb.user%3A"+encodeURIComponent(userCtx.name)});
+$("#userCtx .name").text(userCtx.name).attr({href : 
$.couch.urlPrefix + 
"/_utils/document.html?"+encodeURIComponent(r.info.authentication_db)+"/org.couchdb.user%3A"+encodeURIComponent(userCtx.name)});
 if (userCtx.roles.indexOf("_admin") != -1) {
   $("#userCtx .loggedinadmin").show();
 } else {




svn commit: r957613 - /couchdb/trunk/src/couchdb/couch_httpd.erl

2010-06-24 Thread jchris
Author: jchris
Date: Thu Jun 24 16:35:58 2010
New Revision: 957613

URL: http://svn.apache.org/viewvc?rev=957613&view=rev
Log:
better error message for db names, closes COUCHDB-741 thanks Frank

Modified:
couchdb/trunk/src/couchdb/couch_httpd.erl

Modified: couchdb/trunk/src/couchdb/couch_httpd.erl
URL: 
http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_httpd.erl?rev=957613&r1=957612&r2=957613&view=diff
==
--- couchdb/trunk/src/couchdb/couch_httpd.erl (original)
+++ couchdb/trunk/src/couchdb/couch_httpd.erl Thu Jun 24 16:35:58 2010
@@ -726,7 +726,7 @@ error_info({bad_ctype, Reason}) ->
 error_info({error, illegal_database_name}) ->
 {400, <<"illegal_database_name">>, <<"Only lowercase characters (a-z), "
 "digits (0-9), and any of the characters _, $, (, ), +, -, and / "
-"are allowed">>};
+"are allowed. Must begin with a letter.">>};
 error_info({missing_stub, Reason}) ->
 {412, <<"missing_stub">>, Reason};
 error_info({Error, Reason}) ->




svn commit: r957610 - in /couchdb/trunk: THANKS share/Makefile.am share/www/script/couch_tests.js share/www/script/test/method_override.js src/couchdb/couch_httpd.erl

2010-06-24 Thread jchris
Author: jchris
Date: Thu Jun 24 16:33:27 2010
New Revision: 957610

URL: http://svn.apache.org/viewvc?rev=957610&view=rev
Log:
close COUCHDB-795 add X-HTTP-METHOD-OVERRIDE support. Thanks Brian Jenkins

Added:
couchdb/trunk/share/www/script/test/method_override.js
Modified:
couchdb/trunk/THANKS
couchdb/trunk/share/Makefile.am
couchdb/trunk/share/www/script/couch_tests.js
couchdb/trunk/src/couchdb/couch_httpd.erl

Modified: couchdb/trunk/THANKS
URL: 
http://svn.apache.org/viewvc/couchdb/trunk/THANKS?rev=957610&r1=957609&r2=957610&view=diff
==
--- couchdb/trunk/THANKS (original)
+++ couchdb/trunk/THANKS Thu Jun 24 16:33:27 2010
@@ -61,5 +61,6 @@ suggesting improvements or submitting ch
  * Jason Smith 
  * Dmitry Unkovsky 
  * Zachary Zolton 
+ * Brian Jenkins 
 
 For a list of authors see the `AUTHORS` file.

Modified: couchdb/trunk/share/Makefile.am
URL: 
http://svn.apache.org/viewvc/couchdb/trunk/share/Makefile.am?rev=957610&r1=957609&r2=957610&view=diff
==
--- couchdb/trunk/share/Makefile.am (original)
+++ couchdb/trunk/share/Makefile.am Thu Jun 24 16:33:27 2010
@@ -138,6 +138,7 @@ nobase_dist_localdata_DATA = \
 www/script/test/lorem.txt \
 www/script/test/lorem_b64.txt \
 www/script/test/lots_of_docs.js \
+www/script/test/method_override.js \
 www/script/test/multiple_rows.js \
 www/script/test/oauth.js \
 www/script/test/proxyauth.js \

Modified: couchdb/trunk/share/www/script/couch_tests.js
URL: 
http://svn.apache.org/viewvc/couchdb/trunk/share/www/script/couch_tests.js?rev=957610&r1=957609&r2=957610&view=diff
==
--- couchdb/trunk/share/www/script/couch_tests.js [utf-8] (original)
+++ couchdb/trunk/share/www/script/couch_tests.js [utf-8] Thu Jun 24 16:33:27 
2010
@@ -59,6 +59,7 @@ loadTest("jsonp.js");
 loadTest("large_docs.js");
 loadTest("list_views.js");
 loadTest("lots_of_docs.js");
+loadTest("method_override.js");
 loadTest("multiple_rows.js");
 loadScript("script/oauth.js");
 loadScript("script/sha1.js");

Added: couchdb/trunk/share/www/script/test/method_override.js
URL: 
http://svn.apache.org/viewvc/couchdb/trunk/share/www/script/test/method_override.js?rev=957610&view=auto
==
--- couchdb/trunk/share/www/script/test/method_override.js (added)
+++ couchdb/trunk/share/www/script/test/method_override.js Thu Jun 24 16:33:27 
2010
@@ -0,0 +1,40 @@
+// Licensed under the Apache License, Version 2.0 (the "License"); you may not
+// use this file except in compliance with the License. You may obtain a copy 
of
+// the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+// License for the specific language governing permissions and limitations 
under
+// the License.
+
+// Allow broken HTTP clients to fake a full method vocabulary with an 
X-HTTP-METHOD-OVERRIDE header
+couchTests.method_override = function(debug) {
+  var result = JSON.parse(CouchDB.request("GET", "/").responseText);
+  T(result.couchdb == "Welcome");
+
+  var db = new CouchDB("test_suite_db", {"X-Couch-Full-Commit":"false"});
+  db.deleteDb();
+
+  db.createDb();
+
+  var doc = {bob : "connie"};
+  xhr = CouchDB.request("POST", "/test_suite_db/fnord", {body: 
JSON.stringify(doc), headers:{"X-HTTP-Method-Override" : "PUT"}});
+  T(xhr.status == 201);
+
+  doc = db.open("fnord");
+  T(doc.bob == "connie");
+
+  xhr = CouchDB.request("POST", "/test_suite_db/fnord?rev=" + doc._rev, 
{headers:{"X-HTTP-Method-Override" : "DELETE"}});
+  T(xhr.status == 200)
+
+  xhr = CouchDB.request("GET", "/test_suite_db/fnord2", {body: 
JSON.stringify(doc), headers:{"X-HTTP-Method-Override" : "PUT"}});
+  // Method Override is ignored when original Method isn't POST
+  T(xhr.status == 404);
+
+  doc = db.open("fnord");
+  T(doc == null);  
+
+};

Modified: couchdb/trunk/src/couchdb/couch_httpd.erl
URL: 
http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_httpd.erl?rev=957610&r1=957609&r2=957610&view=diff
==
--- couchdb/trunk/src/couchdb/couch_httpd.erl (original)
+++ couchdb/trunk/src/couchdb/couch_ht

svn commit: r957422 - in /couchdb/trunk: share/www/script/ share/www/script/test/ src/couchdb/

2010-06-23 Thread jchris
Author: jchris
Date: Thu Jun 24 05:21:30 2010
New Revision: 957422

URL: http://svn.apache.org/viewvc?rev=957422&view=rev
Log:
use JSON content type in replicator, require it in the _bulk_docs and other 
POST apis

Modified:
couchdb/trunk/share/www/script/couch.js
couchdb/trunk/share/www/script/test/basics.js
couchdb/trunk/share/www/script/test/batch_save.js
couchdb/trunk/share/www/script/test/stats.js
couchdb/trunk/src/couchdb/couch_httpd.erl
couchdb/trunk/src/couchdb/couch_httpd_auth.erl
couchdb/trunk/src/couchdb/couch_httpd_db.erl
couchdb/trunk/src/couchdb/couch_httpd_show.erl
couchdb/trunk/src/couchdb/couch_rep.erl
couchdb/trunk/src/couchdb/couch_rep_writer.erl
couchdb/trunk/src/couchdb/couch_util.erl

Modified: couchdb/trunk/share/www/script/couch.js
URL: 
http://svn.apache.org/viewvc/couchdb/trunk/share/www/script/couch.js?rev=957422&r1=957421&r2=957422&view=diff
==
--- couchdb/trunk/share/www/script/couch.js [utf-8] (original)
+++ couchdb/trunk/share/www/script/couch.js [utf-8] Thu Jun 24 05:21:30 2010
@@ -398,6 +398,8 @@ CouchDB.newXhr = function() {
 
 CouchDB.request = function(method, uri, options) {
   options = options || {};
+  options.headers = options.headers || {};
+  options.headers["Content-Type"] = options.headers["Content-Type"] || 
"application/json";
   var req = CouchDB.newXhr();
   if(uri.substr(0, "http://".length) != "http://";) {
 uri = CouchDB.urlPrefix + uri

Modified: couchdb/trunk/share/www/script/test/basics.js
URL: 
http://svn.apache.org/viewvc/couchdb/trunk/share/www/script/test/basics.js?rev=957422&r1=957421&r2=957422&view=diff
==
--- couchdb/trunk/share/www/script/test/basics.js (original)
+++ couchdb/trunk/share/www/script/test/basics.js Thu Jun 24 05:21:30 2010
@@ -152,7 +152,8 @@ couchTests.basics = function(debug) {
 
   // test that the POST response has a Location header
   var xhr = CouchDB.request("POST", "/test_suite_db", {
-body: JSON.stringify({"foo":"bar"})
+body: JSON.stringify({"foo":"bar"}),
+headers: {"Content-Type": "application/json"}
   });
   var resp = JSON.parse(xhr.responseText);
   T(resp.ok);
@@ -164,6 +165,7 @@ couchTests.basics = function(debug) {
 
   // test that that POST's with an _id aren't overriden with a UUID.
   var xhr = CouchDB.request("POST", "/test_suite_db", {
+headers: {"Content-Type": "application/json"},
 body: JSON.stringify({"_id": "oppossum", "yar": "matey"})
   });
   var resp = JSON.parse(xhr.responseText);
@@ -202,7 +204,10 @@ couchTests.basics = function(debug) {
 result = JSON.parse(xhr.responseText);
 T(result.error == "doc_validation");
 
-xhr = CouchDB.request("POST", "/test_suite_db/", {body: data});
+xhr = CouchDB.request("POST", "/test_suite_db/", {
+  headers: {"Content-Type": "application/json"},
+  body: data
+});
 T(xhr.status == 500);
 result = JSON.parse(xhr.responseText);
 T(result.error == "doc_validation");

Modified: couchdb/trunk/share/www/script/test/batch_save.js
URL: 
http://svn.apache.org/viewvc/couchdb/trunk/share/www/script/test/batch_save.js?rev=957422&r1=957421&r2=957422&view=diff
==
--- couchdb/trunk/share/www/script/test/batch_save.js (original)
+++ couchdb/trunk/share/www/script/test/batch_save.js Thu Jun 24 05:21:30 2010
@@ -36,7 +36,10 @@ couchTests.batch_save = function(debug) 
 
   // repeat the tests for POST
   for(i=0; i < 100; i++) {
-var resp = db.request("POST", db.uri + "?batch=ok", {body: 
JSON.stringify({a:1})});
+var resp = db.request("POST", db.uri + "?batch=ok", {
+  headers: {"Content-Type": "application/json"},
+  body: JSON.stringify({a:1})
+});
 T(JSON.parse(resp.responseText).ok);
   }
   

Modified: couchdb/trunk/share/www/script/test/stats.js
URL: 
http://svn.apache.org/viewvc/couchdb/trunk/share/www/script/test/stats.js?rev=957422&r1=957421&r2=957422&view=diff
==
--- couchdb/trunk/share/www/script/test/stats.js (original)
+++ couchdb/trunk/share/www/script/test/stats.js Thu Jun 24 05:21:30 2010
@@ -160,7 +160,10 @@ couchTests.stats = function(debug) {
   
   runTest("couchdb", "database_writes", {
 run: function(db) {
-  CouchDB.request("POST", "/test_suite_db", {bod

  1   2   3   4   >