Skip to content

Commit

Permalink
Fix AttributeError when running upgrade 240x with stale brains (sen…
Browse files Browse the repository at this point in the history
…aite#2247)

* Fix AttributeError when running upgrade 240x

* Changelog
  • Loading branch information
xispa authored Feb 10, 2023
1 parent 01ff657 commit fb8deb9
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 12 deletions.
1 change: 1 addition & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Changelog
2.4.0 (unreleased)
------------------

- #2247 Fix `AttributeError` when running upgrade 240x with stale brains
- #2246 Update ReactJS to version 18.2.0
- #2245 Add missing translation for "Show more" (from app.listing)
- #2243 Add ".pdf" extension to filenames for productivity reports
Expand Down
33 changes: 21 additions & 12 deletions src/senaite/core/upgrade/v02_04_000.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,9 @@ def fix_traceback_retract_dl(tool):
# reduce memory size of the transaction
transaction.savepoint()

obj = api.get_object(brain)
if not obj:
try:
obj = api.get_object(brain)
except AttributeError:
uncatalog_brain(brain)
continue

Expand Down Expand Up @@ -405,8 +406,9 @@ def rename_retestof_relationship(tool):
transaction.savepoint()

# find out if the current analysis is a retest
obj = api.get_object(brain)
if not obj:
try:
obj = api.get_object(brain)
except AttributeError:
uncatalog_brain(brain)
continue

Expand Down Expand Up @@ -461,10 +463,12 @@ def purge_backreferences(tool):
transaction.savepoint()

# Purge back-references to current object
obj = api.get_object(brain)
if not obj:
try:
obj = api.get_object(brain)
except AttributeError:
uncatalog_brain(brain)
continue

purge_backreferences_to(obj)

# Flush the object from memory
Expand Down Expand Up @@ -582,10 +586,12 @@ def purge_backreferences_analysisrequest(tool):
transaction.savepoint()

# Purge back-references to current object
obj = api.get_object(brain)
if not obj:
try:
obj = api.get_object(brain)
except AttributeError:
uncatalog_brain(brain)
continue

purge_backreferences_to(obj)

# Flush the object from memory
Expand All @@ -608,10 +614,12 @@ def migrate_interim_values_to_string(tool):
logger.info("Processed objects: {}/{}".format(num, total))

# Migrate float values of interim fields
obj = api.get_object(brain)
if not obj:
try:
obj = api.get_object(brain)
except AttributeError:
uncatalog_brain(brain)
continue

interims = obj.getInterimFields()

for interim in interims:
Expand Down Expand Up @@ -656,8 +664,9 @@ def ensure_sample_client_fields_are_set(portal):
# reduce memory size of the transaction
transaction.savepoint()

obj = api.get_object(brain)
if not obj:
try:
obj = api.get_object(brain)
except AttributeError:
uncatalog_brain(brain)
continue

Expand Down

0 comments on commit fb8deb9

Please sign in to comment.