cubicweb #4084908 bad interaction between read security and optional join in rql query [open]

Occurs in SNCF client project (changeset c2ed1a8e7edf for instance). Simplest RQL is probably: Any S,C WHERE C? etude S. Without the ? everything is fine.

Traceback:

2014-07-03 08:17:16 - (cubicweb.web) ERROR: an exception occurred while calling js_view([]): 'NoneType' object has no attribute 'scope'
Traceback (most recent call last):
  File "/home/logidemo/PN_SNCF/grshell/cubicweb/web/views/ajaxcontroller.py", line 143, in publish
    result = func(*args)
  File "/home/logidemo/PN_SNCF/grshell/cubicweb/web/views/ajaxcontroller.py", line 284, in __call__
    return self.serialize(implementation(self, *args, **kwargs))
  File "/home/logidemo/PN_SNCF/grshell/cubicweb/web/views/ajaxcontroller.py", line 376, in view
    return self._call_view(viewobj, paginate=req.form.pop('paginate', False))
  File "/home/logidemo/PN_SNCF/grshell/cubicweb/web/views/ajaxcontroller.py", line 246, in _call_view
    view.render(**kwargs)
  File "/home/logidemo/PN_SNCF/grshell/cubicweb/view.py", line 137, in render
    view_func(**context)
  File "/home/logidemo/PN_SNCF/grshell/cubes/pn_sncf/views/startup.py", line 36, in call
    rset = self._cw.execute('Any S,SC,COUNT(C),P GROUPBY P,S,SC WHERE'
  File "/home/logidemo/PN_SNCF/grshell/cubicweb/dbapi.py", line 502, in execute
    build_descr=build_descr, **self._txid())
  File "/home/logidemo/PN_SNCF/grshell/cubicweb/server/repository.py", line 793, in execute
    build_descr)
  File "/home/logidemo/PN_SNCF/grshell/cubicweb/server/querier.py", line 639, in execute
    self._planner.build_plan(plan)
  File "/home/logidemo/PN_SNCF/grshell/cubicweb/server/ssplanner.py", line 138, in build_plan
    for step in build_plan(plan, plan.rqlst):
  File "/home/logidemo/PN_SNCF/grshell/cubicweb/server/ssplanner.py", line 147, in build_select_plan
    plan.preprocess(rqlst)
  File "/home/logidemo/PN_SNCF/grshell/cubicweb/server/querier.py", line 241, in preprocess
    noinvariant = self._insert_security(union)
  File "/home/logidemo/PN_SNCF/grshell/cubicweb/server/querier.py", line 261, in _insert_security
    select, self.args, localchecks, restricted, noinvariant)
  File "/home/logidemo/PN_SNCF/grshell/cubicweb/rqlrewrite.py", line 330, in insert_local_checks
    self.rewrite(myrqlst, lcheckdef, kwargs)
  File "/home/logidemo/PN_SNCF/grshell/cubicweb/rqlrewrite.py", line 355, in rewrite
    self.insert_snippets(snippets)
  File "/home/logidemo/PN_SNCF/grshell/cubicweb/rqlrewrite.py", line 383, in insert_snippets
    self.insert_varmap_snippets(varmap, rqlexprs, varexistsmap)
  File "/home/logidemo/PN_SNCF/grshell/cubicweb/rqlrewrite.py", line 427, in insert_varmap_snippets
    new = self.insert_snippet(varmap, rqlexpr.snippet_rqlst, previous)
  File "/home/logidemo/PN_SNCF/grshell/cubicweb/rqlrewrite.py", line 445, in insert_snippet
    new = snippetrqlst.where.accept(self)
  File "/home/logidemo/PN_SNCF/grshell/rql/utils.py", line 166, in accept
    return visit_method(self, *args, **kwargs)
  File "/home/logidemo/PN_SNCF/grshell/cubicweb/rqlrewrite.py", line 777, in visit_or
    return self._visit_binary(node, n.Or)
  File "/home/logidemo/PN_SNCF/grshell/cubicweb/rqlrewrite.py", line 755, in _visit_binary
    new = c.accept(self)
  File "/home/logidemo/PN_SNCF/grshell/rql/utils.py", line 166, in accept
    return visit_method(self, *args, **kwargs)
  File "/home/logidemo/PN_SNCF/grshell/cubicweb/rqlrewrite.py", line 783, in visit_exists
    return self._visit_unary(node, n.Exists)
  File "/home/logidemo/PN_SNCF/grshell/cubicweb/rqlrewrite.py", line 766, in _visit_unary
    newc = node.children[0].accept(self)
  File "/home/logidemo/PN_SNCF/grshell/rql/utils.py", line 166, in accept
    return visit_method(self, *args, **kwargs)
  File "/home/logidemo/PN_SNCF/grshell/cubicweb/rqlrewrite.py", line 774, in visit_and
    return self._visit_binary(node, n.And)
  File "/home/logidemo/PN_SNCF/grshell/cubicweb/rqlrewrite.py", line 755, in _visit_binary
    new = c.accept(self)
  File "/home/logidemo/PN_SNCF/grshell/rql/utils.py", line 166, in accept
    return visit_method(self, *args, **kwargs)
  File "/home/logidemo/PN_SNCF/grshell/cubicweb/rqlrewrite.py", line 816, in visit_relation
    orel = self._may_be_shared_with(node, 'object')
  File "/home/logidemo/PN_SNCF/grshell/cubicweb/rqlrewrite.py", line 713, in _may_be_shared_with
    orel = _compatible_relation(orels, stmt, sniprel)
  File "/home/logidemo/PN_SNCF/grshell/cubicweb/rqlrewrite.py", line 188, in _compatible_relation
    if rel.scope is not stmt:
  File "/home/logidemo/PN_SNCF/grshell/rql/base.py", line 61, in scope
    return self.parent.scope
  File "/home/logidemo/PN_SNCF/grshell/rql/base.py", line 61, in scope
    return self.parent.scope
  File "/home/logidemo/PN_SNCF/grshell/rql/base.py", line 61, in scope
    return self.parent.scope
  File "/home/logidemo/PN_SNCF/grshell/rql/base.py", line 61, in scope
    return self.parent.scope
AttributeError: 'NoneType' object has no attribute 'scope'
prioritynormal
typebug
done in<not specified>
closed by<not specified>