write permission and create permission
Thursday, 10 March 2016 · 2 messages
CS
C. M. Sperberg-McQueen10 Mar 2016 01:55 #
In a function intended to be called from the REST interface, I have code whose essential expression is
db:add('my-db', doc('http://example.com/docs/foo.xml'), 'foo.xml')I was surprised at first that this requires CREATE permission rather than just WRITE permission, but eventually realized that the CREATE is needed not by the
db:add() function but by the doc() function.
It's not important for my current needs (I can run the query under a userid with CREATE permissions), but in the interests of knowledge I wonder: Is there a way to load a document from the Web that does not require CREATE permission?
(And before anyone asks: yes, I could PUT the new document, if I could figure out how to do that from PHP, and if performing the necessary sanity checks were as easy in PHP as it is in XQuery. But neither of those is true at the moment; the first may change, but the second is not ever going to change: given the choice, I'd rather do any work possible in XQuery rather than PHP.)
Thanks!
Michael Sperberg-McQueen--
****************************************************************
* C. M. Sperberg-McQueen, Black Mesa Technologies LLC
* http://www.blackmesatech.com
* http://cmsmcq.com/mib
* http://balisage.net
****************************************************************
CG
Christian Grün10 Mar 2016 10:59 #
Dear Michael,
Quoted text · C. M. Sperberg-McQueen · 2 lines
> the CREATE is > needed not by the db:add() function but by the doc() function.
As the doc() function can be used to retrieve very large external resources, which can eventually trigger out-of-memory errors and other surprises, the function was limited to users with create permissions. This is the reason why data to be stored needs to be added via an input stream or bound to an external variable.
Hope this helps,
Christian
Quoted text · C. M. Sperberg-McQueen · 29 lines
> > It's not important for my current needs (I can run the query under a userid > with CREATE permissions), but in the interests of knowledge I wonder: > Is there a way to load a document from the Web that does not require > CREATE permission? > > (And before anyone asks: yes, I could PUT the new document, if I > could figure out how to do that from PHP, and if performing the > necessary sanity checks were as easy in PHP as it is in XQuery. But > neither of those is true at the moment; the first may change, but the > second is not ever going to change: given the choice, I'd rather do > any work possible in XQuery rather than PHP.) > > > Thanks! > > Michael Sperberg-McQueen > > -- > **************************************************************** > * C. M. Sperberg-McQueen, Black Mesa Technologies LLC > * http://www.blackmesatech.com > * http://cmsmcq.com/mib > * http://balisage.net > **************************************************************** > > > >
Written for BaseX 8.4. BaseX may have changed since: please check the current documentation.
⚡Generated with XQuery