[repoapi] fold ClientConnection into Connection
Connection replaces ClientConnection everywhere.
Some notes:
* testlib: .client_cnx and .repo_cnx become aliases of .cnx (we might
not want to tell people to update their tests again for just no real
benefit, so we'll live with these aliases for a while)
* entity.as_rset must not be cached because we risk caching result
sets having a Connection object as .req (helps unittest_breadcrumbs)
* entity._cw_dont_cache_attributes loses its repo/request special
paths and only keeps its storage/bfss user (this helps
unittest_wfobjs)
* moreover, entity.cw_instantiate and .cw_set stop overriding the
attributes cache *after* the before_*_entity hooks have run, because
there is no need to (it is now actually harmful to do it and
unittest_hooks.test_html_tidy* tests remain green because of this)
* rset._build_entity sticks its .req onto the entity just fetched from
the cache, because otherwise it might carry a _cw that is a
Connection object where a Request is expected (helps
unittest_views_actions)
* we get overall better cache usages (entity caches were split over
Request + ClientConnection and Connection), hence the changes
unittest_entity and unittest_wfobjs
* void the ecache when providing the cnx to a request object
Having the entity cache pre-filled when we bind it to the request
object hurts because these entities are bound to Connection objects,
that lack e.g. `.form` or `.add_js` and crash the views subsystem.
Thus, the unittest_testlib.test_error_raised test will are kept
green.
Closes #3837233
/**
* Functions for ajax boxes.
*
* :organization: Logilab
* :copyright: 2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
* :contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr
*
*/
function ajaxBoxValidateSelectorInput(boxid, eid, separator, fname, msg) {
var holderid = cw.utils.domid(boxid) + eid + 'Holder';
var value = $('#' + holderid + 'Input').val();
if (separator) {
value = $.map(value.split(separator), jQuery.trim);
}
var d = loadRemote(AJAX_BASE_URL, ajaxFuncArgs(fname, null, eid, value));
d.addCallback(function() {
$('#' + holderid).empty();
var formparams = ajaxFuncArgs('render', null, 'ctxcomponents', boxid, eid);
$('#' + cw.utils.domid(boxid) + eid).loadxhtml(AJAX_BASE_URL, formparams, null, 'swap');
if (msg) {
document.location.hash = '#header';
updateMessage(msg);
}
});
}
function ajaxBoxRemoveLinkedEntity(boxid, eid, relatedeid, delfname, msg) {
var d = loadRemote(AJAX_BASE_URL, ajaxFuncArgs(delfname, null, eid, relatedeid));
d.addCallback(function() {
var formparams = ajaxFuncArgs('render', null, 'ctxcomponents', boxid, eid);
$('#' + cw.utils.domid(boxid) + eid).loadxhtml(AJAX_BASE_URL, formparams, null, 'swap');
if (msg) {
document.location.hash = '#header';
updateMessage(msg);
}
});
}
/**
* .. function:: ajaxBoxShowSelector(boxid, eid, unrelfname,
* addfname, msg,
* oklabel, cancellabel,
* separator=None)
*
* Display an ajax selector within a box of regid `boxid`, for entity with eid
* `eid`.
*
* Other parameters are:
*
* * `addfname`, name of the json controller method to call to add a relation
*
* * `msg`, message to display to the user when a relation has been added
*
* * `oklabel`/`cancellabel`, OK/cancel buttons label
*
* * `separator`, items separator if the field is multi-valued (will be
* considered mono-valued when not specified)
*/
function ajaxBoxShowSelector(boxid, eid,
unrelfname,
addfname, msg,
oklabel, cancellabel,
separator) {
var holderid = cw.utils.domid(boxid) + eid + 'Holder';
var holder = $('#' + holderid);
if (holder.children().length) {
holder.empty();
}
else {
var inputid = holderid + 'Input';
var deferred = loadRemote(AJAX_BASE_URL, ajaxFuncArgs(unrelfname, null, eid));
deferred.addCallback(function (unrelated) {
var input = INPUT({'type': 'text', 'id': inputid, 'size': 20});
holder.append(input).show();
var $input = $(input);
$input.keypress(function (evt) {
if (evt.keyCode == $.ui.keyCode.ENTER) {
ajaxBoxValidateSelectorInput(boxid, eid, separator, addfname, msg);
}
});
$input.cwautocomplete(unrelated, {multiple: Boolean(separator)});
var buttons = DIV({'class' : "sgformbuttons"},
A({href : "javascript: $.noop();",
onclick : cw.utils.strFuncCall('ajaxBoxValidateSelectorInput',
boxid, eid, separator, addfname, msg)},
oklabel),
' / ',
A({'href' : "javascript: $.noop();",
'onclick' : '$("#' + holderid + '").empty()'},
cancellabel));
holder.append(buttons);
$input.focus();
});
}
}