Mercurial > libervia-pubsub
comparison 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 |
comparison
equal
deleted
inserted
replaced
437:454f61a32427 | 438:b5e1e8d93dd4 |
---|---|
77 | 77 |
78 # parseXml manage str, but we get unicode | 78 # parseXml manage str, but we get unicode |
79 parseXml = lambda unicode_data: generic.parseXml(unicode_data.encode('utf-8')) | 79 parseXml = lambda unicode_data: generic.parseXml(unicode_data.encode('utf-8')) |
80 ITEMS_SEQ_NAME = 'node_{node_id}_seq' | 80 ITEMS_SEQ_NAME = 'node_{node_id}_seq' |
81 PEP_COL_NAME = 'pep' | 81 PEP_COL_NAME = 'pep' |
82 CURRENT_VERSION = '7' | 82 CURRENT_VERSION = '8' |
83 # retrieve the maximum integer item id + 1 | 83 # retrieve the maximum integer item id + 1 |
84 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+$'" | 84 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+$'" |
85 | 85 |
86 | 86 |
87 def withPEP(query, values, pep, recipient): | 87 def withPEP(query, values, pep, recipient): |
112 const.OPT_MAX_ITEMS: 'max', | 112 const.OPT_MAX_ITEMS: 'max', |
113 const.OPT_DELIVER_PAYLOADS: True, | 113 const.OPT_DELIVER_PAYLOADS: True, |
114 const.OPT_SEND_LAST_PUBLISHED_ITEM: 'on_sub', | 114 const.OPT_SEND_LAST_PUBLISHED_ITEM: 'on_sub', |
115 const.OPT_ACCESS_MODEL: const.VAL_AMODEL_DEFAULT, | 115 const.OPT_ACCESS_MODEL: const.VAL_AMODEL_DEFAULT, |
116 const.OPT_PUBLISH_MODEL: const.VAL_PMODEL_DEFAULT, | 116 const.OPT_PUBLISH_MODEL: const.VAL_PMODEL_DEFAULT, |
117 const.OPT_OVERWRITE_POLICY: const.VAL_OWPOL_DEFAUT, | |
117 const.OPT_SERIAL_IDS: False, | 118 const.OPT_SERIAL_IDS: False, |
118 const.OPT_CONSISTENT_PUBLISHER: False, | 119 const.OPT_CONSISTENT_PUBLISHER: False, |
119 const.OPT_FTS_LANGUAGE: const.VAL_FTS_GENERIC, | 120 const.OPT_FTS_LANGUAGE: const.VAL_FTS_GENERIC, |
120 }, | 121 }, |
121 'collection': { | 122 'collection': { |
153 const.OPT_MAX_ITEMS: 'max' if row[4] == 0 else str(row[4]), | 154 const.OPT_MAX_ITEMS: 'max' if row[4] == 0 else str(row[4]), |
154 const.OPT_DELIVER_PAYLOADS: row[5], | 155 const.OPT_DELIVER_PAYLOADS: row[5], |
155 const.OPT_SEND_LAST_PUBLISHED_ITEM: row[6], | 156 const.OPT_SEND_LAST_PUBLISHED_ITEM: row[6], |
156 const.OPT_ACCESS_MODEL:row[7], | 157 const.OPT_ACCESS_MODEL:row[7], |
157 const.OPT_PUBLISH_MODEL:row[8], | 158 const.OPT_PUBLISH_MODEL:row[8], |
158 const.OPT_SERIAL_IDS:row[9], | 159 const.OPT_OVERWRITE_POLICY: row[9], |
159 const.OPT_CONSISTENT_PUBLISHER:row[10], | 160 const.OPT_SERIAL_IDS:row[10], |
160 const.OPT_FTS_LANGUAGE: row[11], | 161 const.OPT_CONSISTENT_PUBLISHER:row[11], |
162 const.OPT_FTS_LANGUAGE: row[12], | |
161 } | 163 } |
162 schema = row[12] | 164 schema = row[13] |
163 if schema is not None: | 165 if schema is not None: |
164 schema = parseXml(schema) | 166 schema = parseXml(schema) |
165 node = LeafNode(row[0], row[1], configuration, schema) | 167 node = LeafNode(row[0], row[1], configuration, schema) |
166 node.dbpool = self.dbpool | 168 node.dbpool = self.dbpool |
167 return node | 169 return node |
205 max_items, | 207 max_items, |
206 deliver_payloads, | 208 deliver_payloads, |
207 send_last_published_item, | 209 send_last_published_item, |
208 access_model, | 210 access_model, |
209 publish_model, | 211 publish_model, |
212 overwrite_policy, | |
210 serial_ids, | 213 serial_ids, |
211 consistent_publisher, | 214 consistent_publisher, |
212 fts_language, | 215 fts_language, |
213 schema::text, | 216 schema::text, |
214 pep | 217 pep |
229 max_items, | 232 max_items, |
230 deliver_payloads, | 233 deliver_payloads, |
231 send_last_published_item, | 234 send_last_published_item, |
232 access_model, | 235 access_model, |
233 publish_model, | 236 publish_model, |
237 overwrite_policy, | |
234 serial_ids, | 238 serial_ids, |
235 consistent_publisher, | 239 consistent_publisher, |
236 fts_language, | 240 fts_language, |
237 schema::text, | 241 schema::text, |
238 pep | 242 pep |
284 persist_items, | 288 persist_items, |
285 deliver_payloads, | 289 deliver_payloads, |
286 send_last_published_item, | 290 send_last_published_item, |
287 access_model, | 291 access_model, |
288 publish_model, | 292 publish_model, |
293 overwrite_policy, | |
289 serial_ids, | 294 serial_ids, |
290 consistent_publisher, | 295 consistent_publisher, |
291 fts_language, | 296 fts_language, |
292 schema, | 297 schema, |
293 pep) | 298 pep) |
294 VALUES | 299 VALUES |
295 (%s, 'leaf', %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)""", | 300 (%s, 'leaf', %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)""", |
296 (nodeIdentifier, | 301 (nodeIdentifier, |
297 config['pubsub#persist_items'], | 302 config['pubsub#persist_items'], |
298 config['pubsub#deliver_payloads'], | 303 config['pubsub#deliver_payloads'], |
299 config['pubsub#send_last_published_item'], | 304 config['pubsub#send_last_published_item'], |
300 config[const.OPT_ACCESS_MODEL], | 305 config[const.OPT_ACCESS_MODEL], |
301 config[const.OPT_PUBLISH_MODEL], | 306 config[const.OPT_PUBLISH_MODEL], |
307 config[const.OPT_OVERWRITE_POLICY], | |
302 config[const.OPT_SERIAL_IDS], | 308 config[const.OPT_SERIAL_IDS], |
303 config[const.OPT_CONSISTENT_PUBLISHER], | 309 config[const.OPT_CONSISTENT_PUBLISHER], |
304 config[const.OPT_FTS_LANGUAGE], | 310 config[const.OPT_FTS_LANGUAGE], |
305 schema, | 311 schema, |
306 recipient.userhost() if pep else None | 312 recipient.userhost() if pep else None |