Projet

Général

Profil

Bug #12701

utilisation d'un appel webservice dans un champ commentaire, crash dans la prévisu

Ajouté par Frédéric Péters il y a presque 8 ans. Mis à jour il y a plus de 7 ans.

Statut:
Fermé
Priorité:
Normal
Assigné à:
Version cible:
Début:
22 juillet 2016
Echéance:
% réalisé:

0%

Temps estimé:
Patch proposed:
Oui
Planning:

Description

Exception:
  type = '<type 'exceptions.ValueError'>', value = 'No JSON object could be decoded'

Stack trace (most recent call first):
  File "/usr/lib/python2.7/json/decoder.py", line 382, in raw_decode
   380             obj, end = self.scan_once(s, idx)
   381         except StopIteration:
>  382             raise ValueError("No JSON object could be decoded")
   383         return obj, end

  locals: 
     s = 'page not found'
     self = <json.decoder.JSONDecoder object at 0x7facb37faa90>
     idx = 0

  File "/usr/lib/python2.7/json/decoder.py", line 364, in decode
   362 
   363         """ 
>  364         obj, end = self.raw_decode(s, idx=_w(s, 0).end())
   365         end = _w(s, end).end()
   366         if end != len(s):

  locals: 
     _w = <built-in method match of _sre.SRE_Pattern object at 0x7facb37e1490>
     s = 'page not found'
     self = <json.decoder.JSONDecoder object at 0x7facb37faa90>

  File "/usr/lib/python2.7/json/__init__.py", line 339, in loads
   337             parse_int is None and parse_float is None and
   338             parse_constant is None and object_pairs_hook is None and not kw):
>  339         return _default_decoder.decode(s)
   340     if cls is None:
   341         cls = JSONDecoder

  locals: 
     parse_int = None
     parse_float = None
     object_hook = None
     encoding = None
     parse_constant = None
     s = 'page not found'
     kw = {}
     object_pairs_hook = None
     cls = None

  File "/home/fred/src/eo/wcs/wcs/qommon/misc.py", line 461, in json_loads
   459 def json_loads(value, charset=None):
   460     charset = (get_publisher() and get_publisher().site_charset) or 'utf-8'
>  461     return json_encode_helper(json.loads(value), charset)
   462 
   463 def can_decorate_as_pdf():

  locals: 
     charset = 'utf-8'
     value = 'page not found'

  File "/home/fred/src/eo/wcs/wcs/wscalls.py", line 194, in call
   192     def call(self):
   193         (response, status, data) = call_webservice(**self.request)
>  194         return json_loads(data)
   195         raise AttributeError()
   196 

  locals: 
     status = 404
     self = <NamedWsCall 'xxx' id:xxx>
     data = 'page not found'
     response = <utilities.FakeResponse object at 0x7faca4e4db90>

  File "/home/fred/src/eo/wcs/wcs/wscalls.py", line 199, in __getattr__
   197 class WsCallsSubstitutionProxy(object):
   198     def __getattr__(self, attr):
>  199         return NamedWsCall.get(attr).call()
   200 
   201 

  locals: 
     self = <wcs.wscalls.WsCallsSubstitutionProxy object at 0x7faca4e59390>
     attr = 'xxx'

  File "/home/fred/src/eo/wcs/wcs/qommon/ezt.py", line 644, in _get_value
   642           ob = ob[int(attr)]
   643         except (ValueError, TypeError):
>  644           raise UnknownReference(refname)
   645 
   646   # make sure we return a string instead of some various Python types

  locals: 
     attr = 'xxx'
     ctx = <wcs.qommon.ezt._context instance at 0x7faca4f3a2d8>
     refname = 'webservice.xxx.foobar'
     rest = ['xxx', 'foobar']
     ob = <wcs.wscalls.WsCallsSubstitutionProxy object at 0x7faca4e59390>
     start = 'webservice'
     .0 = ('webservice.xxx.foobar', 'webservice', ['xxx', 'foobar'])

  File "/home/fred/src/eo/wcs/wcs/qommon/ezt.py", line 669, in _write_value
   667     value = '[' + ' '.join([v[0] for v in valrefs]) + ']'
   668     fp.write(format(value))
>  669     return
   670   args = map(lambda valref, ctx=ctx: _get_value_fallback(valref, ctx), valrefs[1:])
   671 

  locals: 
     fp = <cStringIO.StringO object at 0x7faca5679c38>
     valrefs = [('webservice.xxx.foobar', 'webservice', ['xxx', 'foobar'])]
     ctx = <wcs.qommon.ezt._context instance at 0x7faca4f3a2d8>
     format = <function escape at 0x7facb434ea28>

  File "/home/fred/src/eo/wcs/wcs/qommon/ezt.py", line 472, in _cmd_print_html
   470 
   471   def _cmd_print_html(self, valref, fp, ctx):
>  472     _write_value(valref, fp, ctx, cgi.escape)
   473 
   474   def _cmd_print_xml(self, valref, fp, ctx):

  locals: 
     fp = <cStringIO.StringO object at 0x7faca5679c38>
     self = <wcs.qommon.ezt.Template instance at 0x7faca4e5c7a0>
     ctx = <wcs.qommon.ezt._context instance at 0x7faca4f3a2d8>
     valref = [('webservice.xxx.foobar', 'webservice', ['xxx', 'foobar'])]

  File "/home/fred/src/eo/wcs/wcs/qommon/ezt.py", line 466, in _execute
   464         fp.write(step)
   465       else:
>  466         step[0](step[1], fp, ctx)
   467 
   468   def _cmd_print(self, valref, fp, ctx):

  locals: 
     fp = <cStringIO.StringO object at 0x7faca5679c38>
     step = (<bound method Template._cmd_print_html of <wcs.qommon.ezt.Template instance at 0x7faca4e5c7a0>>, [('webservice.xxx.foobar', 'webservice', ['xxx', 'foobar'])])
     program = ['x ', (<bound method Template._cmd_print_html of <wcs.qommon.ezt.Template instance at 0x7faca4e5c7a0>>, [('webservice.xxx.foobar', 'webservice', ['xxx', 'foobar'])]), ' x']
     ctx = <wcs.qommon.ezt._context instance at 0x7faca4f3a2d8>
     self = <wcs.qommon.ezt.Template instance at 0x7faca4e5c7a0>

  File "/home/fred/src/eo/wcs/wcs/qommon/ezt.py", line 326, in generate
   324     ctx.for_index = { }
   325     ctx.defines = { }
>  326     self._execute(self.program, fp, ctx)
   327 
   328   def _parse(self, reader, for_names=None, file_args=(), base_printer=None):

  locals: 
     fp = <cStringIO.StringO object at 0x7faca5679c38>
     _data_ob = <class wcs.qommon.ezt._data_ob at 0x7faca55107a0>
     self = <wcs.qommon.ezt.Template instance at 0x7faca4e5c7a0>
     ctx = <wcs.qommon.ezt._context instance at 0x7faca4f3a2d8>
     data = <wcs.qommon.ezt._data_ob instance at 0x7faca4f3a3b0>

  File "/home/fred/src/eo/wcs/wcs/workflows.py", line 2067, in template_on_formdata
  2065 
  2066     fd = StringIO()
> 2067     processor.generate(fd, ctx)
  2068 
  2069     return fd.getvalue()

  locals: 
     process = None
     formdata = None
     ctx = {'session_user_email': None, 'data_source': <wcs.data_sources.DataSourcesSubstitutionProxy object at 0x7faca4e59310>, 'site_name': None, 'webservice': <wcs.wscalls.WsCallsSubstitutionProxy object at 0x7faca4e59390>, 'session_user_admin_access': True, 'site_lang': 'en', 'session_user_backoffice_access': True, 'session_user': <SqlUser 'admin' id:1>, 'site_url': 'http://example.net', 'site_url_backoffice': 'http://example.net/backoffice', 'is_in_backoffice': True, 'site_theme': 'default', 'session_user_display_name': 'admin', 'now': '2016-07-22 10:29', 'today': '2016-07-22'}
     base_format = 'html'
     template = 'x [webservice.xxx.foobar] x'
     fd = <cStringIO.StringO object at 0x7faca5679c38>
     processor = <wcs.qommon.ezt.Template instance at 0x7faca4e5c7a0>

  File "/home/fred/src/eo/wcs/wcs/workflows.py", line 2052, in template_on_html_string
  2050 def template_on_html_string(template, process=None):
  2051     return template_on_formdata(None, template, process=process,
> 2052             base_format=ezt.FORMAT_HTML)
  2053 
  2054 

  locals: 
     process = None
     template = 'x [webservice.xxx.foobar] x'

  File "/home/fred/src/eo/wcs/wcs/fields.py", line 506, in add_to_form
   504 
   505         import wcs.workflows
>  506         label = wcs.workflows.template_on_html_string(label)
   507 
   508         if '<p' in label:

  locals: 
     extra_css_class = ''
     wcs = <module 'wcs' from '/home/fred/src/eo/wcs/wcs/__init__.pyc'>
     form = <qommon.form.Form object at 0x7faca4e59210>
     self = <wcs.fields.CommentField object at 0x7faca553aa90>
     value = None
     label = 'x [webservice.xxx.foobar] x'

  File "/home/fred/src/eo/wcs/wcs/admin/forms.py", line 770, in get_preview
   768             field.id = i
   769             if hasattr(field, str('add_to_form')):
>  770                 field.add_to_form(form)
   771             else:
   772                 if field.key == 'page':

  locals: 
     i = 0
     field = <wcs.fields.CommentField object at 0x7faca553aa90>
     self = <wcs.admin.forms.FormDefPage object at 0x7faca5689a10>
     on_page = 0
     form = <qommon.form.Form object at 0x7faca4e59210>

  File "/home/fred/src/eo/wcs/wcs/admin/forms.py", line 507, in _q_index
   505         r += htmltext('<h3 class="clear">%s <span class="change">(<a href="fields/">%s</a>)</span></h3>') % (
   506                         _('Fields'), _('edit'))
>  507         r += self.get_preview()
   508         r += htmltext('</div>')
   509         return r.getvalue()

  locals: 
     online_status = 'Active'
     self = <wcs.admin.forms.FormDefPage object at 0x7faca5689a10>
     add_option_line = <function add_option_line at 0x7faca5edecf8>
     role_id = None
     r = <TemplateIO object at 0x7faca5f2df50>
     wf_role_id = '_receiver'
     wf_role_label = 'Recipient'
     warning_class = 'recent'
     role_label = '-'

Fichiers

Révisions associées

Révision 52ffec6d (diff)
Ajouté par Frédéric Péters il y a presque 8 ans

wscalls: don't crash ezt substitution on errors in webservice call (#12701)

Historique

#1

Mis à jour par Frédéric Péters il y a presque 8 ans

#2

Mis à jour par Benjamin Dauvergne il y a presque 8 ans

Ça m'embête un peu de cacher le ValueError de json.loads sans en conserver ni message, ni rien et ceci pour tous les appelants à NameWsCall; on pourrait plutôt déplacer ce try/catch dans WsCallsSubstitutionProxy.__getattr__ pour obtenir le même effet du point de vue de ezt, non ?

#4

Mis à jour par Benjamin Dauvergne il y a presque 8 ans

Ack.

#5

Mis à jour par Frédéric Péters il y a presque 8 ans

  • Statut changé de En cours à Résolu (à déployer)
commit 52ffec6dd6757363c56898e9a6a0bd9d276427ac
Author: Frédéric Péters <fpeters@entrouvert.com>
Date:   Fri Jul 22 10:32:08 2016 +0200

    wscalls: don't crash ezt substitution on errors in webservice call (#12701)
#6

Mis à jour par Frédéric Péters il y a plus de 7 ans

  • Version cible mis à v1.54
#7

Mis à jour par Frédéric Péters il y a plus de 7 ans

  • Statut changé de Résolu (à déployer) à Fermé

Formats disponibles : Atom PDF