Commit 77f7a03b authored by Jérome Perrin's avatar Jérome Perrin

full_text_mroonga_catalog: fix a PY3 regression

from 031408c6 (erp5_full_text_mroonga_catalog: defer fulltext index
and unindex using dedicated catalog keys., 2025-01-13)
parent 769d52a3
Pipeline #39117 failed with stage
in 0 seconds
contains_more_than_uid = set(['uid']).isdisjoint
uid_list = [] uid_list = []
for grouped_message in grouped_message_list: for grouped_message in grouped_message_list:
assert not grouped_message.args assert not grouped_message.args
assert grouped_message.kw.keys() == ['uid'] assert not contains_more_than_uid(grouped_message.kw)
uid_list.append(grouped_message.kw['uid']) uid_list.append(grouped_message.kw['uid'])
for method_id in context.getSqlDeferredUncatalogObjectList(): for method_id in context.getSqlDeferredUncatalogObjectList():
method = getattr(context, method_id) method = getattr(context, method_id)
......
  • @kazuhiko is this a good way ? I first did using ensure_list ( see 8631cc5d ) but I don't like ensure_list so much because it is "slower" on py3.

  • How about the following ?

    @@ -1,8 +1,8 @@
     uid_list = []
     for grouped_message in grouped_message_list:
       assert not grouped_message.args
    -  assert grouped_message.kw.keys() == ['uid']
    -  uid_list.append(grouped_message.kw['uid'])
    +  uid_list.append(grouped_message.kw.pop('uid'))
    +  assert not grouped_message.kw
     for method_id in context.getSqlDeferredUncatalogObjectList():
       method = getattr(context, method_id)
       method(uid=uid_list)
  • Thanks, but is it "safe" to mutate this dict like this ?

  • I believe it's safe, unless we use the dict in the code below of the same script.

  • Or... I can propose the following, if you prefer.

      assert len(grouped_message.kw) == 1
      uid_list.append(grouped_message.kw['uid'])
  • ah sorry, I forgot to reply. I was a bit worried about not only using the dict in the same script, but also from the functions calling the script. I really like what you just suggested.

Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment