Migrate AuditLog to Dexterity and move audit log machinery to senaite.core - #2980
Merged
Conversation
…refactor/auditlog-to-senaite-core # Conflicts: # src/senaite/core/upgrade/v02_07_000.zcml
ramonski
marked this pull request as draft
July 8, 2026 21:49
ramonski
force-pushed
the
refactor/auditlog-to-senaite-core
branch
2 times, most recently
from
July 9, 2026 05:52
8dcb843 to
0426956
Compare
The AuditLog folder only backs the listing view and holds no content of its own; the audit snapshots live on the audited objects and are found via the auditlog catalog. It is recreated rather than migrated: the old bika_setup/auditlog folder is removed and a fresh DX folder is created at setup/auditlog, and fresh installs create it alongside the other SENAITE setup items. A minimal AT AuditLog stub is kept at bika.lims.controlpanel.auditlog so the legacy folder still loads as a regular object and deletes cleanly via the normal uncatalog/delete path. The remaining AT classes will be dropped before 3.0. The global audit log action now points to setup/auditlog, while the per-object audit trail keeps using @@auditlog, so traversal resolves the contained folder first.
ramonski
force-pushed
the
refactor/auditlog-to-senaite-core
branch
from
July 9, 2026 06:02
0426956 to
82ec6f3
Compare
ramonski
marked this pull request as ready for review
July 9, 2026 06:18
…enaite-core # Conflicts: # src/bika/lims/api/snapshot.py # src/bika/lims/browser/templates/auditlog_diff.pt # src/bika/lims/controlpanel/auditlog.py # src/senaite/core/profiles/default/metadata.xml # src/senaite/core/upgrade/v02_07_000.zcml
| storage = annotation.get(SNAPSHOT_STORAGE) | ||
| if storage: | ||
| del(annotation[SNAPSHOT_STORAGE]) | ||
| from senaite.core.api.snapshot import * # noqa: F401,F403 |
…enaite-core # Conflicts: # src/senaite/core/upgrade/v02_07_000.py # src/senaite/core/upgrade/v02_07_000.zcml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of the issue/feature this PR addresses
The audit log / snapshot machinery still lived under the legacy
bika.limsnamespace, and theAuditLogcontainer was still an Archetypes content type. This PR moves the whole audit log stack intosenaite.coreand replaces the ArchetypesAuditLogfolder with a Dexterity one that lives in the new SENAITE setup, alongside the other AT to DX migrations (Laboratory, Calculations, ...).Backwards compatibility is preserved for add-ons (e.g.
senaite.storage) via thin re-export shims at the old import locations.Current behavior before PR
bika.lims.api.snapshotholds the snapshot storage and diff logic.bika.lims.subscribers.auditlog.@@auditlogview and the site-wide audit log control panel live inbika.lims.browser/bika.lims.controlpanel.AuditLogis an ArchetypesATFolder(bika.lims.controlpanel.auditlog), registered with a Factory-based FTI, and lives atbika_setup/auditlog.IAuditLogis defined inbika.lims.interfaces.Desired behavior after PR is merged
senaite.core.api.snapshot(re-export shim kept atbika.lims.api.snapshot).senaite.core.subscribers.auditlogand registered there.@@auditlogview +auditlog_diff.ptmoved tosenaite.core.browser; the site-wide audit log control panel moved tosenaite.core.browser.controlpanel.auditlog.AuditLogis now a Dexterity content type (senaite.core.content.auditlog.AuditLog) with a Dexterity FTI;IAuditLogmoved tosenaite.core.interfaces(with abika.lims.interfacesre-export soprovidedBychecks are unaffected).AuditLogfolder now lives in the new SENAITE setup atsetup/auditlog(next to Laboratory, Calculations, ...) instead ofbika_setup/auditlog. Fresh installs create it there via the setup handler.setup/auditlog. The per-object audit trail keeps using the explicit@@auditlogform; becauseBTreeFolder2exposes contained items via__getattr__, traversal resolves theauditlogfolder before the same-named per-object view, sosetup/auditlogrenders the global listing.Migration
The
AuditLogfolder never holds content of its own; it only backs the listing view (the audit snapshots live as annotations on the audited objects and are looked up through the auditlog catalog, not through this folder). The upgrade step (2750to2751) therefore does not migrate any data: it removes the oldbika_setup/auditlogfolder and creates a fresh DexterityAuditLogin the SENAITE setup.A minimal Archetypes
AuditLogstub is kept atbika.lims.controlpanel.auditlogso that folders persisted by earlier versions still load as regular objects (instead of unpickling as Broken ones, now that the real AT class is gone) and can be removed cleanly through the normal uncatalog/delete path. The remaining legacy AT classes will be dropped before 3.0.Testing
senaite.coreprofile install succeed (this exercises the fresh-install creation of the DXAuditLogfolder in the SENAITE setup).bin/test-senaite -s senaite.core -t API_snapshotand-t Catalogspass.auditlogfolder: the old folder is removed, the DXsetup/auditlogis created, and the audit log listing renders at the new URL.--
I confirm I have tested this PR thoroughly and coded it according to PEP8
and Plone's Python styleguide standards.