Mercurial > libervia-pubsub
diff src/pgsql_storage.py @ 403:1dc606612405
implemented experimental "consistent_publisher" option:
/!\ pgsql schema needs to be updated /!\
New "consistent_publisher" option has been implemented to allow node owners + admins to
modify an item while preserving the original publisher. This way, original publisher can
still edit the item.
In addition to `consistent_publisher`, `max_items` has been added to PGQSL schema to
prepare for future implementation.
author | Goffi <goffi@goffi.org> |
---|---|
date | Wed, 12 Jun 2019 21:51:50 +0200 |
parents | 724e39d596a9 |
children |
line wrap: on
line diff
--- a/src/pgsql_storage.py Thu May 23 08:58:29 2019 +0200 +++ b/src/pgsql_storage.py Wed Jun 12 21:51:50 2019 +0200 @@ -79,7 +79,7 @@ parseXml = lambda unicode_data: generic.parseXml(unicode_data.encode('utf-8')) ITEMS_SEQ_NAME = u'node_{node_id}_seq' PEP_COL_NAME = 'pep' -CURRENT_VERSION = '4' +CURRENT_VERSION = '5' # 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_ACCESS_MODEL: const.VAL_AMODEL_DEFAULT, const.OPT_PUBLISH_MODEL: const.VAL_PMODEL_DEFAULT, const.OPT_SERIAL_IDS: False, + const.OPT_CONSISTENT_PUBLISHER: False, }, 'collection': { const.OPT_DELIVER_PAYLOADS: True, @@ -154,8 +155,9 @@ const.OPT_ACCESS_MODEL:row[6], const.OPT_PUBLISH_MODEL:row[7], const.OPT_SERIAL_IDS:row[8], + const.OPT_CONSISTENT_PUBLISHER:row[9], } - schema = row[9] + schema = row[10] if schema is not None: schema = parseXml(schema) node = LeafNode(row[0], row[1], configuration, schema) @@ -191,6 +193,7 @@ access_model, publish_model, serial_ids, + consistent_publisher, schema::text, pep FROM nodes @@ -212,6 +215,7 @@ access_model, publish_model, serial_ids, + consistent_publisher, schema::text, pep FROM nodes @@ -265,10 +269,11 @@ access_model, publish_model, serial_ids, + consistent_publisher, schema, pep) VALUES - (%s, 'leaf', %s, %s, %s, %s, %s, %s, %s, %s)""", + (%s, 'leaf', %s, %s, %s, %s, %s, %s, %s, %s, %s)""", (nodeIdentifier, config['pubsub#persist_items'], config['pubsub#deliver_payloads'], @@ -276,6 +281,7 @@ config[const.OPT_ACCESS_MODEL], config[const.OPT_PUBLISH_MODEL], config[const.OPT_SERIAL_IDS], + config[const.OPT_CONSISTENT_PUBLISHER], schema, recipient.userhost() if pep else None ) @@ -535,7 +541,8 @@ send_last_published_item=%s, access_model=%s, publish_model=%s, - serial_ids=%s + serial_ids=%s, + consistent_publisher=%s WHERE node_id=%s""", (config[const.OPT_PERSIST_ITEMS], config[const.OPT_DELIVER_PAYLOADS], @@ -543,6 +550,7 @@ config[const.OPT_ACCESS_MODEL], config[const.OPT_PUBLISH_MODEL], config[const.OPT_SERIAL_IDS], + config[const.OPT_CONSISTENT_PUBLISHER], self.nodeDbId)) def _setCachedConfiguration(self, void, config):