Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Eliminate duplication in surgery. #5

Open
deiferni opened this issue Jul 8, 2019 · 0 comments
Open

Eliminate duplication in surgery. #5

deiferni opened this issue Jul 8, 2019 · 0 comments

Comments

@deiferni
Copy link
Contributor

deiferni commented Jul 8, 2019

Currently surgeries have pre-op checks done in perform. There is a certain level of duplication in those checks, when we touch them next we should attempt to reduce it. Namely

rid = self.unhealthy_rid.rid
if len(self.unhealthy_rid.paths) != 1:
raise CantPerformSurgery(
"Expected exactly one affected path, got: {}"
.format(", ".join(self.unhealthy_rid.paths)))
path = self.unhealthy_rid.paths[0]
if self.catalog.uids[path] == rid:
raise CantPerformSurgery(
"Expected different rid in catalog uids mapping for path {}"
.format(path))

and

rid = self.unhealthy_rid.rid
if len(self.unhealthy_rid.paths) != 1:
raise CantPerformSurgery(
"Expected exactly one affected path, got: {}"
.format(", ".join(self.unhealthy_rid.paths)))
path = list(self.unhealthy_rid.paths)[0]
if path in self.catalog.uids:
raise CantPerformSurgery(
"Expected path to be absent from catalog uids {}"
.format(path))
portal = api.portal.get()
obj = portal.unrestrictedTraverse(path, None)
if obj is not None:
raise CantPerformSurgery(
"Unexpectedly found object at {}".format(path))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant