You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by cm...@apache.org on 2008/08/31 10:57:43 UTC
svn commit: r690659 - in /incubator/couchdb/branches/json_term_changes: ./
bin/ etc/couchdb/ share/www/browse/ share/www/script/ share/www/style/
src/couchdb/ test/
Author: cmlenz
Date: Sun Aug 31 01:57:42 2008
New Revision: 690659
URL: http://svn.apache.org/viewvc?rev=690659&view=rev
Log:
Merged revisions 688180-690605 via svnmerge from
https://svn.apache.org/repos/asf/incubator/couchdb/trunk
Added:
incubator/couchdb/branches/json_term_changes/share/www/browse/_upload_attachment.html
- copied unchanged from r690595, incubator/couchdb/trunk/share/www/browse/_upload_attachment.html
incubator/couchdb/branches/json_term_changes/share/www/script/jquery.form.js
- copied unchanged from r690595, incubator/couchdb/trunk/share/www/script/jquery.form.js
Removed:
incubator/couchdb/branches/json_term_changes/etc/couchdb/couch.ini.tpl.in
Modified:
incubator/couchdb/branches/json_term_changes/ (props changed)
incubator/couchdb/branches/json_term_changes/CHANGES
incubator/couchdb/branches/json_term_changes/LICENSE
incubator/couchdb/branches/json_term_changes/README
incubator/couchdb/branches/json_term_changes/bin/couchdb.tpl.in
incubator/couchdb/branches/json_term_changes/etc/couchdb/ (props changed)
incubator/couchdb/branches/json_term_changes/etc/couchdb/default.ini.tpl.in
incubator/couchdb/branches/json_term_changes/etc/couchdb/local.ini
incubator/couchdb/branches/json_term_changes/share/www/browse/document.html
incubator/couchdb/branches/json_term_changes/share/www/browse/index.html
incubator/couchdb/branches/json_term_changes/share/www/script/browse.js
incubator/couchdb/branches/json_term_changes/share/www/script/jquery.dialog.js
incubator/couchdb/branches/json_term_changes/share/www/style/layout.css
incubator/couchdb/branches/json_term_changes/src/couchdb/ (props changed)
incubator/couchdb/branches/json_term_changes/src/couchdb/couch_config.erl
incubator/couchdb/branches/json_term_changes/src/couchdb/couch_config_writer.erl
incubator/couchdb/branches/json_term_changes/src/couchdb/couch_db_update_notifier_sup.erl
incubator/couchdb/branches/json_term_changes/src/couchdb/couch_file.erl
incubator/couchdb/branches/json_term_changes/src/couchdb/couch_ft_query.erl
incubator/couchdb/branches/json_term_changes/src/couchdb/couch_httpd.erl
incubator/couchdb/branches/json_term_changes/src/couchdb/couch_log.erl
incubator/couchdb/branches/json_term_changes/src/couchdb/couch_query_servers.erl
incubator/couchdb/branches/json_term_changes/src/couchdb/couch_server.erl
incubator/couchdb/branches/json_term_changes/src/couchdb/couch_server_sup.erl
incubator/couchdb/branches/json_term_changes/src/couchdb/couch_util.erl
incubator/couchdb/branches/json_term_changes/src/couchdb/couch_view.erl
incubator/couchdb/branches/json_term_changes/test/ (props changed)
incubator/couchdb/branches/json_term_changes/test/couch_config_test.erl
incubator/couchdb/branches/json_term_changes/test/couch_config_writer_test.erl
incubator/couchdb/branches/json_term_changes/test/runner.sh (props changed)
Propchange: incubator/couchdb/branches/json_term_changes/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Sun Aug 31 01:57:42 2008
@@ -1 +1 @@
-/incubator/couchdb/trunk:1-688179
+/incubator/couchdb/trunk:1-690605
Modified: incubator/couchdb/branches/json_term_changes/CHANGES
URL: http://svn.apache.org/viewvc/incubator/couchdb/branches/json_term_changes/CHANGES?rev=690659&r1=690658&r2=690659&view=diff
==============================================================================
--- incubator/couchdb/branches/json_term_changes/CHANGES (original)
+++ incubator/couchdb/branches/json_term_changes/CHANGES Sun Aug 31 01:57:42 2008
@@ -10,6 +10,11 @@
* Updated `configure.ac` to extended default library paths.
* Removed inets configuration files.
+Futon Utility Client:
+
+ * Added pagination to the database listing page.
+ * Implemented attachment uploading from the document page.
+
Version 0.8.1-incubating
------------------------
Modified: incubator/couchdb/branches/json_term_changes/LICENSE
URL: http://svn.apache.org/viewvc/incubator/couchdb/branches/json_term_changes/LICENSE?rev=690659&r1=690658&r2=690659&view=diff
==============================================================================
--- incubator/couchdb/branches/json_term_changes/LICENSE (original)
+++ incubator/couchdb/branches/json_term_changes/LICENSE Sun Aug 31 01:57:42 2008
@@ -239,6 +239,29 @@
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+For the share/www/script/jquery.form.js component:
+
+ http://malsup.com/jquery/form/
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice shall be
+ included in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
For the share/www/script/json2.js component:
Public Domain
Modified: incubator/couchdb/branches/json_term_changes/README
URL: http://svn.apache.org/viewvc/incubator/couchdb/branches/json_term_changes/README?rev=690659&r1=690658&r2=690659&view=diff
==============================================================================
--- incubator/couchdb/branches/json_term_changes/README (original)
+++ incubator/couchdb/branches/json_term_changes/README Sun Aug 31 01:57:42 2008
@@ -177,13 +177,13 @@
When Apache CouchDB starts it should eventually display the following message:
- Apache CouchDB has started, time to relax. See http://localhost:5984/_utils/index.html
+ Apache CouchDB has started, time to relax. See http://127.0.0.1:5984/_utils/index.html
Relax.
To check that everything has worked, point your web browser to:
- http://localhost:5984/_utils/index.html
+ http://127.0.0.1:5984/_utils/index.html
From here you should run the test suite.
Modified: incubator/couchdb/branches/json_term_changes/bin/couchdb.tpl.in
URL: http://svn.apache.org/viewvc/incubator/couchdb/branches/json_term_changes/bin/couchdb.tpl.in?rev=690659&r1=690658&r2=690659&view=diff
==============================================================================
--- incubator/couchdb/branches/json_term_changes/bin/couchdb.tpl.in (original)
+++ incubator/couchdb/branches/json_term_changes/bin/couchdb.tpl.in Sun Aug 31 01:57:42 2008
@@ -180,6 +180,7 @@
start_arguments="$start_arguments, ";
fi
start_arguments="$start_arguments \\\"$file\\\""
+ background_start_arguments="$background_start_arguments -c \\\"$file\\\""
done
command="`%ICU_CONFIG% --invoke` \
%ERL% $interactive_option -smp auto -sasl errlog_type error +K true \
@@ -193,7 +194,7 @@
-eval \"couch_server:start([$start_arguments]), receive done -> done end.\" "
if test "$BACKGROUND_BOOLEAN" = "true" \
-a "$RECURSED_BOOLEAN" = "false"; then
- $0 -c $INI_FILE -b -r $RESPAWN_TIMEOUT -p $PID_FILE \
+ $0 $background_start_arguments -b -r $RESPAWN_TIMEOUT -p $PID_FILE \
-o $STDOUT_FILE -e $STDERR_FILE -R &
echo "Apache CouchDB has started, time to relax."
else
Propchange: incubator/couchdb/branches/json_term_changes/etc/couchdb/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Sun Aug 31 01:57:42 2008
@@ -1,6 +1,4 @@
Makefile
Makefile.in
-couch_httpd.conf
-couch_httpd.conf.tpl
-couch.ini
-couch.ini.tpl
+default.ini
+default.ini.tpl
Modified: incubator/couchdb/branches/json_term_changes/etc/couchdb/default.ini.tpl.in
URL: http://svn.apache.org/viewvc/incubator/couchdb/branches/json_term_changes/etc/couchdb/default.ini.tpl.in?rev=690659&r1=690658&r2=690659&view=diff
==============================================================================
--- incubator/couchdb/branches/json_term_changes/etc/couchdb/default.ini.tpl.in (original)
+++ incubator/couchdb/branches/json_term_changes/etc/couchdb/default.ini.tpl.in Sun Aug 31 01:57:42 2008
@@ -2,22 +2,20 @@
; Upgrading CouchDB will overwrite this file.
-[CouchDB]
-RootDirectory=%localstatelibdir%
-UtilDriverDir=%couchprivlibdir%
-MaximumDocumentSize=4294967296 ; 4 GB
+[couchdb]
+database_dir = %localstatelibdir%
+util_driver_dir = %couchprivlibdir%
+max_document_size = 4294967296 ; 4 GB
+view_timeout = 5000 ; 5 seconds
+
+[httpd]
+port = 5984
+bind_address = 127.0.0.1
+utils_dir = %localdatadir%/www
+
+[log]
+file = %localstatelogdir%/couch.log
+level = info
-[HTTPd]
-Port=5984
-BindAddress=127.0.0.1
-DocumentRoot=%localdatadir%/www
-
-[Log]
-File=%localstatelogdir%/couch.log
-Level=info
-
-[CouchDB Query Servers]
-javascript=%bindir%/%couchjs_command_name% %localdatadir%/server/main.js
-
-[CouchDB Query Server Options]
-QueryTimeout=5000 ; 5 seconds
+[query_servers]
+javascript = %bindir%/%couchjs_command_name% %localdatadir%/server/main.js
Modified: incubator/couchdb/branches/json_term_changes/etc/couchdb/local.ini
URL: http://svn.apache.org/viewvc/incubator/couchdb/branches/json_term_changes/etc/couchdb/local.ini?rev=690659&r1=690658&r2=690659&view=diff
==============================================================================
--- incubator/couchdb/branches/json_term_changes/etc/couchdb/local.ini (original)
+++ incubator/couchdb/branches/json_term_changes/etc/couchdb/local.ini Sun Aug 31 01:57:42 2008
@@ -4,17 +4,17 @@
; in default.ini, but unlike changes made to default.ini, this file won't be
; overwritten on server upgrade.
-[CouchDB]
-;MaximumDocumentSize=4294967296 ; bytes
+[couchdb]
+;max_document_size = 4294967296 ; bytes
-[HTTPd]
-;Port=5984
-;BindAddress=127.0.0.1
+[httpd]
+;port = 5984
+;bind_address = 127.0.0.1
-[Log]
-;Level=info
+[log]
+;level = info
-[Update Notification]
+[update_notification]
;unique notifier name=/full/path/to/exe -with "cmd line arg"
Modified: incubator/couchdb/branches/json_term_changes/share/www/browse/document.html
URL: http://svn.apache.org/viewvc/incubator/couchdb/branches/json_term_changes/share/www/browse/document.html?rev=690659&r1=690658&r2=690659&view=diff
==============================================================================
--- incubator/couchdb/branches/json_term_changes/share/www/browse/document.html [utf-8] (original)
+++ incubator/couchdb/branches/json_term_changes/share/www/browse/document.html [utf-8] Sun Aug 31 01:57:42 2008
@@ -23,6 +23,7 @@
<script src="../script/jquery.cookies.js?0.8.0"></script>
<script src="../script/jquery.couch.js?0.8.0"></script>
<script src="../script/jquery.dialog.js?0.8.0"></script>
+ <script src="../script/jquery.form.js?0.8.0"></script>
<script src="../script/jquery.resizer.js?0.8.0"></script>
<script src="../script/browse.js?0.8.0"></script>
<script src="../script/pprint.js?0.8.0"></script>
@@ -61,6 +62,7 @@
$("#toolbar button.save").click(page.saveDocument);
$("#toolbar button.add").click(page.addField);
+ $("#toolbar button.load").click(page.uploadAttachment);
$("#toolbar button.delete").click(page.deleteDocument);
});
</script>
@@ -76,6 +78,7 @@
<ul id="toolbar">
<li><button class="save">Save Document</button></li>
<li><button class="add">Add Field</button></li>
+ <li><button class="load">Upload Attachment</button></li>
<li><button class="delete">Delete Document</button></li>
</ul>
Modified: incubator/couchdb/branches/json_term_changes/share/www/browse/index.html
URL: http://svn.apache.org/viewvc/incubator/couchdb/branches/json_term_changes/share/www/browse/index.html?rev=690659&r1=690658&r2=690659&view=diff
==============================================================================
--- incubator/couchdb/branches/json_term_changes/share/www/browse/index.html [utf-8] (original)
+++ incubator/couchdb/branches/json_term_changes/share/www/browse/index.html [utf-8] Sun Aug 31 01:57:42 2008
@@ -28,7 +28,15 @@
<script>
var page = new CouchIndexPage();
$(document).ready(function() {
+ var dbsPerPage = $.cookies.get("perpage");
+ if (dbsPerPage) $("#perpage").val(dbsPerPage);
+ $("#perpage").change(function() {
+ page.updateDatabaseListing();
+ $.cookies.set("perpage", this.value);
+ });
+
page.updateDatabaseListing();
+
$("#toolbar button.add").click(function() {
page.addDatabase();
});
@@ -57,7 +65,19 @@
</tbody>
<tbody class="footer">
<tr>
- <td colspan="4"></td>
+ <td colspan="4">
+ <div id="paging">
+ <a class="prev">← Previous Page</a> |
+ <label>Rows per page: <select id="perpage">
+ <option selected>10</option>
+ <option>25</option>
+ <option>50</option>
+ <option>100</option>
+ </select></label> |
+ <a class="next">Next Page →</a>
+ </div>
+ <span></span>
+ </td>
</tr>
</tbody>
</table>
Modified: incubator/couchdb/branches/json_term_changes/share/www/script/browse.js
URL: http://svn.apache.org/viewvc/incubator/couchdb/branches/json_term_changes/share/www/script/browse.js?rev=690659&r1=690658&r2=690659&view=diff
==============================================================================
--- incubator/couchdb/branches/json_term_changes/share/www/script/browse.js [utf-8] (original)
+++ incubator/couchdb/branches/json_term_changes/share/www/script/browse.js [utf-8] Sun Aug 31 01:57:42 2008
@@ -36,15 +36,22 @@
return false;
}
- this.updateDatabaseListing = function() {
+ this.updateDatabaseListing = function(offset) {
+ offset |= 0;
$(document.body).addClass("loading");
+ var maxPerPage = parseInt($("#perpage").val(), 10);
+
$.couch.allDbs({
success: function(dbs) {
+ $("#paging a").unbind();
+ $("#databases tbody.content").empty();
+
if (dbs.length == 0) {
$(document.body).removeClass("loading");
}
+ var dbsOnPage = dbs.slice(offset, offset + maxPerPage);
- $.each(dbs, function(idx, dbName) {
+ $.each(dbsOnPage, function(idx, dbName) {
$("#databases tbody.content").append("<tr>" +
"<th><a href='database.html?" + encodeURIComponent(dbName) + "'>" +
dbName + "</a></th>" +
@@ -56,14 +63,34 @@
.find("td.size").text(prettyPrintSize(info.disk_size)).end()
.find("td.count").text(info.doc_count).end()
.find("td.seq").text(info.update_seq);
- if (idx == dbs.length - 1) {
+ if (idx == dbsOnPage.length - 1) {
$(document.body).removeClass("loading");
}
}
});
});
$("#databases tbody tr:odd").addClass("odd");
- $("#databases tbody.footer tr td").text(dbs.length + " database(s)");
+
+ if (offset > 0) {
+ $("#paging a.prev").attr("href", "#" + (offset - maxPerPage)).click(function() {
+ page.updateDatabaseListing(offset - maxPerPage);
+ });
+ } else {
+ $("#paging a.prev").removeAttr("href");
+ }
+ if (offset + maxPerPage < dbs.length) {
+ $("#paging a.next").attr("href", "#" + (offset + maxPerPage)).click(function() {
+ page.updateDatabaseListing(offset + maxPerPage);
+ });
+ } else {
+ $("#paging a.next").removeAttr("href");
+ }
+
+ var firstNum = offset + 1;
+ var lastNum = firstNum + dbsOnPage.length - 1;
+ $("#databases tbody.footer tr td span").text(
+ "Showing " + firstNum + "-" + lastNum + " of " + dbs.length +
+ " databases");
}
});
}
@@ -621,6 +648,36 @@
});
}
+ this.uploadAttachment = function() {
+ if (page.isDirty) {
+ alert("You need to save or revert any changes you have made to the " +
+ "document before you can attach a new file.");
+ return false;
+ }
+ $.showDialog("_upload_attachment.html", {
+ load: function(elem) {
+ $("input[name='_rev']", elem).val(page.doc._rev);
+ },
+ submit: function(data, callback) {
+ if (!data._attachments || data._attachments.length == 0) {
+ callback({_attachments: "Please select a file to upload."});
+ return;
+ }
+ var form = $("#upload-form");
+ form.find("#progress").css("visibility", "visible");
+ form.ajaxSubmit({
+ url: db.uri + encodeURIComponent(page.docId),
+ success: function(resp) {
+ form.find("#progress").css("visibility", "hidden");
+ page.isDirty = false;
+ location.href = "?" + encodeURIComponent(dbName) +
+ "/" + encodeURIComponent(docId);
+ }
+ });
+ }
+ });
+ }
+
window.onbeforeunload = function() {
if (page.isDirty) {
return "You've made changes to this document that have not been " +
@@ -816,6 +873,7 @@
delete page.doc._attachments[name];
li.remove();
page.isDirty = true;
+ return false;
}).prependTo($("a", li));
}
Modified: incubator/couchdb/branches/json_term_changes/share/www/script/jquery.dialog.js
URL: http://svn.apache.org/viewvc/incubator/couchdb/branches/json_term_changes/share/www/script/jquery.dialog.js?rev=690659&r1=690658&r2=690659&view=diff
==============================================================================
--- incubator/couchdb/branches/json_term_changes/share/www/script/jquery.dialog.js [utf-8] (original)
+++ incubator/couchdb/branches/json_term_changes/share/www/script/jquery.dialog.js [utf-8] Sun Aug 31 01:57:42 2008
@@ -75,6 +75,9 @@
$.each($("form :input", dialog).serializeArray(), function(i, field) {
data[field.name] = field.value;
});
+ $("form :file", dialog).each(function() {
+ data[this.name] = this.value; // file inputs need special handling
+ });
options.submit(data, function callback(errors) {
if (errors == null || errors == {}) {
dismiss();
Modified: incubator/couchdb/branches/json_term_changes/share/www/style/layout.css
URL: http://svn.apache.org/viewvc/incubator/couchdb/branches/json_term_changes/share/www/style/layout.css?rev=690659&r1=690658&r2=690659&view=diff
==============================================================================
--- incubator/couchdb/branches/json_term_changes/share/www/style/layout.css (original)
+++ incubator/couchdb/branches/json_term_changes/share/www/style/layout.css Sun Aug 31 01:57:42 2008
@@ -198,7 +198,7 @@
width: expression(document.body.clientWidth + 'px');
height: expression(document.body.clientHeight + 'px');
}
-#dialog { background: #333 url(../image/progress.gif) 50% 50% no-repeat;
+#dialog { background: #333 url(../image/progress.gif) 50% 50% no-repeat;
color: #f4f4f4; overflow: hidden; opacity: .95; max-width: 33em;
padding: 1em 1em 0; -moz-border-radius: 7px; -webkit-border-radius: 7px;
-webkit-box-shadow: 4px 4px 6px #333;
@@ -237,6 +237,11 @@
#dialog .buttons button:hover { background: #555; }
#dialog .buttons button:active { background: #333; color: #fff; }
+#dialog fieldset td#progress {
+ background: url(../image/progress.gif) 50% 50% no-repeat;
+ visibility: hidden;
+}
+
/* View selector */
#switch { color: #666; float: right; font-size: 90%; font-weight: bold;
@@ -327,6 +332,7 @@
#tabs .active :link, #tabs .active :visited { background: #e9e9e9;
border-bottom-color: #e9e9e9; color: #333;
}
+#tabs :link:focus, #tabs :visited:focus { outline: none; }
/* Document fields table */
Propchange: incubator/couchdb/branches/json_term_changes/src/couchdb/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Sun Aug 31 01:57:42 2008
@@ -5,4 +5,8 @@
couch.app
couch.app.tpl
couchjs
+edoc-info
+erlang.png
+stylesheet.css
*.beam
+*.html
Modified: incubator/couchdb/branches/json_term_changes/src/couchdb/couch_config.erl
URL: http://svn.apache.org/viewvc/incubator/couchdb/branches/json_term_changes/src/couchdb/couch_config.erl?rev=690659&r1=690658&r2=690659&view=diff
==============================================================================
--- incubator/couchdb/branches/json_term_changes/src/couchdb/couch_config.erl (original)
+++ incubator/couchdb/branches/json_term_changes/src/couchdb/couch_config.erl Sun Aug 31 01:57:42 2008
@@ -11,9 +11,9 @@
% the License.
%% @doc Reads CouchDB's ini file and gets queried for configuration parameters.
-%% This module is initialized with a list of ini files that it
-%% consecutively reads Key/Value pairs from and saves them in an ets
-%% table. If more an one ini file is specified, the last one is used to
+%% This module is initialized with a list of ini files that it
+%% consecutively reads Key/Value pairs from and saves them in an ets
+%% table. If more an one ini file is specified, the last one is used to
%% write changes that are made with store/2 back to that ini file.
-module(couch_config).
@@ -21,13 +21,13 @@
-behaviour(gen_server).
-export([start_link/1, init/1,
- handle_call/3, handle_cast/2, handle_info/2,
+ handle_call/3, handle_cast/2, handle_info/2,
terminate/2, code_change/3]).
--export([store/2, register/1, register/2,
+-export([store/2, register/1, register/2,
get/1, get/2,
lookup_match/1, lookup_match/2,
all/0, unset/1, load_ini_file/1]).
-
+
-record(config,
{notify_funs=[],
writeback_filename=""
@@ -37,7 +37,7 @@
%% @type etstable() = integer().
-start_link(IniFiles) -> gen_server:start_link({local, ?MODULE}, ?MODULE, IniFiles, []).
+start_link(IniFiles) -> gen_server:start_link({local, ?MODULE}, ?MODULE, IniFiles, []).
%% @spec store(Key::any(), Value::any()) -> {ok, Tab::etsatable()}
%% @doc Public API function that triggers storage of a Key/Value pair into the
@@ -57,12 +57,12 @@
fix_lookup_result(ets:lookup(?MODULE, Key), Default).
%% @spec lookup_match(Key::any()) -> Value::any() | undefined:atom()
-%% @doc Lets you look for a Key's Value specifying a pattern that gets passed
+%% @doc Lets you look for a Key's Value specifying a pattern that gets passed
%% to ets::match(). Returns undefined::atom() if no Key is found.
lookup_match(Key) -> gen_server:call(?MODULE, {lookup_match, Key}).
%% @spec lookup_match(Key::any(), Default::any()) -> Value::any() | Default
-%% @doc Lets you look for a Key's Value specifying a pattern that gets passed
+%% @doc Lets you look for a Key's Value specifying a pattern that gets passed
%% to ets::match(). Returns Default::any() if no Key is found
lookup_match(Key, Default) -> gen_server:call(?MODULE, {lookup_match, Key, Default}).
@@ -74,7 +74,7 @@
register(Fun, Pid) -> gen_server:call(?MODULE, {register, Fun, Pid}).
%% @spec unset(Key::any) -> ok
-%% @doc Public API call to remove the configuration entry from the internal
+%% @doc Public API call to remove the configuration entry from the internal
%% ets table. This change is _not_ written to the storage ini file.
unset(Key) -> gen_server:call(?MODULE, {unset, Key}).
@@ -115,7 +115,7 @@
handle_call({register, Fun, Pid}, _From, #config{notify_funs=PidFuns}=Config) ->
erlang:monitor(process, Pid),
{reply, ok, Config#config{notify_funs=[{Pid, Fun}|PidFuns]}}.
-
+
fix_lookup_result([{_Key, Value}], _Default) ->
Value;
@@ -125,7 +125,7 @@
[list_to_tuple(Value) || Value <- Values].
%% @spec insert_and_commit(Tab::etstable(), Config::any()) -> ok
-%% @doc Inserts a Key/Value pair into the ets table, writes it to the storage
+%% @doc Inserts a Key/Value pair into the ets table, writes it to the storage
%% ini file and calls all registered callback functions for Key.
insert_and_commit(Config, KV) ->
true = ets:insert(?MODULE, KV),
@@ -146,7 +146,7 @@
io:format("~s~n", [Msg]),
throw({startup_error, Msg})
end,
-
+
{ok, Lines} = regexp:split(binary_to_list(IniBin), "\r\n|\n|\r|\032"),
{_, ParsedIniValues} =
lists:foldl(fun(Line, {AccSectionName, AccValues}) ->
@@ -161,7 +161,7 @@
";" ++ _Comment ->
{AccSectionName, AccValues};
Line2 ->
- case regexp:split(Line2, "=") of
+ case regexp:split(Line2, "\s?=\s?") of
{ok, [_SingleElement]} -> % no "=" found, ignore this line
{AccSectionName, AccValues};
{ok, [""|_LineValues]} -> % line begins with "=", ignore
@@ -173,7 +173,7 @@
end
end
end, {"", []}, Lines),
-
+
[ets:insert(?MODULE, {Key, Value}) || {Key, Value} <- ParsedIniValues],
ok.
Modified: incubator/couchdb/branches/json_term_changes/src/couchdb/couch_config_writer.erl
URL: http://svn.apache.org/viewvc/incubator/couchdb/branches/json_term_changes/src/couchdb/couch_config_writer.erl?rev=690659&r1=690658&r2=690659&view=diff
==============================================================================
--- incubator/couchdb/branches/json_term_changes/src/couchdb/couch_config_writer.erl (original)
+++ incubator/couchdb/branches/json_term_changes/src/couchdb/couch_config_writer.erl Sun Aug 31 01:57:42 2008
@@ -10,11 +10,11 @@
% License for the specific language governing permissions and limitations under
% the License.
-%% @doc Saves a Key/Value pair to a ini file. The Key consists of a Module
-%% and Variable combination. If that combination is found in the ini file
-%% the new value replaces the old value. If only the Module is found the
-%% Variable and value combination is appended to the Module. If the Module
-%% does not yet exist in the ini file, it is added and the Variable/Value
+%% @doc Saves a Key/Value pair to a ini file. The Key consists of a Section
+%% and Option combination. If that combination is found in the ini file
+%% the new value replaces the old value. If only the Section is found the
+%% Option and value combination is appended to the Section. If the Section
+%% does not yet exist in the ini file, it is added and the Option/Value
%% pair is appended.
%% @see couch_config
@@ -24,33 +24,33 @@
-export([save_to_file/2]).
%% @spec save_to_file(
-%% Config::{{Module::string(), Variable::string()}, Value::string()},
+%% Config::{{Section::string(), Option::string()}, Value::string()},
%% File::filename()) -> ok
-%% @doc Saves a Module/Key/Value triple to the ini file File::filename()
-save_to_file({{Module, Variable}, Value}, File) ->
-
- ?LOG_DEBUG("saving to file '~s', Congif: '~p'", [File, {{Module, Variable}, Value}]),
-
+%% @doc Saves a Section/Key/Value triple to the ini file File::filename()
+save_to_file({{Section, Option}, Value}, File) ->
+
+ ?LOG_DEBUG("saving to file '~s', Config: '~p'", [File, {{Section, Option}, Value}]),
+
% open file and create a list of lines
{ok, Stream} = file:read_file(File),
OldFileContents = binary_to_list(Stream),
{ok, Lines} = regexp:split(OldFileContents, "\r\n|\n|\r|\032"),
-
+
% prepare input variables
- ModuleName = "[" ++ Module ++ "]",
- VariableList = Variable,
-
+ SectionName = "[" ++ Section ++ "]",
+ OptionList = Option,
+
% produce the contents for the config file
- NewFileContents =
- case NewFileContents2 = save_loop({{ModuleName, VariableList}, Value}, Lines, "", "", []) of
+ NewFileContents =
+ case NewFileContents2 = save_loop({{SectionName, OptionList}, Value}, Lines, "", "", []) of
% we didn't change anything, that means we couldn't find a matching
% [ini section] in which case we just append a new one.
OldFileContents ->
- append_new_ini_section({{ModuleName, VariableList}, Value}, OldFileContents);
+ append_new_ini_section({{SectionName, OptionList}, Value}, OldFileContents);
_ ->
NewFileContents2
end,
-
+
% do the save, close the config file and get out
save_file(File, NewFileContents),
file:close(Stream),
@@ -58,40 +58,40 @@
%% @doc Iterates over the lines of an ini file and replaces or adds a new
%% configuration directive.
-save_loop({{Module, Variable}, Value}, [Line|Rest], OldCurrentModule, Contents, DoneVariables) ->
+save_loop({{Section, Option}, Value}, [Line|Rest], OldCurrentSection, Contents, DoneOptions) ->
- % if we find a new [ini section] (Module), save that for reference
- NewCurrentModule = parse_module(Line, OldCurrentModule),
+ % if we find a new [ini section] (Section), save that for reference
+ NewCurrentSection = parse_module(Line, OldCurrentSection),
- % if the current Module is the one we want to change, try to match
- % each line with the Variable
- NewContents = case Module of
- NewCurrentModule ->
+ % if the current Section is the one we want to change, try to match
+ % each line with the Option
+ NewContents = case Section of
+ NewCurrentSection ->
% see if the current line matches the variable we want to substitute
- case parse_variable(Line, Variable, Value) of
+ case parse_variable(Line, Option, Value) of
% nope, return original line
nomatch ->
- DoneVariables2 = DoneVariables,
+ DoneOptions2 = DoneOptions,
Line;
% got em! return new line
NewLine ->
- DoneVariables2 = [Variable|DoneVariables],
+ DoneOptions2 = [Option|DoneOptions],
NewLine
end;
% if the variable we want to change couldn't be replaced, we append it
% in the proper module section
- OldCurrentModule ->
- case lists:member(Variable, DoneVariables) of
+ OldCurrentSection ->
+ case lists:member(Option, DoneOptions) of
false ->
- DoneVariables2 = [Variable|DoneVariables],
- Variable ++ "=" ++ Value ++ "\n" ++ Line;
+ DoneOptions2 = [Option|DoneOptions],
+ Option ++ " = " ++ Value ++ "\n" ++ Line;
true ->
- DoneVariables2 = DoneVariables,
+ DoneOptions2 = DoneOptions,
Line
end;
% otherwise we just print out the original line
_ ->
- DoneVariables2 = DoneVariables,
+ DoneOptions2 = DoneOptions,
Line
end,
% clumsy way to only append a newline character
@@ -101,46 +101,46 @@
Contents2 = case Contents of "" -> ""; _ -> Contents ++ "\n" end,
% go to next line
- save_loop({{Module, Variable}, Value}, Rest, NewCurrentModule, Contents2 ++ NewContents, DoneVariables2);
-
-save_loop(_Config, [], _OldModule, NewFileContents, _DoneVariable) ->
+ save_loop({{Section, Option}, Value}, Rest, NewCurrentSection, Contents2 ++ NewContents, DoneOptions2);
+
+save_loop(_Config, [], _OldSection, NewFileContents, _DoneOption) ->
% we're out of new lines, just return the new file's contents
NewFileContents.
-append_new_ini_section({{ModuleName, Variable}, Value}, OldFileContents) ->
- OldFileContents ++ "\n\n" ++ ModuleName ++ "\n" ++ Variable ++ "=" ++ Value ++ "\n".
+append_new_ini_section({{SectionName, Option}, Value}, OldFileContents) ->
+ OldFileContents ++ "\n\n" ++ SectionName ++ "\n" ++ Option ++ " = " ++ Value ++ "\n".
-%% @spec parse_module(Lins::string(), OldModule::string()) -> string()
-%% @doc Tries to match a line against a pattern specifying a ini module or
-%% section ("[Module]"). Returns OldModule if no match is found.
-parse_module(Line, OldModule) ->
+%% @spec parse_module(Lins::string(), OldSection::string()) -> string()
+%% @doc Tries to match a line against a pattern specifying a ini module or
+%% section ("[Section]"). Returns OldSection if no match is found.
+parse_module(Line, OldSection) ->
case regexp:match(Line, "^\\[([a-zA-Z0-9_-]*)\\]$") of
nomatch ->
- OldModule;
+ OldSection;
{error, Error} ->
io:format("ini file regex error module: '~s'~n", [Error]),
- OldModule;
+ OldSection;
{match, Start, Length} ->
string:substr(Line, Start, Length)
end.
-%% @spec parse_variable(Line::string(), Variable::string(), Value::string()) ->
+%% @spec parse_variable(Line::string(), Option::string(), Value::string()) ->
%% string() | nomatch
%% @doc Tries to match a variable assignment in Line. Returns nomatch if the
-%% Variable is not found. Returns a new line composed of the Variable and
+%% Option is not found. Returns a new line composed of the Option and
%% Value otherwise.
-parse_variable(Line, Variable, Value) ->
- case regexp:match(Line, "^" ++ Variable ++ "=") of
+parse_variable(Line, Option, Value) ->
+ case regexp:match(Line, "^" ++ Option ++ "\s?=") of
nomatch ->
nomatch;
{error, Error}->
io:format("ini file regex error variable: '~s'~n", [Error]),
nomatch;
{match, _Start, _Length} ->
- Variable ++ "=" ++ Value
+ Option ++ " = " ++ Value
end.
-%% @spec save_file(File::filename(), Contents::string()) ->
+%% @spec save_file(File::filename(), Contents::string()) ->
%% ok | {error, Reason::string()}
%% @doc Writes Contents to File
save_file(File, Contents) ->
Modified: incubator/couchdb/branches/json_term_changes/src/couchdb/couch_db_update_notifier_sup.erl
URL: http://svn.apache.org/viewvc/incubator/couchdb/branches/json_term_changes/src/couchdb/couch_db_update_notifier_sup.erl?rev=690659&r1=690658&r2=690659&view=diff
==============================================================================
--- incubator/couchdb/branches/json_term_changes/src/couchdb/couch_db_update_notifier_sup.erl (original)
+++ incubator/couchdb/branches/json_term_changes/src/couchdb/couch_db_update_notifier_sup.erl Sun Aug 31 01:57:42 2008
@@ -31,12 +31,12 @@
init([]) ->
Self = self(),
ok = couch_config:register(
- fun({"Update Notification", _}) ->
+ fun({"update_notification", _}) ->
exit(Self, reload_config)
end),
UpdateNotifierExes = couch_config:lookup_match(
- {{"Update Notification", '$1'}, '$2'}, []),
+ {{"update_notification", '$1'}, '$2'}, []),
{ok,
{{one_for_one, 10, 3600},
Modified: incubator/couchdb/branches/json_term_changes/src/couchdb/couch_file.erl
URL: http://svn.apache.org/viewvc/incubator/couchdb/branches/json_term_changes/src/couchdb/couch_file.erl?rev=690659&r1=690658&r2=690659&view=diff
==============================================================================
--- incubator/couchdb/branches/json_term_changes/src/couchdb/couch_file.erl (original)
+++ incubator/couchdb/branches/json_term_changes/src/couchdb/couch_file.erl Sun Aug 31 01:57:42 2008
@@ -363,12 +363,16 @@
{ok, Pos} = file:position(Fd, eof),
{reply, {file:pwrite(Fd, Pos, Bin2), Pos}, Fd};
handle_call({pread_bin, Pos}, _From, Fd) ->
- {ok, <<TermLen:32>>}
- = file:pread(Fd, Pos, 4),
+ {ok, <<TermLen:32>>} = file:pread(Fd, Pos, 4),
{ok, Bin} = file:pread(Fd, Pos + 4, TermLen),
{reply, {ok, Bin}, Fd};
handle_call({add_ref, Pid},_From, Fd) ->
- undefined = put(Pid, erlang:monitor(process, Pid)),
+ case get(Pid) of
+ undefined ->
+ put(Pid, {erlang:monitor(process, Pid), 1});
+ {MonRef, RefCnt} ->
+ put(Pid, {MonRef, RefCnt + 1})
+ end,
{reply, ok, Fd};
handle_call(num_refs, _From, Fd) ->
{monitors, Monitors} = process_info(self(), monitors),
@@ -382,9 +386,15 @@
catch unlink(Pid),
maybe_close_async(Fd);
handle_cast({drop_ref, Pid}, Fd) ->
- % don't check return of demonitor. The process could haved crashed causing
- % the {'DOWN', ...} message to be sent and the process unmonitored.
- erlang:demonitor(erase(Pid), [flush]),
+ case get(Pid) of
+ {MonRef, 1} ->
+ erase(Pid),
+ % don't check return of demonitor. The process could haved crashed causing
+ % the {'DOWN', ...} message to be sent and the process unmonitored.
+ erlang:demonitor(MonRef, [flush]);
+ {MonRef, Num} ->
+ put(Pid, {MonRef, Num-1})
+ end,
maybe_close_async(Fd).
@@ -392,7 +402,7 @@
{ok, State}.
handle_info({'DOWN', MonitorRef, _Type, Pid, _Info}, Fd) ->
- MonitorRef = erase(Pid),
+ {MonitorRef, _RefCount} = erase(Pid),
maybe_close_async(Fd);
handle_info(Info, Fd) ->
exit({error, {Info, Fd}}).
Modified: incubator/couchdb/branches/json_term_changes/src/couchdb/couch_ft_query.erl
URL: http://svn.apache.org/viewvc/incubator/couchdb/branches/json_term_changes/src/couchdb/couch_ft_query.erl?rev=690659&r1=690658&r2=690659&view=diff
==============================================================================
--- incubator/couchdb/branches/json_term_changes/src/couchdb/couch_ft_query.erl (original)
+++ incubator/couchdb/branches/json_term_changes/src/couchdb/couch_ft_query.erl Sun Aug 31 01:57:42 2008
@@ -28,11 +28,11 @@
init([]) ->
ok = couch_config:register(
- fun({"Search", "QueryServer"}) ->
+ fun({"search", "query_server"}) ->
?MODULE:stop()
end),
- case couch_config:get({"Search", "QueryServer"}, none) of
+ case couch_config:get({"search", "query_server"}, none) of
none ->
{ok, none};
QueryExec ->
Modified: incubator/couchdb/branches/json_term_changes/src/couchdb/couch_httpd.erl
URL: http://svn.apache.org/viewvc/incubator/couchdb/branches/json_term_changes/src/couchdb/couch_httpd.erl?rev=690659&r1=690658&r2=690659&view=diff
==============================================================================
--- incubator/couchdb/branches/json_term_changes/src/couchdb/couch_httpd.erl (original)
+++ incubator/couchdb/branches/json_term_changes/src/couchdb/couch_httpd.erl Sun Aug 31 01:57:42 2008
@@ -40,14 +40,14 @@
start_link() ->
% read config and register for configuration changes
-
+
% just stop if one of the config settings change. couch_server_sup
% will restart us and then we will pick up the new settings.
-
- BindAddress = couch_config:get({"HTTPd", "BindAddress"}, any),
- Port = couch_config:get({"HTTPd", "Port"}, "5984"),
- DocumentRoot = couch_config:get({"HTTPd", "DocumentRoot"}, "../../share/www"),
-
+
+ BindAddress = couch_config:get({"httpd", "bind_address"}, any),
+ Port = couch_config:get({"httpd", "port"}, "5984"),
+ DocumentRoot = couch_config:get({"httpd", "utils_dir"}, "../../share/www"),
+
% and off we go
Loop = fun (Req) -> apply(couch_httpd, handle_request, [Req, DocumentRoot]) end,
{ok, Pid} = mochiweb_http:start([
@@ -57,14 +57,14 @@
{port, Port}
]),
ok = couch_config:register(
- fun({"HTTPd", "BindAddress"}) ->
+ fun({"httpd", "bind_address"}) ->
?MODULE:stop();
- ({"HTTPd", "Port"}) ->
+ ({"httpd", "port"}) ->
?MODULE:stop();
- ({"HTTPd", "DocumentRoot"}) ->
+ ({"httpd", "utils_dir"}) ->
?MODULE:stop()
end, Pid),
-
+
{ok, Pid}.
stop() ->
@@ -77,7 +77,7 @@
% alias HEAD to GET as mochiweb takes care of stripping the body
Method = case Req:get(method) of
'HEAD' -> 'GET';
- Other ->
+ Other ->
% handling of non standard HTTP verbs. Should be fixe din gen_tcp:recv()
case Other of
"COPY" -> 'COPY';
@@ -110,7 +110,7 @@
Path,
Resp:get(code)
]).
-
+
handle_request(Req, DocumentRoot, Method, Path) ->
% Start = erlang:now(),
X = handle_request0(Req, DocumentRoot, Method, Path),
@@ -223,11 +223,11 @@
Error ->
throw(Error)
end;
-
+
handle_db_request(Req, Method, {DbName, Rest}) ->
case couch_db:open(DbName, []) of
{ok, Db} ->
- try
+ try
handle_db_request(Req, Method, {DbName, Db, Rest})
after
couch_db:close(Db)
@@ -593,6 +593,30 @@
end_json_response(Resp)
end;
+handle_doc_request(Req, 'POST', _DbName, Db, DocId) ->
+ Form = mochiweb_multipart:parse_form(Req),
+ Rev = proplists:get_value("_rev", Form),
+ NewAttachments = [{Name, {ContentType, Content}} ||
+ {Name, {ContentType, _}, Content} <-
+ proplists:get_all_values("_attachments", Form)],
+
+ Doc = case couch_db:open_doc_revs(Db, DocId, [Rev], []) of
+ {ok, [{ok, Doc0}]} -> Doc0#doc{revs=[Rev]};
+ {ok, [Error]} -> throw(Error)
+ end,
+
+ #doc{attachments=Attachments} = Doc,
+ NewDoc = Doc#doc{
+ attachments = Attachments ++ NewAttachments
+ },
+ {ok, NewRev} = couch_db:update_doc(Db, NewDoc, []),
+
+ send_json(Req, 201, [{"Etag", "\"" ++ NewRev ++ "\""}], {obj, [
+ {ok, true},
+ {id, DocId},
+ {rev, NewRev}
+ ]});
+
handle_doc_request(Req, 'PUT', _DbName, Db, DocId) ->
Json = ?JSON_DECODE(Req:recv_body(?MAX_DOC_SIZE)),
Doc = couch_doc:from_json_obj(Json),
@@ -640,7 +664,7 @@
case extract_header_rev(Req, proplists:get_value("rev", Req:parse_qs())) of
missing_rev ->
throw({
- bad_request,
+ bad_request,
"MOVE requires a specified rev parameter for the origin resource."}
);
Rev -> Rev
@@ -669,12 +693,12 @@
]});
handle_doc_request(_Req, _Method, _DbName, _Db, _DocId) ->
- throw({method_not_allowed, "DELETE,GET,HEAD,PUT,COPY,MOVE"}).
+ throw({method_not_allowed, "DELETE,GET,HEAD,POST,PUT,COPY,MOVE"}).
% Useful for debugging
% couch_doc_open(Db, DocId) ->
% couch_doc_open(Db, DocId, [], []).
-
+
couch_doc_open(Db, DocId, Rev, Options) ->
case Rev of
"" -> % open most recent rev
@@ -693,17 +717,6 @@
end
end.
-parse_copy_destination_header(Req) ->
- Destination = Req:get_header_value("Destination"),
- case regexp:match(Destination, "\\?") of
- nomatch ->
- {list_to_binary(Destination), []};
- {match, _, _} ->
- {ok, [DocId, RevQueryOptions]} = regexp:split(Destination, "\\?"),
- {ok, [_RevQueryKey, Rev]} = regexp:split(RevQueryOptions, "="),
- {list_to_binary(DocId), [list_to_binary(Rev)]}
- end.
-
% Attachment request handlers
handle_attachment_request(Req, 'GET', _DbName, Db, DocId, FileName) ->
@@ -734,32 +747,31 @@
handle_attachment_request(Req, Method, _DbName, Db, DocId, FileName)
when (Method == 'PUT') or (Method == 'DELETE') ->
-
- NewAttachment =
- case Method of
- 'DELETE' ->
- [];
- _ ->
- [{FileName, {
- Req:get_header_value("Content-Type"),
- Req:recv_body()
- }}]
+
+ NewAttachment = case Method of
+ 'DELETE' ->
+ [];
+ _ ->
+ [{FileName, {
+ Req:get_header_value("Content-Type"),
+ Req:recv_body()
+ }}]
end,
- Doc =
- case extract_header_rev(Req, proplists:get_value("rev", Req:parse_qs())) of
- missing_rev -> % make the new doc
- #doc{id=DocId};
- Rev ->
- case couch_db:open_doc_revs(Db, DocId, [Rev], []) of
- {ok, [{ok, Doc0}]} -> Doc0#doc{revs=[Rev]};
- {ok, [Error]} -> throw(Error)
- end
+ Doc = case extract_header_rev(Req, proplists:get_value("rev", Req:parse_qs())) of
+ missing_rev -> % make the new doc
+ #doc{id=DocId};
+ Rev ->
+ case couch_db:open_doc_revs(Db, DocId, [Rev], []) of
+ {ok, [{ok, Doc0}]} -> Doc0#doc{revs=[Rev]};
+ {ok, [Error]} -> throw(Error)
+ end
end,
-
+
#doc{attachments=Attachments} = Doc,
DocEdited = Doc#doc{
- attachments = NewAttachment ++ proplists:delete(FileName, Attachments)},
+ attachments = NewAttachment ++ proplists:delete(FileName, Attachments)
+ },
{ok, UpdatedRev} = couch_db:update_doc(Db, DocEdited, []),
send_json(Req, case Method of 'DELETE' -> 200; _ -> 201 end, {[
{ok, true},
@@ -770,73 +782,54 @@
handle_attachment_request(_Req, _Method, _DbName, _Db, _DocId, _FileName) ->
throw({method_not_allowed, "GET,HEAD,DELETE,PUT"}).
-extract_header_rev(Req, ExplictRev) when is_list(ExplictRev)->
- extract_header_rev(Req, list_to_binary(ExplictRev));
-extract_header_rev(Req, ExplictRev) ->
- Etag = case Req:get_header_value("If-Match") of
- undefined -> undefined;
- Tag -> string:strip(Tag, both, $")
- end,
- case {ExplictRev, Etag} of
- {undefined, undefined} -> missing_rev;
- {_, undefined} -> ExplictRev;
- {undefined, _} -> list_to_binary(Etag);
- _ when ExplictRev == Etag -> list_to_binary(Etag);
- _ ->
- throw({bad_request, "Document rev and etag have different values"})
- end.
-
% Config request handlers
handle_config_request(_Req, Method, {config, Config}) ->
- [Module, Key] = string:tokens(Config, "/"),
- handle_config_request(_Req, Method, {[Module, Key]});
+ [Section, Option] = string:tokens(Config, "/"),
+ handle_config_request(_Req, Method, {[Section, Option]});
-
-% PUT /_config/Module/Key
+% PUT /_config/Section/Option
% "value"
-handle_config_request(_Req, 'PUT', {[Module, Key]}) ->
- handle_config_request(_Req, 'POST', {[Module, Key]});
+handle_config_request(_Req, 'PUT', {[Section, Option]}) ->
+ handle_config_request(_Req, 'POST', {[Section, Option]});
-% POST,PUT /_config/Module/Key
+% POST,PUT /_config/Section/Option
% "value"
-
-handle_config_request(Req, 'POST', {[Module, Key]}) ->
+handle_config_request(Req, 'POST', {[Section, Option]}) ->
Value = binary_to_list(Req:recv_body()),
- ok = couch_config:store({Module, Key}, Value),
+ ok = couch_config:store({Section, Option}, Value),
send_json(Req, 200, {obj, [
{ok, true},
- {module, Module},
- {key, Key},
+ {section, Section},
+ {name, Option},
{value, Value}
]});
-
-% GET /_config/Module/Key
-handle_config_request(Req, 'GET', {[Module, Key]}) ->
- case couch_config:get({Module, Key},null) of
+
+% GET /_config/Section/Option
+handle_config_request(Req, 'GET', {[Section, Option]}) ->
+ case couch_config:get({Section, Option},null) of
null ->
throw({not_found, unknown_config_value});
Value ->
send_json(Req, 200, {obj, [
{ok, true},
- {module, Module},
- {key, Key},
+ {section, Section},
+ {name, Option},
{value, Value}
]})
end;
-
-% DELETE /_config/Key
-handle_config_request(Req, 'DELETE', {[Module, Key]}) ->
- case couch_config:get({Module, Key}, null) of
+% DELETE /_config/Section/Option
+handle_config_request(Req, 'DELETE', {[Section, Option]}) ->
+ case couch_config:get({Section, Option}, null) of
null ->
throw({not_found, unknown_config_value});
OldValue ->
- couch_config:unset({Module, Key}),
+ couch_config:unset({Section, Option}),
send_json(Req, 200, {obj, [
{ok, true},
- {module, Module},
- {key, Key},
+ {section, Section},
+ {name, Option},
{old_value, OldValue}
]})
end.
@@ -845,7 +838,7 @@
% TODO:
% POST,PUT /_config/
% [{Key, Value}, {K2, V2}, {K3, V3}]
-%
+%
% POST,PUT/_config/Key?value=Value
@@ -1118,6 +1111,33 @@
error_to_json0(Error) ->
{500, error, Error}.
+extract_header_rev(Req, ExplictRev) when is_list(ExplictRev)->
+ extract_header_rev(Req, list_to_binary(ExplictRev));
+extract_header_rev(Req, ExplictRev) ->
+ Etag = case Req:get_header_value("If-Match") of
+ undefined -> undefined;
+ Tag -> string:strip(Tag, both, $")
+ end,
+ case {ExplictRev, Etag} of
+ {undefined, undefined} -> missing_rev;
+ {_, undefined} -> ExplictRev;
+ {undefined, _} -> list_to_binary(Etag);
+ _ when ExplictRev == Etag -> list_to_binary(Etag);
+ _ ->
+ throw({bad_request, "Document rev and etag have different values"})
+ end.
+
+parse_copy_destination_header(Req) ->
+ Destination = Req:get_header_value("Destination"),
+ case regexp:match(Destination, "\\?") of
+ nomatch ->
+ {list_to_binary(Destination), []};
+ {match, _, _} ->
+ {ok, [DocId, RevQueryOptions]} = regexp:split(Destination, "\\?"),
+ {ok, [_RevQueryKey, Rev]} = regexp:split(RevQueryOptions, "="),
+ {list_to_binary(DocId), [list_to_binary(Rev)]}
+ end.
+
send_error(Req, {method_not_allowed, Methods}) ->
{ok, Req:respond({405, [{"Allow", Methods}] ++ server_header(), <<>>})};
send_error(Req, {modified, Etag}) ->
Modified: incubator/couchdb/branches/json_term_changes/src/couchdb/couch_log.erl
URL: http://svn.apache.org/viewvc/incubator/couchdb/branches/json_term_changes/src/couchdb/couch_log.erl?rev=690659&r1=690658&r2=690659&view=diff
==============================================================================
--- incubator/couchdb/branches/json_term_changes/src/couchdb/couch_log.erl (original)
+++ incubator/couchdb/branches/json_term_changes/src/couchdb/couch_log.erl Sun Aug 31 01:57:42 2008
@@ -46,14 +46,14 @@
% just stop if one of the config settings change. couch_server_sup
% will restart us and then we will pick up the new settings.
ok = couch_config:register(
- fun({"Log", "File"}) ->
+ fun({"log", "file"}) ->
?MODULE:stop();
- ({"Log", "Level"}) ->
+ ({"log", "level"}) ->
?MODULE:stop()
end),
- Filename = couch_config:get({"Log", "File"}, "couchdb.log"),
- Level = couch_config:get({"Log", "Level"},"info"),
+ Filename = couch_config:get({"log", "file"}, "couchdb.log"),
+ Level = couch_config:get({"log", "level"},"info"),
{ok, Fd} = file:open(Filename, [append]),
{ok, {Fd, level_integer(list_to_atom(Level))}}.
Modified: incubator/couchdb/branches/json_term_changes/src/couchdb/couch_query_servers.erl
URL: http://svn.apache.org/viewvc/incubator/couchdb/branches/json_term_changes/src/couchdb/couch_query_servers.erl?rev=690659&r1=690658&r2=690659&view=diff
==============================================================================
--- incubator/couchdb/branches/json_term_changes/src/couchdb/couch_query_servers.erl (original)
+++ incubator/couchdb/branches/json_term_changes/src/couchdb/couch_query_servers.erl Sun Aug 31 01:57:42 2008
@@ -35,7 +35,7 @@
case get(query_server_timeout) of
undefined ->
Timeout = list_to_integer(couch_config:get(
- {"CouchDB Query Server Options", "QueryTimeout"}, "5000")),
+ {"couchdb", "view_timeout"}, "5000")),
put(timeout, Timeout);
Timeout -> ok
end,
@@ -183,12 +183,12 @@
% will restart us and then we will pick up the new settings.
ok = couch_config:register(
- fun({"CouchDB Query Server" ++ _, _}) ->
+ fun({"query_servers" ++ _, _}) ->
?MODULE:stop()
end),
QueryServers = couch_config:lookup_match(
- {{"CouchDB Query Servers", '$1'}, '$2'}, []),
+ {{"query_servers", '$1'}, '$2'}, []),
QueryServers2 =
[{list_to_binary(Lang), Path} || {Lang, Path} <- QueryServers],
Modified: incubator/couchdb/branches/json_term_changes/src/couchdb/couch_server.erl
URL: http://svn.apache.org/viewvc/incubator/couchdb/branches/json_term_changes/src/couchdb/couch_server.erl?rev=690659&r1=690658&r2=690659&view=diff
==============================================================================
--- incubator/couchdb/branches/json_term_changes/src/couchdb/couch_server.erl (original)
+++ incubator/couchdb/branches/json_term_changes/src/couchdb/couch_server.erl Sun Aug 31 01:57:42 2008
@@ -30,7 +30,7 @@
}).
start() ->
- start(["couch.ini"]).
+ start(["default.ini"]).
start(IniFiles) ->
couch_server_sup:start_link(IniFiles).
@@ -94,13 +94,13 @@
% just stop if one of the config settings change. couch_server_sup
% will restart us and then we will pick up the new settings.
- RootDir = couch_config:get({"CouchDB", "RootDirectory"}, "."),
- MaxDbsOpen = couch_config:get({"CouchDB", "MaxDbsOpen"}, "100"),
+ RootDir = couch_config:get({"couchdb", "database_dir"}, "."),
+ MaxDbsOpen = couch_config:get({"couchdb", "max_open_databases"}, "100"),
Self = self(),
ok = couch_config:register(
- fun({"CouchDB", "RootDirectory"}) ->
+ fun({"couchdb", "database_dir"}) ->
exit(Self, config_change);
- ({"CouchDB", "ServerOptions"}) ->
+ ({"couchdb", "server_options"}) ->
exit(Self, config_change)
end),
{ok, RegExp} = regexp:parse("^[a-z][a-z0-9\\_\\$()\\+\\-\\/]*$"),
@@ -264,7 +264,7 @@
{reply, Error, Server}
end;
handle_call(remote_restart, _From, Server) ->
- case couch_config:get({"CouchDB", "AllowRemoteRestart"}, "false") of
+ case couch_config:get({"couchdb", "allow_remote_restart"}, "false") of
"true" ->
exit(couch_server_sup, restart);
_ ->
Modified: incubator/couchdb/branches/json_term_changes/src/couchdb/couch_server_sup.erl
URL: http://svn.apache.org/viewvc/incubator/couchdb/branches/json_term_changes/src/couchdb/couch_server_sup.erl?rev=690659&r1=690658&r2=690659&view=diff
==============================================================================
--- incubator/couchdb/branches/json_term_changes/src/couchdb/couch_server_sup.erl (original)
+++ incubator/couchdb/branches/json_term_changes/src/couchdb/couch_server_sup.erl Sun Aug 31 01:57:42 2008
@@ -49,7 +49,7 @@
{ok, ConfigPid} = couch_config:start_link(IniFiles),
- LogLevel = couch_config:get({"Log", "Level"}, "info"),
+ LogLevel = couch_config:get({"log", "level"}, "info"),
% announce startup
io:format("Apache CouchDB ~s (LogLevel=~s) is starting.~n", [
couch_server:get_version(),
@@ -64,7 +64,7 @@
end,
LibDir =
- case couch_config:get({"CouchDB", "UtilDriverDir"}, null) of
+ case couch_config:get({"couchdb", "util_driver_dir"}, null) of
null ->
filename:join(code:priv_dir(couch), "lib");
LibDir0 -> LibDir0
@@ -100,7 +100,7 @@
% just restart if one of the config settings change.
couch_config:register(
- fun({"CouchDB", "UtilDriverDir"}) ->
+ fun({"couchdb", "util_driver_dir"}) ->
?MODULE:stop()
end, Pid),
Modified: incubator/couchdb/branches/json_term_changes/src/couchdb/couch_util.erl
URL: http://svn.apache.org/viewvc/incubator/couchdb/branches/json_term_changes/src/couchdb/couch_util.erl?rev=690659&r1=690658&r2=690659&view=diff
==============================================================================
--- incubator/couchdb/branches/json_term_changes/src/couchdb/couch_util.erl (original)
+++ incubator/couchdb/branches/json_term_changes/src/couchdb/couch_util.erl Sun Aug 31 01:57:42 2008
@@ -24,8 +24,6 @@
-define(FLUSH_MAX_MEM, 10000000).
start_driver(LibDir) ->
- % read config and register for configuration changes
-
case erl_ddll:load_driver(LibDir, "couch_erl_driver") of
ok ->
ok;
Modified: incubator/couchdb/branches/json_term_changes/src/couchdb/couch_view.erl
URL: http://svn.apache.org/viewvc/incubator/couchdb/branches/json_term_changes/src/couchdb/couch_view.erl?rev=690659&r1=690658&r2=690659&view=diff
==============================================================================
--- incubator/couchdb/branches/json_term_changes/src/couchdb/couch_view.erl (original)
+++ incubator/couchdb/branches/json_term_changes/src/couchdb/couch_view.erl Sun Aug 31 01:57:42 2008
@@ -229,10 +229,10 @@
init([]) ->
% read configuration settings and register for configuration changes
- RootDir = couch_config:get({"CouchDB", "RootDirectory"}),
+ RootDir = couch_config:get({"couchdb", "database_dir"}),
Self = self(),
ok = couch_config:register(
- fun({"CouchDB", "RootDirectory"})->
+ fun({"couchdb", "database_dir"})->
exit(Self, config_change)
end),
Propchange: incubator/couchdb/branches/json_term_changes/test/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Sun Aug 31 01:57:42 2008
@@ -0,0 +1,3 @@
+.deps
+Makefile.in
+Makefile
Modified: incubator/couchdb/branches/json_term_changes/test/couch_config_test.erl
URL: http://svn.apache.org/viewvc/incubator/couchdb/branches/json_term_changes/test/couch_config_test.erl?rev=690659&r1=690658&r2=690659&view=diff
==============================================================================
--- incubator/couchdb/branches/json_term_changes/test/couch_config_test.erl (original)
+++ incubator/couchdb/branches/json_term_changes/test/couch_config_test.erl Sun Aug 31 01:57:42 2008
@@ -30,14 +30,21 @@
store(Key2, Value2) ->
+ Filename = "local.ini",
+ file:write_file(Filename, ""),
+
Key = binary_to_list(term_to_binary(Key2)),
Value = binary_to_list(term_to_binary(Value2)),
- couch_config:start_link(["couch.ini"]),
+ couch_config:start_link(["local.ini"]),
couch_config:store({"test_module", Key}, Value),
Result = couch_config:get({"test_module", Key}),
couch_config:unset(Key),
couch_config:terminate(end_of_test, ok),
+
+ % clean up
+ file:delete(Filename),
+
Value = Result.
\ No newline at end of file
Modified: incubator/couchdb/branches/json_term_changes/test/couch_config_writer_test.erl
URL: http://svn.apache.org/viewvc/incubator/couchdb/branches/json_term_changes/test/couch_config_writer_test.erl?rev=690659&r1=690658&r2=690659&view=diff
==============================================================================
--- incubator/couchdb/branches/json_term_changes/test/couch_config_writer_test.erl (original)
+++ incubator/couchdb/branches/json_term_changes/test/couch_config_writer_test.erl Sun Aug 31 01:57:42 2008
@@ -17,47 +17,47 @@
Contents = "; etc/couchdb/couch.ini.tpl. Generated from couch.ini.tpl.in by configure.
[CouchDB]
-RootDirectory=/Users/jan/Work/runcouch/conf9/var/lib/couchdb
-UtilDriverDir=/Users/jan/Work/runcouch/conf9/lib/couchdb/erlang/lib/couch-0.7.3a663206/priv/lib
-MaximumDocumentSize=4294967296 ; 4 GB
+RootDirectory = /Users/jan/Work/runcouch/conf9/var/lib/couchdb
+UtilDriverDir = /Users/jan/Work/runcouch/conf9/lib/couchdb/erlang/lib/couch-0.7.3a663206/priv/lib
+MaximumDocumentSize = 4294967296 ; 4 GB
[HTTPd]
-Port=5984
-BindAddress=127.0.0.1
-DocumentRoot=/Users/jan/Work/runcouch/conf9/share/couchdb/www
+Port = 5984
+BindAddress = 127.0.0.1
+DocumentRoot = /Users/jan/Work/runcouch/conf9/share/couchdb/www
[Log]
-File=/Users/jan/Work/runcouch/conf9/var/log/couchdb/couch.log
-Level=info
+File = /Users/jan/Work/runcouch/conf9/var/log/couchdb/couch.log
+Level = info
[CouchDB Query Servers]
-javascript=/Users/jan/Work/runcouch/conf9/bin/couchjs /Users/jan/Work/runcouch/conf9/share/couchdb/server/main.js
+javascript = /Users/jan/Work/runcouch/conf9/bin/couchjs /Users/jan/Work/runcouch/conf9/share/couchdb/server/main.js
[CouchDB Query Server Options]
-QueryTimeout=5000 ; 5 seconds
+QueryTimeout = 5000 ; 5 seconds
",
Expect = "; etc/couchdb/couch.ini.tpl. Generated from couch.ini.tpl.in by configure.
[CouchDB]
-RootDirectory=/Users/jan/Work/runcouch/conf9/var/lib/couchdb
-UtilDriverDir=/Users/jan/Work/runcouch/conf9/lib/couchdb/erlang/lib/couch-0.7.3a663206/priv/lib
-MaximumDocumentSize=4294967296 ; 4 GB
+RootDirectory = /Users/jan/Work/runcouch/conf9/var/lib/couchdb
+UtilDriverDir = /Users/jan/Work/runcouch/conf9/lib/couchdb/erlang/lib/couch-0.7.3a663206/priv/lib
+MaximumDocumentSize = 4294967296 ; 4 GB
[HTTPd]
-Port=5985
-BindAddress=127.0.0.1
-DocumentRoot=/Users/jan/Work/runcouch/conf9/share/couchdb/www
+Port = 5985
+BindAddress = 127.0.0.1
+DocumentRoot = /Users/jan/Work/runcouch/conf9/share/couchdb/www
[Log]
-File=/Users/jan/Work/runcouch/conf9/var/log/couchdb/couch.log
-Level=info
+File = /Users/jan/Work/runcouch/conf9/var/log/couchdb/couch.log
+Level = info
[CouchDB Query Servers]
-javascript=/Users/jan/Work/runcouch/conf9/bin/couchjs /Users/jan/Work/runcouch/conf9/share/couchdb/server/main.js
+javascript = /Users/jan/Work/runcouch/conf9/bin/couchjs /Users/jan/Work/runcouch/conf9/share/couchdb/server/main.js
[CouchDB Query Server Options]
-QueryTimeout=5000 ; 5 seconds
+QueryTimeout = 5000 ; 5 seconds
",
run_operation_and_compare_results(Contents, Expect, {{"HTTPd", "Port"}, "5985"}).
@@ -67,48 +67,48 @@
Contents = "; etc/couchdb/couch.ini.tpl. Generated from couch.ini.tpl.in by configure.
[CouchDB]
-RootDirectory=/Users/jan/Work/runcouch/conf9/var/lib/couchdb
-UtilDriverDir=/Users/jan/Work/runcouch/conf9/lib/couchdb/erlang/lib/couch-0.7.3a663206/priv/lib
-MaximumDocumentSize=4294967296 ; 4 GB
+RootDirectory = /Users/jan/Work/runcouch/conf9/var/lib/couchdb
+UtilDriverDir = /Users/jan/Work/runcouch/conf9/lib/couchdb/erlang/lib/couch-0.7.3a663206/priv/lib
+MaximumDocumentSize = 4294967296 ; 4 GB
[HTTPd]
-Port=5984
-BindAddress=127.0.0.1
-DocumentRoot=/Users/jan/Work/runcouch/conf9/share/couchdb/www
+Port = 5984
+BindAddress = 127.0.0.1
+DocumentRoot = /Users/jan/Work/runcouch/conf9/share/couchdb/www
[Log]
-File=/Users/jan/Work/runcouch/conf9/var/log/couchdb/couch.log
-Level=info
+File = /Users/jan/Work/runcouch/conf9/var/log/couchdb/couch.log
+Level = info
[CouchDB Query Servers]
-javascript=/Users/jan/Work/runcouch/conf9/bin/couchjs /Users/jan/Work/runcouch/conf9/share/couchdb/server/main.js
+javascript = /Users/jan/Work/runcouch/conf9/bin/couchjs /Users/jan/Work/runcouch/conf9/share/couchdb/server/main.js
[CouchDB Query Server Options]
-QueryTimeout=5000 ; 5 seconds
+QueryTimeout = 5000 ; 5 seconds
",
Expect = "; etc/couchdb/couch.ini.tpl. Generated from couch.ini.tpl.in by configure.
[CouchDB]
-RootDirectory=/Users/jan/Work/runcouch/conf9/var/lib/couchdb
-UtilDriverDir=/Users/jan/Work/runcouch/conf9/lib/couchdb/erlang/lib/couch-0.7.3a663206/priv/lib
-MaximumDocumentSize=4294967296 ; 4 GB
+RootDirectory = /Users/jan/Work/runcouch/conf9/var/lib/couchdb
+UtilDriverDir = /Users/jan/Work/runcouch/conf9/lib/couchdb/erlang/lib/couch-0.7.3a663206/priv/lib
+MaximumDocumentSize = 4294967296 ; 4 GB
[HTTPd]
-Port=5984
-BindAddress=127.0.0.1
-DocumentRoot=/Users/jan/Work/runcouch/conf9/share/couchdb/www
+Port = 5984
+BindAddress = 127.0.0.1
+DocumentRoot = /Users/jan/Work/runcouch/conf9/share/couchdb/www
-FantasyConfiguration=Citation Needed
+FantasyConfiguration = Citation Needed
[Log]
-File=/Users/jan/Work/runcouch/conf9/var/log/couchdb/couch.log
-Level=info
+File = /Users/jan/Work/runcouch/conf9/var/log/couchdb/couch.log
+Level = info
[CouchDB Query Servers]
-javascript=/Users/jan/Work/runcouch/conf9/bin/couchjs /Users/jan/Work/runcouch/conf9/share/couchdb/server/main.js
+javascript = /Users/jan/Work/runcouch/conf9/bin/couchjs /Users/jan/Work/runcouch/conf9/share/couchdb/server/main.js
[CouchDB Query Server Options]
-QueryTimeout=5000 ; 5 seconds
+QueryTimeout = 5000 ; 5 seconds
",
run_operation_and_compare_results(Contents, Expect, {{"HTTPd", "FantasyConfiguration"}, "Citation Needed"}).
@@ -118,54 +118,54 @@
Contents = "; etc/couchdb/couch.ini.tpl. Generated from couch.ini.tpl.in by configure.
[CouchDB]
-RootDirectory=/Users/jan/Work/runcouch/conf9/var/lib/couchdb
-UtilDriverDir=/Users/jan/Work/runcouch/conf9/lib/couchdb/erlang/lib/couch-0.7.3a663206/priv/lib
-MaximumDocumentSize=4294967296 ; 4 GB
+RootDirectory = /Users/jan/Work/runcouch/conf9/var/lib/couchdb
+UtilDriverDir = /Users/jan/Work/runcouch/conf9/lib/couchdb/erlang/lib/couch-0.7.3a663206/priv/lib
+MaximumDocumentSize = 4294967296 ; 4 GB
[HTTPd]
-Port=5984
-BindAddress=127.0.0.1
-DocumentRoot=/Users/jan/Work/runcouch/conf9/share/couchdb/www
+Port = 5984
+BindAddress = 127.0.0.1
+DocumentRoot = /Users/jan/Work/runcouch/conf9/share/couchdb/www
[Log]
-File=/Users/jan/Work/runcouch/conf9/var/log/couchdb/couch.log
-Level=info
+File = /Users/jan/Work/runcouch/conf9/var/log/couchdb/couch.log
+Level = info
[CouchDB Query Servers]
-javascript=/Users/jan/Work/runcouch/conf9/bin/couchjs /Users/jan/Work/runcouch/conf9/share/couchdb/server/main.js
+javascript = /Users/jan/Work/runcouch/conf9/bin/couchjs /Users/jan/Work/runcouch/conf9/share/couchdb/server/main.js
[CouchDB Query Server Options]
-QueryTimeout=5000 ; 5 seconds",
+QueryTimeout = 5000 ; 5 seconds",
Expect = "; etc/couchdb/couch.ini.tpl. Generated from couch.ini.tpl.in by configure.
[CouchDB]
-RootDirectory=/Users/jan/Work/runcouch/conf9/var/lib/couchdb
-UtilDriverDir=/Users/jan/Work/runcouch/conf9/lib/couchdb/erlang/lib/couch-0.7.3a663206/priv/lib
-MaximumDocumentSize=4294967296 ; 4 GB
+RootDirectory = /Users/jan/Work/runcouch/conf9/var/lib/couchdb
+UtilDriverDir = /Users/jan/Work/runcouch/conf9/lib/couchdb/erlang/lib/couch-0.7.3a663206/priv/lib
+MaximumDocumentSize = 4294967296 ; 4 GB
[HTTPd]
-Port=5984
-BindAddress=127.0.0.1
-DocumentRoot=/Users/jan/Work/runcouch/conf9/share/couchdb/www
+Port = 5984
+BindAddress = 127.0.0.1
+DocumentRoot = /Users/jan/Work/runcouch/conf9/share/couchdb/www
[Log]
-File=/Users/jan/Work/runcouch/conf9/var/log/couchdb/couch.log
-Level=info
+File = /Users/jan/Work/runcouch/conf9/var/log/couchdb/couch.log
+Level = info
[CouchDB Query Servers]
-javascript=/Users/jan/Work/runcouch/conf9/bin/couchjs /Users/jan/Work/runcouch/conf9/share/couchdb/server/main.js
+javascript = /Users/jan/Work/runcouch/conf9/bin/couchjs /Users/jan/Work/runcouch/conf9/share/couchdb/server/main.js
[CouchDB Query Server Options]
-QueryTimeout=5000 ; 5 seconds
+QueryTimeout = 5000 ; 5 seconds
[Erlang]
-Option=Value
+Option = Value
",
run_operation_and_compare_results(Contents, Expect, {{"Erlang", "Option"}, "Value"}).
run_operation_and_compare_results(Contents, Expect, Config) ->
- Filename = "couch.ini",
+ Filename = "local.ini",
file:write_file(Filename, Contents),
% call replace function
@@ -176,6 +176,6 @@
Result = binary_to_list(Result_),
% clean up
- % file:delete(Filename),
+ file:delete(Filename),
Result = Expect.
Propchange: incubator/couchdb/branches/json_term_changes/test/runner.sh
------------------------------------------------------------------------------
svn:executable = *