web/views/basecontrollers.py
changeset 5940 0e3ae19b181a
parent 5869 8a129b3a5aff
child 6107 05061eda1fa7
equal deleted inserted replaced
5939:a33402c1aa79 5940:0e3ae19b181a
    24 
    24 
    25 from logilab.common.date import strptime
    25 from logilab.common.date import strptime
    26 
    26 
    27 from cubicweb import (NoSelectableObject, ObjectNotFound, ValidationError,
    27 from cubicweb import (NoSelectableObject, ObjectNotFound, ValidationError,
    28                       AuthenticationError, typed_eid)
    28                       AuthenticationError, typed_eid)
    29 from cubicweb.utils import CubicWebJsonEncoder
    29 from cubicweb.utils import json, json_dumps
    30 from cubicweb.selectors import authenticated_user, anonymous_user, match_form_params
    30 from cubicweb.selectors import authenticated_user, anonymous_user, match_form_params
    31 from cubicweb.mail import format_mail
    31 from cubicweb.mail import format_mail
    32 from cubicweb.web import (Redirect, RemoteCallFailed, DirectResponse,
    32 from cubicweb.web import Redirect, RemoteCallFailed, DirectResponse
    33                           json, json_dumps)
       
    34 from cubicweb.web.controller import Controller
    33 from cubicweb.web.controller import Controller
    35 from cubicweb.web.views import vid_from_rset, formrenderers
    34 from cubicweb.web.views import vid_from_rset, formrenderers
    36 
    35 
    37 try:
    36 try:
    38     from cubicweb.web.facet import (FilterRQLBuilder, get_facet,
    37     from cubicweb.web.facet import (FilterRQLBuilder, get_facet,
    40     HAS_SEARCH_RESTRICTION = True
    39     HAS_SEARCH_RESTRICTION = True
    41 except ImportError: # gae
    40 except ImportError: # gae
    42     HAS_SEARCH_RESTRICTION = False
    41     HAS_SEARCH_RESTRICTION = False
    43 
    42 
    44 def jsonize(func):
    43 def jsonize(func):
    45     """decorator to sets correct content_type and calls `json.dumps` on
    44     """decorator to sets correct content_type and calls `json_dumps` on
    46     results
    45     results
    47     """
    46     """
    48     def wrapper(self, *args, **kwargs):
    47     def wrapper(self, *args, **kwargs):
    49         self._cw.set_content_type('application/json')
    48         self._cw.set_content_type('application/json')
    50         return json_dumps(func(self, *args, **kwargs))
    49         return json_dumps(func(self, *args, **kwargs))