comparison idavoll/pgsql_storage.py @ 124:c4ee16bc48e5

Change Node.set_configuration() to set cached configuration in a callback.
author Ralph Meijer <ralphm@ik.nu>
date Tue, 12 Apr 2005 12:34:25 +0000
parents 4f0113adb7ed
children d3689da18ed2
comparison
equal deleted inserted replaced
123:8f99b4f7aea2 124:c4ee16bc48e5
118 118
119 def get_configuration(self): 119 def get_configuration(self):
120 return self._config 120 return self._config
121 121
122 def set_configuration(self, options): 122 def set_configuration(self, options):
123 return self._dbpool.runInteraction(self._set_configuration,
124 options)
125
126 def _set_configuration(self, cursor, options):
127 self._check_node_exists(cursor)
128
129 config = copy.copy(self._config) 123 config = copy.copy(self._config)
130 124
131 for option in options: 125 for option in options:
132 if option in config: 126 if option in config:
133 config[option] = options[option] 127 config[option] = options[option]
134 128
129 d = self._dbpool.runInteraction(self._set_configuration, config)
130 d.addCallback(self._set_cached_configuration, config)
131 return d
132
133 def _set_configuration(self, cursor, config):
134 self._check_node_exists(cursor)
135 cursor.execute("""UPDATE nodes SET persistent=%s, deliver_payload=%s 135 cursor.execute("""UPDATE nodes SET persistent=%s, deliver_payload=%s
136 WHERE node=%s""", 136 WHERE node=%s""",
137 (config["pubsub#persist_items"], 137 (config["pubsub#persist_items"],
138 config["pubsub#deliver_payloads"], 138 config["pubsub#deliver_payloads"],
139 self.id.encode('utf-8'))) 139 self.id.encode('utf-8')))
140 140
141 def _set_cached_configuration(self, void, config):
141 self._config = config 142 self._config = config
142 143
143 def get_meta_data(self): 144 def get_meta_data(self):
144 config = copy.copy(self._config) 145 config = copy.copy(self._config)
145 config["pubsub#node_type"] = self.type 146 config["pubsub#node_type"] = self.type