diff sat_pubsub/pgsql_storage.py @ 438:b5e1e8d93dd4

backend, pgsql: new `overwrite_policy` node setting: /!\ pgsql schema needs to be updated /!\ this settings can be set currently to 2 values: - `original_publisher` (default), when only original publisher of an item can overwrite it (except node owner/admin) - `any_publisher` when any entity with publishing right can overwrite any item.
author Goffi <goffi@goffi.org>
date Sat, 27 Feb 2021 21:20:32 +0100
parents f6a225476165
children 074037832daf
line wrap: on
line diff
--- a/sat_pubsub/pgsql_storage.py	Mon Feb 08 19:01:29 2021 +0100
+++ b/sat_pubsub/pgsql_storage.py	Sat Feb 27 21:20:32 2021 +0100
@@ -79,7 +79,7 @@
 parseXml = lambda unicode_data: generic.parseXml(unicode_data.encode('utf-8'))
 ITEMS_SEQ_NAME = 'node_{node_id}_seq'
 PEP_COL_NAME = 'pep'
-CURRENT_VERSION = '7'
+CURRENT_VERSION = '8'
 # retrieve the maximum integer item id + 1
 NEXT_ITEM_ID_QUERY = r"SELECT COALESCE(max(item::integer)+1,1) as val from items where node_id={node_id} and item ~ E'^\\d+$'"
 
@@ -114,6 +114,7 @@
                 const.OPT_SEND_LAST_PUBLISHED_ITEM: 'on_sub',
                 const.OPT_ACCESS_MODEL: const.VAL_AMODEL_DEFAULT,
                 const.OPT_PUBLISH_MODEL: const.VAL_PMODEL_DEFAULT,
+                const.OPT_OVERWRITE_POLICY: const.VAL_OWPOL_DEFAUT,
                 const.OPT_SERIAL_IDS: False,
                 const.OPT_CONSISTENT_PUBLISHER: False,
                 const.OPT_FTS_LANGUAGE: const.VAL_FTS_GENERIC,
@@ -155,11 +156,12 @@
                     const.OPT_SEND_LAST_PUBLISHED_ITEM: row[6],
                     const.OPT_ACCESS_MODEL:row[7],
                     const.OPT_PUBLISH_MODEL:row[8],
-                    const.OPT_SERIAL_IDS:row[9],
-                    const.OPT_CONSISTENT_PUBLISHER:row[10],
-                    const.OPT_FTS_LANGUAGE: row[11],
+                    const.OPT_OVERWRITE_POLICY: row[9],
+                    const.OPT_SERIAL_IDS:row[10],
+                    const.OPT_CONSISTENT_PUBLISHER:row[11],
+                    const.OPT_FTS_LANGUAGE: row[12],
                     }
-            schema = row[12]
+            schema = row[13]
             if schema is not None:
                 schema = parseXml(schema)
             node = LeafNode(row[0], row[1], configuration, schema)
@@ -207,6 +209,7 @@
                                  send_last_published_item,
                                  access_model,
                                  publish_model,
+                                 overwrite_policy,
                                  serial_ids,
                                  consistent_publisher,
                                  fts_language,
@@ -231,6 +234,7 @@
                                           send_last_published_item,
                                           access_model,
                                           publish_model,
+                                          overwrite_policy,
                                           serial_ids,
                                           consistent_publisher,
                                           fts_language,
@@ -286,19 +290,21 @@
                                send_last_published_item,
                                access_model,
                                publish_model,
+                               overwrite_policy,
                                serial_ids,
                                consistent_publisher,
                                fts_language,
                                schema,
                                pep)
                               VALUES
-                              (%s, 'leaf', %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)""",
+                              (%s, 'leaf', %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)""",
                            (nodeIdentifier,
                             config['pubsub#persist_items'],
                             config['pubsub#deliver_payloads'],
                             config['pubsub#send_last_published_item'],
                             config[const.OPT_ACCESS_MODEL],
                             config[const.OPT_PUBLISH_MODEL],
+                            config[const.OPT_OVERWRITE_POLICY],
                             config[const.OPT_SERIAL_IDS],
                             config[const.OPT_CONSISTENT_PUBLISHER],
                             config[const.OPT_FTS_LANGUAGE],