[javascript] fix #736185: add_onload / jQuery.bind() vs. jQuery.one()
This patch introduces a new 'server-response' event and
deprecates the 'ajax-loaded' event.
- 'server-response' is triggered by postAjaxLoad() (instead of
'ajax-loaded').
- 'server-response' is also triggered on document.ready().
- The add_onload() method binds the javascript code the
'server-response' event whether or not it's an ajax
request, thus removing the need of the jsoncall hackish
parameter. The binding is done with jQuery.one() instead
of jQuery.bind().
- The javascript callbacks will be passed two extra parameters :
a boolean to indicate if it's an ajax request or not, the DOM
node (result of the HTTP query). As javascript is what it is,
callbacks can safely ignore those two parameters if they don't
need them.
Backward compatibility is maintained by triggerring an 'ajax-loaded'
event when a 'server-response' is emitted.
"""hooks to handle attributes mapped to a custom storage
"""
from cubicweb.server.hook import Hook
from cubicweb.server.sources.storages import ETYPE_ATTR_STORAGE
class BFSSHook(Hook):
"""abstract class for bytes file-system storage hooks"""
__abstract__ = True
category = 'bfss'
class PreAddEntityHook(BFSSHook):
""""""
__regid__ = 'bfss_add_entity'
events = ('before_add_entity', )
def __call__(self):
etype = self.entity.__regid__
for attr in ETYPE_ATTR_STORAGE.get(etype, ()):
ETYPE_ATTR_STORAGE[etype][attr].entity_added(self.entity, attr)
class PreUpdateEntityHook(BFSSHook):
""""""
__regid__ = 'bfss_update_entity'
events = ('before_update_entity', )
def __call__(self):
etype = self.entity.__regid__
for attr in ETYPE_ATTR_STORAGE.get(etype, ()):
ETYPE_ATTR_STORAGE[etype][attr].entity_updated(self.entity, attr)
class PreDeleteEntityHook(BFSSHook):
""""""
__regid__ = 'bfss_delete_entity'
events = ('before_delete_entity', )
def __call__(self):
etype = self.entity.__regid__
for attr in ETYPE_ATTR_STORAGE.get(etype, ()):
ETYPE_ATTR_STORAGE[etype][attr].entity_deleted(self.entity, attr)