Commit 0500b645 authored by Romain Courteaud's avatar Romain Courteaud

Release 3.30.0

Speed optimization.
parent ee320069
...@@ -8195,47 +8195,64 @@ return new Parser; ...@@ -8195,47 +8195,64 @@ return new Parser;
} }
} }
function ensurePushableQueue(callback, argument_list, context) {
var result;
try {
result = callback.apply(context, argument_list);
} catch (e) {
return new RSVP.Queue()
.push(function returnPushableError() {
return RSVP.reject(e);
});
}
if (result instanceof RSVP.Queue) {
return result;
}
return new RSVP.Queue()
.push(function returnPushableResult() {
return result;
});
}
function declareMethod(klass, name, precondition_function, post_function) { function declareMethod(klass, name, precondition_function, post_function) {
klass.prototype[name] = function () { klass.prototype[name] = function () {
var argument_list = arguments, var argument_list = arguments,
context = this, context = this,
precondition_result; precondition_result,
storage_method,
queue;
return new RSVP.Queue() // Precondition function are not asynchronous
.push(function () { if (precondition_function !== undefined) {
if (precondition_function !== undefined) { precondition_result = precondition_function.apply(
return precondition_function.apply( context.__storage,
context.__storage, [argument_list, context, name]
[argument_list, context, name] );
); }
}
}) storage_method = context.__storage[name];
.push(function (result) { if (storage_method === undefined) {
var storage_method = context.__storage[name]; throw new jIO.util.jIOError(
precondition_result = result; "Capacity '" + name + "' is not implemented on '" +
if (storage_method === undefined) { context.__type + "'",
throw new jIO.util.jIOError( 501
"Capacity '" + name + "' is not implemented on '" + );
context.__type + "'", }
501 queue = ensurePushableQueue(storage_method, argument_list,
); context.__storage);
}
return storage_method.apply( if (post_function !== undefined) {
context.__storage, queue
argument_list .push(function (result) {
);
})
.push(function (result) {
if (post_function !== undefined) {
return post_function.call( return post_function.call(
context, context,
argument_list, argument_list,
result, result,
precondition_result precondition_result
); );
} });
return result; }
}); return queue;
}; };
// Allow chain // Allow chain
return this; return this;
...@@ -8267,17 +8284,16 @@ return new Parser; ...@@ -8267,17 +8284,16 @@ return new Parser;
JioProxyStorage.prototype.post = function () { JioProxyStorage.prototype.post = function () {
var context = this, var context = this,
argument_list = arguments; argument_list = arguments;
return new RSVP.Queue() return ensurePushableQueue(function () {
.push(function () { var storage_method = context.__storage.post;
var storage_method = context.__storage.post; if (storage_method === undefined) {
if (storage_method === undefined) { throw new jIO.util.jIOError(
throw new jIO.util.jIOError( "Capacity 'post' is not implemented on '" + context.__type + "'",
"Capacity 'post' is not implemented on '" + context.__type + "'", 501
501 );
); }
} return context.__storage.post.apply(context.__storage, argument_list);
return context.__storage.post.apply(context.__storage, argument_list); });
});
}; };
declareMethod(JioProxyStorage, 'putAttachment', function (argument_list, declareMethod(JioProxyStorage, 'putAttachment', function (argument_list,
...@@ -8395,13 +8411,8 @@ return new Parser; ...@@ -8395,13 +8411,8 @@ return new Parser;
501 501
); );
} }
return new RSVP.Queue() return ensurePushableQueue(storage_method, argument_list,
.push(function () { context.__storage);
return storage_method.apply(
context.__storage,
argument_list
);
});
}; };
JioProxyStorage.prototype.hasCapacity = function (name) { JioProxyStorage.prototype.hasCapacity = function (name) {
...@@ -8425,27 +8436,26 @@ return new Parser; ...@@ -8425,27 +8436,26 @@ return new Parser;
if (options === undefined) { if (options === undefined) {
options = {}; options = {};
} }
return new RSVP.Queue() return ensurePushableQueue(function () {
.push(function () { if (context.hasCapacity("list") &&
if (context.hasCapacity("list") && ((options.query === undefined) || context.hasCapacity("query")) &&
((options.query === undefined) || context.hasCapacity("query")) && ((options.sort_on === undefined) || context.hasCapacity("sort")) &&
((options.sort_on === undefined) || context.hasCapacity("sort")) && ((options.select_list === undefined) ||
((options.select_list === undefined) || context.hasCapacity("select")) &&
context.hasCapacity("select")) && ((options.include_docs === undefined) ||
((options.include_docs === undefined) || context.hasCapacity("include")) &&
context.hasCapacity("include")) && ((options.limit === undefined) || context.hasCapacity("limit"))) {
((options.limit === undefined) || context.hasCapacity("limit"))) { return context.buildQuery(options)
return context.buildQuery(options); .push(function (result) {
} return {
}) data: {
.push(function (result) { rows: result,
return { total_rows: result.length
data: { }
rows: result, };
total_rows: result.length });
} }
}; });
});
}; };
declareMethod(JioProxyStorage, "allAttachments", checkId); declareMethod(JioProxyStorage, "allAttachments", checkId);
...@@ -8454,14 +8464,13 @@ return new Parser; ...@@ -8454,14 +8464,13 @@ return new Parser;
JioProxyStorage.prototype.repair = function () { JioProxyStorage.prototype.repair = function () {
var context = this, var context = this,
argument_list = arguments; argument_list = arguments;
return new RSVP.Queue() return ensurePushableQueue(function () {
.push(function () { var storage_method = context.__storage.repair;
var storage_method = context.__storage.repair; if (storage_method !== undefined) {
if (storage_method !== undefined) { return context.__storage.repair.apply(context.__storage,
return context.__storage.repair.apply(context.__storage, argument_list);
argument_list); }
} });
});
}; };
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
...@@ -12385,59 +12394,56 @@ return new Parser; ...@@ -12385,59 +12394,56 @@ return new Parser;
}; };
function extractPropertyFromFormJSON(json) { function extractPropertyFromFormJSON(json) {
return new RSVP.Queue() var form = json._embedded._view,
.push(function () { converted_json = {
var form = json._embedded._view, portal_type: json._links.type.name
converted_json = { },
portal_type: json._links.type.name form_data_json = {},
}, field,
form_data_json = {}, key,
field, prefix_length,
key, result;
prefix_length,
result;
if (json._links.hasOwnProperty('parent')) { if (json._links.hasOwnProperty('parent')) {
converted_json.parent_relative_url = converted_json.parent_relative_url =
new URI(json._links.parent.href).segment(2); new URI(json._links.parent.href).segment(2);
} }
form_data_json.form_id = { form_data_json.form_id = {
"key": [form.form_id.key], "key": [form.form_id.key],
"default": form.form_id["default"] "default": form.form_id["default"]
}; };
// XXX How to store datetime // XXX How to store datetime
for (key in form) { for (key in form) {
if (form.hasOwnProperty(key)) { if (form.hasOwnProperty(key)) {
field = form[key]; field = form[key];
prefix_length = 0; prefix_length = 0;
if (key.indexOf('my_') === 0 && field.editable) { if (key.indexOf('my_') === 0 && field.editable) {
prefix_length = 3; prefix_length = 3;
} }
if (key.indexOf('your_') === 0) { if (key.indexOf('your_') === 0) {
prefix_length = 5; prefix_length = 5;
} }
if ((prefix_length !== 0) && if ((prefix_length !== 0) &&
(allowed_field_dict.hasOwnProperty(field.type))) { (allowed_field_dict.hasOwnProperty(field.type))) {
form_data_json[key.substring(prefix_length)] = { form_data_json[key.substring(prefix_length)] = {
"default": field["default"], "default": field["default"],
"key": field.key "key": field.key
}; };
converted_json[key.substring(prefix_length)] = field["default"]; converted_json[key.substring(prefix_length)] = field["default"];
}
}
} }
}
}
result = { result = {
data: converted_json, data: converted_json,
form_data: form_data_json form_data: form_data_json
}; };
if (form.hasOwnProperty('_actions') && if (form.hasOwnProperty('_actions') &&
form._actions.hasOwnProperty('put')) { form._actions.hasOwnProperty('put')) {
result.action_href = form._actions.put.href; result.action_href = form._actions.put.href;
} }
return result; return result;
});
} }
function extractPropertyFromForm(context, id) { function extractPropertyFromForm(context, id) {
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
{ {
"name": "jio", "name": "jio",
"version": "v3.29.0", "version": "v3.30.0",
"license": "LGPLv3", "license": "LGPLv3",
"author": "Nexedi SA", "author": "Nexedi SA",
"contributors": [ "contributors": [
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment