I'm trying to understand how to use db:output() in the context of a REST function that does a bunch of stuff that updates and then wants to return a result.
I have my updating functions using db:output() to return XML elements that are log entries, which I have up to now then formatted as HTML for return by the Web app.
However, there doesn't appear to be a way to get the stuff returned by db:output before it gets returned to the ultimate caller. Have I missed something?
My REST-handling function is declared as %updating:
declare %updating %rest:path("/repo/{$repo}/{$branch}/updateLinkManagementIndexes")
Which I understand to be a requirement if the function itself calls any updating functions.
I tried e.g.:
let $result := f:myUpdatingFunction() return db:output(f:formatLogItems($result))
But that results in the "no updating functions" message on the variable assignment.
Is there a way to do what I want?
Thanks,
Eliot ---- Eliot Kimber, Owner Contrext, LLC http://contrext.com
Hi Eliot,
Two years ago, two members of our team gave a little demo on RESTXQ [1,2]. Maybe this gives you an idea how we db:output can be used in web applications.
Just recently, we added a function that allows you to access the current entries of the output cache [3]. Please note, however, that this is more like a helper function that was mainly integrated for XQUnit tests.
Best, Christian
[1] http://files.basex.org/publications/xmlprague/2013.html [2] http://files.basex.org/publications/xmlprague/2013.html [3] http://docs.basex.org/wiki/Database_Module#db:output-cache
On Sun, Jul 5, 2015 at 6:42 PM, Eliot Kimber ekimber@contrext.com wrote:
I'm trying to understand how to use db:output() in the context of a REST function that does a bunch of stuff that updates and then wants to return a result.
I have my updating functions using db:output() to return XML elements that are log entries, which I have up to now then formatted as HTML for return by the Web app.
However, there doesn't appear to be a way to get the stuff returned by db:output before it gets returned to the ultimate caller. Have I missed something?
My REST-handling function is declared as %updating:
declare %updating %rest:path("/repo/{$repo}/{$branch}/updateLinkManagementIndexes")
Which I understand to be a requirement if the function itself calls any updating functions.
I tried e.g.:
let $result := f:myUpdatingFunction() return db:output(f:formatLogItems($result))
But that results in the "no updating functions" message on the variable assignment.
Is there a way to do what I want?
Thanks,
Eliot
Eliot Kimber, Owner Contrext, LLC http://contrext.com
Christian,
Thanks for those pointers--lots of interesting stuff.
Looking at how those two apps are using db:output() and restxq:redirect it looks like the cleanest solution would be to log processing details to a document in the repo and then set up a REST function that takes the the log ID and presents it in whatever way is appropriate. Shouldn't be too hard to set up.
Cheers,
Eliot
---- Eliot Kimber, Owner Contrext, LLC http://contrext.com
On 7/5/15, 12:35 PM, "Christian Grün" christian.gruen@gmail.com wrote:
Hi Eliot,
Two years ago, two members of our team gave a little demo on RESTXQ [1,2]. Maybe this gives you an idea how we db:output can be used in web applications.
Just recently, we added a function that allows you to access the current entries of the output cache [3]. Please note, however, that this is more like a helper function that was mainly integrated for XQUnit tests.
Best, Christian
[1] http://files.basex.org/publications/xmlprague/2013.html [2] http://files.basex.org/publications/xmlprague/2013.html [3] http://docs.basex.org/wiki/Database_Module#db:output-cache
On Sun, Jul 5, 2015 at 6:42 PM, Eliot Kimber ekimber@contrext.com wrote:
I'm trying to understand how to use db:output() in the context of a REST function that does a bunch of stuff that updates and then wants to return a result.
I have my updating functions using db:output() to return XML elements that are log entries, which I have up to now then formatted as HTML for return by the Web app.
However, there doesn't appear to be a way to get the stuff returned by db:output before it gets returned to the ultimate caller. Have I missed something?
My REST-handling function is declared as %updating:
declare %updating %rest:path("/repo/{$repo}/{$branch}/updateLinkManagementIndexes")
Which I understand to be a requirement if the function itself calls any updating functions.
I tried e.g.:
let $result := f:myUpdatingFunction() return db:output(f:formatLogItems($result))
But that results in the "no updating functions" message on the variable assignment.
Is there a way to do what I want?
Thanks,
Eliot
Eliot Kimber, Owner Contrext, LLC http://contrext.com
I have successfully refactored my Web service code to use redirects in order to perform a sequence of updating functions, where the next function depends on updates made by the previous function.
The pattern is pretty simple. The first REST handler, which is the "public" API and must also be declared as %updating, sets up the parameters for the internal calls then does:
let $params := map {'param1' : 'somevalue'}
return try { db:output(web:redirect($targetURI, $params)) catch * { db:output(web:redirect($errorPageURI, $params) }
Then each of the updating functions follows the same pattern, doing whatever updates it does and then returning either a redirect to the next stage or an appropriate error response.
I still need to set up logging to a document within the repo, but that will be no problem now that I have the general pattern in place.
Cheers,
E. ---- Eliot Kimber, Owner Contrext, LLC http://contrext.com
On 7/6/15, 8:14 AM, "Eliot Kimber" <basex-talk-bounces@mailman.uni-konstanz.de on behalf of ekimber@contrext.com> wrote:
Christian,
Thanks for those pointers--lots of interesting stuff.
Looking at how those two apps are using db:output() and restxq:redirect it looks like the cleanest solution would be to log processing details to a document in the repo and then set up a REST function that takes the the log ID and presents it in whatever way is appropriate. Shouldn't be too hard to set up.
Cheers,
Eliot
Eliot Kimber, Owner Contrext, LLC http://contrext.com
On 7/5/15, 12:35 PM, "Christian Grün" christian.gruen@gmail.com wrote:
Hi Eliot,
Two years ago, two members of our team gave a little demo on RESTXQ [1,2]. Maybe this gives you an idea how we db:output can be used in web applications.
Just recently, we added a function that allows you to access the current entries of the output cache [3]. Please note, however, that this is more like a helper function that was mainly integrated for XQUnit tests.
Best, Christian
[1] http://files.basex.org/publications/xmlprague/2013.html [2] http://files.basex.org/publications/xmlprague/2013.html [3] http://docs.basex.org/wiki/Database_Module#db:output-cache
On Sun, Jul 5, 2015 at 6:42 PM, Eliot Kimber ekimber@contrext.com wrote:
I'm trying to understand how to use db:output() in the context of a REST function that does a bunch of stuff that updates and then wants to return a result.
I have my updating functions using db:output() to return XML elements that are log entries, which I have up to now then formatted as HTML for return by the Web app.
However, there doesn't appear to be a way to get the stuff returned by db:output before it gets returned to the ultimate caller. Have I missed something?
My REST-handling function is declared as %updating:
declare %updating %rest:path("/repo/{$repo}/{$branch}/updateLinkManagementIndexes")
Which I understand to be a requirement if the function itself calls any updating functions.
I tried e.g.:
let $result := f:myUpdatingFunction() return db:output(f:formatLogItems($result))
But that results in the "no updating functions" message on the variable assignment.
Is there a way to do what I want?
Thanks,
Eliot
Eliot Kimber, Owner Contrext, LLC http://contrext.com
…great!
On Sat, Aug 1, 2015 at 10:38 PM, Eliot Kimber ekimber@contrext.com wrote:
I have successfully refactored my Web service code to use redirects in order to perform a sequence of updating functions, where the next function depends on updates made by the previous function.
The pattern is pretty simple. The first REST handler, which is the "public" API and must also be declared as %updating, sets up the parameters for the internal calls then does:
let $params := map {'param1' : 'somevalue'}
return try { db:output(web:redirect($targetURI, $params)) catch * { db:output(web:redirect($errorPageURI, $params) }
Then each of the updating functions follows the same pattern, doing whatever updates it does and then returning either a redirect to the next stage or an appropriate error response.
I still need to set up logging to a document within the repo, but that will be no problem now that I have the general pattern in place.
Cheers,
E.
Eliot Kimber, Owner Contrext, LLC http://contrext.com
On 7/6/15, 8:14 AM, "Eliot Kimber" <basex-talk-bounces@mailman.uni-konstanz.de on behalf of ekimber@contrext.com> wrote:
Christian,
Thanks for those pointers--lots of interesting stuff.
Looking at how those two apps are using db:output() and restxq:redirect it looks like the cleanest solution would be to log processing details to a document in the repo and then set up a REST function that takes the the log ID and presents it in whatever way is appropriate. Shouldn't be too hard to set up.
Cheers,
Eliot
Eliot Kimber, Owner Contrext, LLC http://contrext.com
On 7/5/15, 12:35 PM, "Christian Grün" christian.gruen@gmail.com wrote:
Hi Eliot,
Two years ago, two members of our team gave a little demo on RESTXQ [1,2]. Maybe this gives you an idea how we db:output can be used in web applications.
Just recently, we added a function that allows you to access the current entries of the output cache [3]. Please note, however, that this is more like a helper function that was mainly integrated for XQUnit tests.
Best, Christian
[1] http://files.basex.org/publications/xmlprague/2013.html [2] http://files.basex.org/publications/xmlprague/2013.html [3] http://docs.basex.org/wiki/Database_Module#db:output-cache
On Sun, Jul 5, 2015 at 6:42 PM, Eliot Kimber ekimber@contrext.com wrote:
I'm trying to understand how to use db:output() in the context of a REST function that does a bunch of stuff that updates and then wants to return a result.
I have my updating functions using db:output() to return XML elements that are log entries, which I have up to now then formatted as HTML for return by the Web app.
However, there doesn't appear to be a way to get the stuff returned by db:output before it gets returned to the ultimate caller. Have I missed something?
My REST-handling function is declared as %updating:
declare %updating %rest:path("/repo/{$repo}/{$branch}/updateLinkManagementIndexes")
Which I understand to be a requirement if the function itself calls any updating functions.
I tried e.g.:
let $result := f:myUpdatingFunction() return db:output(f:formatLogItems($result))
But that results in the "no updating functions" message on the variable assignment.
Is there a way to do what I want?
Thanks,
Eliot
Eliot Kimber, Owner Contrext, LLC http://contrext.com
basex-talk@mailman.uni-konstanz.de