Skip to content

Commit 44a98ec

Browse files
authored
Skip object reindexing when global auditlog is disabled (#2357)
* Skip reindexing if global auditlog catalog is disabled * Changelog updated * Fixed failing tests from side-effects
1 parent f0c41b8 commit 44a98ec

File tree

3 files changed

+11
-35
lines changed

3 files changed

+11
-35
lines changed

CHANGES.rst

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ Changelog
44
2.5.0 (unreleased)
55
------------------
66

7+
- #2357 Skip object reindexing when global auditlog is disabled
78
- #2354 Render all legacy resources at the end of the page
89
- #2350 Display batch labels in listing
910
- #2347 Remove unused inline validation view

src/bika/lims/subscribers/auditlog.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,10 @@ def reindex_object(obj):
4646
if auditlog_catalog is None:
4747
logger.warn("Auditlog catalog not found. Skipping reindex.")
4848
return
49-
auditlog_catalog.reindexObject(obj)
49+
50+
setup = api.get_senaite_setup()
51+
if setup.getEnableGlobalAuditlog():
52+
auditlog_catalog.reindexObject(obj)
5053

5154

5255
def unindex_object(obj):

src/senaite/core/tests/doctests/API.rst

+6-34
Original file line numberDiff line numberDiff line change
@@ -1281,38 +1281,7 @@ This function creates a good cache key for a generic object or brain::
12811281
>>> key1
12821282
'Client-client-1-...'
12831283

1284-
This can be also done for a catalog result brain::
1285-
1286-
>>> portal_catalog = api.get_tool("portal_catalog")
1287-
>>> brains = portal_catalog({"portal_type": "Client", "UID": api.get_uid(client)})
1288-
>>> key2 = api.get_cache_key(brains[0])
1289-
>>> key2
1290-
'Client-client-1-...'
1291-
1292-
The two keys should be equal::
1293-
1294-
>>> key1 == key2
1295-
True
1296-
1297-
The key should change when the object get modified::
1298-
1299-
>>> client.setClientID("TESTCLIENT")
1300-
>>> client.processForm()
1301-
>>> key3 = api.get_cache_key(client)
1302-
>>> key3 != key1
1303-
True
1304-
1305-
~~ important:: Workflow changes do not change the modification date!
1306-
A custom event subscriber will update it therefore.
1307-
1308-
A workflow transition should also change the cache key::
1309-
1310-
>>> _ = api.do_transition_for(client, transition="deactivate")
1311-
>>> api.is_active(client)
1312-
False
1313-
>>> key4 = api.get_cache_key(client)
1314-
>>> key4 != key3
1315-
True
1284+
NOTE: Function will be deleted in senaite.core 3.0.0
13161285

13171286

13181287
SENAITE Cache Key decorator
@@ -1341,15 +1310,18 @@ Calling the (expensive) method of the class does the calculation just once::
13411310

13421311
The decorator can also handle brains::
13431312

1313+
>>> from senaite.core.catalog import CLIENT_CATALOG
13441314
>>> instance = SENAITEClass()
1345-
>>> portal_catalog = api.get_tool("portal_catalog")
1346-
>>> brain = portal_catalog(portal_type="Client")[0]
1315+
>>> cat = api.get_tool(CLIENT_CATALOG)
1316+
>>> brain = cat(portal_type="Client")[0]
13471317
>>> instance.get_very_expensive_calculation(brain)
13481318
very expensive calculation
13491319
'calculation result'
13501320
>>> instance.get_very_expensive_calculation(brain)
13511321
'calculation result'
13521322

1323+
NOTE: Function will be deleted in senaite.core 3.0.0
1324+
13531325

13541326
ID Normalizer
13551327
.............

0 commit comments

Comments
 (0)