From 13557a17f1c3d2f4c3fe0fdf7c1f91d799f3701e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Henrik=20tom=20W=C3=B6rden?= <henrik@trineo.org>
Date: Sat, 18 Dec 2021 15:41:49 +0100
Subject: [PATCH] DOC: add doc on serverside

---
 src/doc/tutorials/index.rst      |  1 +
 src/doc/tutorials/serverside.rst | 53 ++++++++++++++++++++++++++++++++
 2 files changed, 54 insertions(+)
 create mode 100644 src/doc/tutorials/serverside.rst

diff --git a/src/doc/tutorials/index.rst b/src/doc/tutorials/index.rst
index 79068e92..0b08d0b4 100644
--- a/src/doc/tutorials/index.rst
+++ b/src/doc/tutorials/index.rst
@@ -16,4 +16,5 @@ advanced usage of the Python client.
    errors
    data-model-interface
    complex_data_models
+   serverside
       
diff --git a/src/doc/tutorials/serverside.rst b/src/doc/tutorials/serverside.rst
new file mode 100644
index 00000000..8c1dbc35
--- /dev/null
+++ b/src/doc/tutorials/serverside.rst
@@ -0,0 +1,53 @@
+
+Server Side Scripting
+=====================
+Some regular needed scripts, e.g. for computing a standardized analysis, might
+be placed by the administrator on the same machine as the CaosDB server such
+that they can be executed there, on the server side.
+
+The execution of those scripts can also be started using the Python client.
+
+Call a Script
+~~~~~~~~~~~~~
+
+Of course, you need to have access to the server and sufficient permissions to
+run the script that you want to run. Execution is then fairly simple:
+
+.. code:: python
+
+    from caosdb.utils.server_side_scripting import run_server_side_script
+    response = run_server_side_script('scriptname.py')
+    print(response.stderr,response.stdout)
+
+
+This triggers the execution of the script ``scriptname.py``. The output of the
+script (``stderr`` and ``stdout``) is returned within an response object.
+
+
+If the script requires additional arguments, those can be provided after the 
+scriptname. 
+
+Note, that by default the script runs with your account. It has your
+permissions and changes are logged as if they were done by you directly.
+
+
+Testing it
+~~~~~~~~~~
+
+You can try this out using for example the ``diagnositics.py`` script (it is
+also available on https://demo.indiscale.com). The script returns some
+information in JSON format. You can do for example the following
+
+.. code:: python
+
+    import json
+    from caosdb.utils.server_side_scripting import run_server_side_script
+    response = run_server_side_script('administration/diagnostics.py')
+    print(json.loads(response.stdout))
+    print(response.stderr)
+
+
+Further Information
+~~~~~~~~~~~~~~~~~~~
+
+Additionally, you might have a look at https://docs.indiscale.com/caosdb-server/specification/Server-side-scripting.html
-- 
GitLab