[Cubicweb] user callbacks, rqlcontroller, ajaxfunc, and schema permissions

Julien Cristau julien.cristau at logilab.fr
Tue Mar 11 14:25:01 CET 2014


Hi all,

as part of making it easier to run multiple instances of a cubicweb
application, we're trying to sanitize our use of server-side state.

The user_callback mechanism in cubicweb stores a function in the session
data, that can then be invoked in a later web request.  That mechanism
is, shall we say, less than ideal in the context of session data being
shared across processes, so that "later web request" could be served by
a different backend.

I can think of a few ways to deal with this:
1. for each of the call sites, instead of storing the callback in session
   data, store the necessary state (basically the current callback's
   arguments), and write a dedicated ajaxfunc that retrieves this state
   from session data and then uses it
2. same as above, except pass the state back and forth as part of the
   generated link and get it back as form data

As one specific example, EditRelationMixin
(http://hg.logilab.org/master/cubicweb/file/48f0ff3e2a32/web/component.py#l506)
uses user_rql_callback to add/delete a relation.  The 'add a relation'
functionality is e.g. used by AddRelationView
(http://hg.logilab.org/master/cubicweb/file/48f0ff3e2a32/web/views/ajaxedit.py#l27)
which lets the user choose pretty much any relation they want to add
through url params.
Trying to replace user_rql_callback in this case (using approach 2.
above) led me to https://www.cubicweb.org/revision/3624373; it has the
downside over the current approach that it potentially opens up things the
developer didn't want to allow (which I would argue would be a bug in
the application's permissions setting, but...).  It is also kind of a
less generic version of what's already present in the rqlcontroller
cube.

So my questions would be: do you think it's ok to rely on the app schema
to define what should and shouldn't be allowed in these controllers?  Or
should a replacement for user_callback aim to reimplement exactly the
current functionality?  If we do rely on schema permissions, I think it
would make sense to merge rqlcontroller in to cubicweb core.

Cheers,
Julien
-- 
Julien Cristau          <julien.cristau at logilab.fr>
Logilab		        http://www.logilab.fr/
Informatique scientifique & gestion de connaissances



More information about the Cubicweb mailing list