web/views/ajaxcontroller.py
changeset 8190 2a3c1b787688
parent 8128 0a927fe4541b
child 8401 a9efb25337da
equal deleted inserted replaced
8189:2ee0ef069fa7 8190:2a3c1b787688
     1 # copyright 2003-2011 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
     1 # copyright 2003-2012 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
     2 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
     2 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
     3 #
     3 #
     4 # This file is part of CubicWeb.
     4 # This file is part of CubicWeb.
     5 #
     5 #
     6 # CubicWeb is free software: you can redistribute it and/or modify it under the
     6 # CubicWeb is free software: you can redistribute it and/or modify it under the
    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 :ref:`cubicweb.web.views.ajaxcontroller.ajaxfunc` decorator:
    32 
    32 
    33 .. sourcecode:: python
    33 .. sourcecode:: python
    34 
    34 
    35     from cubicweb.selectors 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')]
    64 __docformat__ = "restructuredtext en"
    64 __docformat__ = "restructuredtext en"
    65 
    65 
    66 from functools import partial
    66 from functools import partial
    67 
    67 
    68 from logilab.common.date import strptime
    68 from logilab.common.date import strptime
       
    69 from logilab.common.registry import yes
    69 from logilab.common.deprecation import deprecated
    70 from logilab.common.deprecation import deprecated
    70 
    71 
    71 from cubicweb import ObjectNotFound, NoSelectableObject
    72 from cubicweb import ObjectNotFound, NoSelectableObject
    72 from cubicweb.appobject import AppObject
    73 from cubicweb.appobject import AppObject
    73 from cubicweb.selectors import yes
       
    74 from cubicweb.utils import json, json_dumps, UStringIO
    74 from cubicweb.utils import json, json_dumps, UStringIO
    75 from cubicweb.uilib import exc_message
    75 from cubicweb.uilib import exc_message
    76 from cubicweb.web import RemoteCallFailed, DirectResponse
    76 from cubicweb.web import RemoteCallFailed, DirectResponse
    77 from cubicweb.web.controller import Controller
    77 from cubicweb.web.controller import Controller
    78 from cubicweb.web.views import vid_from_rset
    78 from cubicweb.web.views import vid_from_rset