web/views/ajaxcontroller.py
changeset 8496 e4d71fc0b701
parent 8437 c9ab72f0645d
child 8535 268b6349baf3
equal deleted inserted replaced
8495:0bc63e46bdb5 8496:e4d71fc0b701
    26 
    26 
    27 ``ajax-funcs`` registry hosts exposed remote functions, that is
    27 ``ajax-funcs`` registry hosts exposed remote functions, that is
    28 functions that can be called from the javascript world.
    28 functions that can be called from the javascript world.
    29 
    29 
    30 To register a new remote function, either decorate your function
    30 To register a new remote function, either decorate your function
    31 with the :ref:`cubicweb.web.views.ajaxcontroller.ajaxfunc` decorator:
    31 with the :func:`~cubicweb.web.views.ajaxcontroller.ajaxfunc` decorator:
    32 
    32 
    33 .. sourcecode:: python
    33 .. sourcecode:: python
    34 
    34 
    35     from cubicweb.predicates import mactch_user_groups
    35     from cubicweb.predicates import mactch_user_groups
    36     from cubicweb.web.views.ajaxcontroller import ajaxfunc
    36     from cubicweb.web.views.ajaxcontroller import ajaxfunc
    37 
    37 
    38     @ajaxfunc(output_type='json', selector=match_user_groups('managers'))
    38     @ajaxfunc(output_type='json', selector=match_user_groups('managers'))
    39     def list_users(self):
    39     def list_users(self):
    40         return [u for (u,) in self._cw.execute('Any L WHERE U login L')]
    40         return [u for (u,) in self._cw.execute('Any L WHERE U login L')]
    41 
    41 
    42 or inherit from :class:`cubicwbe.web.views.ajaxcontroller.AjaxFunction` and
    42 or inherit from :class:`~cubicweb.web.views.ajaxcontroller.AjaxFunction` and
    43 implement the ``__call__`` method:
    43 implement the ``__call__`` method:
    44 
    44 
    45 .. sourcecode:: python
    45 .. sourcecode:: python
    46 
    46 
    47     from cubicweb.web.views.ajaxcontroller import AjaxFunction
    47     from cubicweb.web.views.ajaxcontroller import AjaxFunction