diff options
| author | Aurélien Bompard | 2015-12-02 10:30:59 +0100 |
|---|---|---|
| committer | Barry Warsaw | 2015-12-16 11:04:25 -0500 |
| commit | 30611aa0d445bc5e19ce37f6b01289f9cc2b7f0b (patch) | |
| tree | 2bebcd25549b9f8200137f1c49483828d65a88ef /src/mailman/model/pending.py | |
| parent | ed9efb350c7629be2b8f1fe509c74e5dca6935f0 (diff) | |
| download | mailman-30611aa0d445bc5e19ce37f6b01289f9cc2b7f0b.tar.gz mailman-30611aa0d445bc5e19ce37f6b01289f9cc2b7f0b.tar.zst mailman-30611aa0d445bc5e19ce37f6b01289f9cc2b7f0b.zip | |
Diffstat (limited to 'src/mailman/model/pending.py')
| -rw-r--r-- | src/mailman/model/pending.py | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/mailman/model/pending.py b/src/mailman/model/pending.py index a98c9dfb8..54188c39f 100644 --- a/src/mailman/model/pending.py +++ b/src/mailman/model/pending.py @@ -79,7 +79,7 @@ class Pended(Model): @implementer(IPendable) class UnpendedPendable(dict): - pass + PEND_TYPE = 'unpended' @@ -114,6 +114,9 @@ class Pendings: pending = Pended( token=token, expiration_date=now() + lifetime) + pendable_type = pendable.pop('type', pendable.PEND_TYPE) + pending.key_values.append( + PendedKeyValue(key='type', value=pendable_type)) for key, value in pendable.items(): # Both keys and values must be strings. if isinstance(key, bytes): @@ -141,7 +144,10 @@ class Pendings: # Iter on PendedKeyValue entries that are associated with the pending # object's ID. Watch out for type conversions. for keyvalue in pending.key_values: - value = json.loads(keyvalue.value) + if keyvalue.key == 'type': + value = keyvalue.value + else: + value = json.loads(keyvalue.value) if isinstance(value, dict) and '__encoding__' in value: value = value['value'].encode(value['__encoding__']) pendable[keyvalue.key] = value @@ -169,7 +175,7 @@ class Pendings: pkv_alias_type = aliased(PendedKeyValue) query = query.join(pkv_alias_type).filter(and_( pkv_alias_type.key == 'type', - pkv_alias_type.value == json.dumps(type) + pkv_alias_type.value == type )) for pending in query: yield pending.token, self.confirm(pending.token, expunge=False) |
