web/__init__.py
changeset 11057 0b59724cb3f2
parent 11052 058bb3dc685f
child 11058 23eb30449fe5
equal deleted inserted replaced
11052:058bb3dc685f 11057:0b59724cb3f2
     1 # copyright 2003-2012 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
       
     2 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
       
     3 #
       
     4 # This file is part of CubicWeb.
       
     5 #
       
     6 # CubicWeb is free software: you can redistribute it and/or modify it under the
       
     7 # terms of the GNU Lesser General Public License as published by the Free
       
     8 # Software Foundation, either version 2.1 of the License, or (at your option)
       
     9 # any later version.
       
    10 #
       
    11 # CubicWeb is distributed in the hope that it will be useful, but WITHOUT
       
    12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
       
    13 # FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
       
    14 # details.
       
    15 #
       
    16 # You should have received a copy of the GNU Lesser General Public License along
       
    17 # with CubicWeb.  If not, see <http://www.gnu.org/licenses/>.
       
    18 """CubicWeb web client core. You'll need a apache-modpython or twisted
       
    19 publisher to get a full CubicWeb web application
       
    20 """
       
    21 
       
    22 __docformat__ = "restructuredtext en"
       
    23 from cubicweb import _
       
    24 
       
    25 from six.moves.urllib.parse import quote as urlquote
       
    26 from logilab.common.deprecation import deprecated
       
    27 
       
    28 from cubicweb.web._exceptions import *
       
    29 from cubicweb.utils import json_dumps
       
    30 from cubicweb.uilib import eid_param
       
    31 
       
    32 assert json_dumps is not None, 'no json module installed'
       
    33 
       
    34 INTERNAL_FIELD_VALUE = '__cubicweb_internal_field__'
       
    35 
       
    36 
       
    37 class stdmsgs(object):
       
    38     """standard ui message (in a class for bw compat)"""
       
    39     BUTTON_OK     = (_('button_ok'), 'OK_ICON')
       
    40     BUTTON_APPLY  = (_('button_apply'), 'APPLY_ICON')
       
    41     BUTTON_CANCEL = (_('button_cancel'), 'CANCEL_ICON')
       
    42     BUTTON_DELETE = (_('button_delete'), 'TRASH_ICON')
       
    43     YES = (_('yes'), None)
       
    44     NO  = (_('no'), None)
       
    45 
       
    46 
       
    47 from logging import getLogger
       
    48 LOGGER = getLogger('cubicweb.web')
       
    49 
       
    50 # XXX deprecated
       
    51 FACETTES = set()
       
    52 
       
    53 
       
    54 def jsonize(function):
       
    55     def newfunc(*args, **kwargs):
       
    56         value = function(*args, **kwargs)
       
    57         try:
       
    58             return json_dumps(value)
       
    59         except TypeError:
       
    60             return json_dumps(repr(value))
       
    61     return newfunc