@@ -1281,38 +1281,7 @@ This function creates a good cache key for a generic object or brain::
1281
1281
>>> key1
1282
1282
'Client-client-1-...'
1283
1283
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
1316
1285
1317
1286
1318
1287
SENAITE Cache Key decorator
@@ -1341,15 +1310,18 @@ Calling the (expensive) method of the class does the calculation just once::
1341
1310
1342
1311
The decorator can also handle brains::
1343
1312
1313
+ >>> from senaite.core.catalog import CLIENT_CATALOG
1344
1314
>>> 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]
1347
1317
>>> instance.get_very_expensive_calculation(brain)
1348
1318
very expensive calculation
1349
1319
'calculation result'
1350
1320
>>> instance.get_very_expensive_calculation(brain)
1351
1321
'calculation result'
1352
1322
1323
+ NOTE: Function will be deleted in senaite.core 3.0.0
1324
+
1353
1325
1354
1326
ID Normalizer
1355
1327
.............
0 commit comments