Skip to content

Commit

Permalink
Fix several UnboundLocalError exceptions when doing automated impor…
Browse files Browse the repository at this point in the history
…t with `return_json=True`
  • Loading branch information
petschki committed Jul 5, 2024
1 parent 6f8834b commit 968eaaf
Showing 1 changed file with 16 additions and 33 deletions.
49 changes: 16 additions & 33 deletions src/collective/exportimport/import_other.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,8 @@ def __call__(self, jsonfile=None, return_json=False):
except Exception as e:
logger.error(e)
status = "error"
msg = e
api.portal.show_message(
_(u"Failure while uploading: {}").format(e),
request=self.request,
)
msg = _(u"Failure while uploading: {}").format(e)
api.portal.show_message(msg, request=self.request)
else:
msg = self.do_import(data)
api.portal.show_message(msg, self.request)
Expand Down Expand Up @@ -194,10 +191,8 @@ def __call__(self, jsonfile=None, return_json=False):
except Exception as e:
status = "error"
logger.error(e)
api.portal.show_message(
_(u"Failure while uploading: {}").format(e),
request=self.request,
)
msg = _(u"Failure while uploading: {}").format(e)
api.portal.show_message(msg, request=self.request)
else:
groups = self.import_groups(data["groups"])
members = self.import_members(data["members"])
Expand Down Expand Up @@ -385,10 +380,8 @@ def __call__(self, jsonfile=None, return_json=False):
except Exception as e:
status = "error"
logger.error(e)
api.portal.show_message(
_(u"Failure while uploading: {}").format(e),
request=self.request,
)
msg = _(u"Failure while uploading: {}").format(e)
api.portal.show_message(msg, request=self.request)
else:
localroles = self.import_localroles(data)
msg = _(u"Imported {} localroles").format(localroles)
Expand Down Expand Up @@ -461,10 +454,8 @@ def __call__(self, jsonfile=None, return_json=False):
except Exception as e:
status = "error"
logger.error(e)
api.portal.show_message(
_(u"Failure while uploading: {}").format(e),
request=self.request,
)
msg = _(u"Failure while uploading: {}").format(e)
api.portal.show_message(msg, request=self.request)
else:
start = datetime.now()
orders = self.import_ordering(data)
Expand Down Expand Up @@ -519,10 +510,8 @@ def __call__(self, jsonfile=None, return_json=False):
except Exception as e:
status = "error"
logger.error(e)
api.portal.show_message(
u"Failure while uploading: {}".format(e),
request=self.request,
)
msg = u"Failure while uploading: {}".format(e)
api.portal.show_message(msg, request=self.request)
else:
defaultpages = self.import_default_pages(data)
msg = _(u"Changed {} default pages").format(defaultpages)
Expand Down Expand Up @@ -592,10 +581,8 @@ def __call__(self, jsonfile=None, return_json=False):
except Exception as e:
status = "error"
logger.error(e)
api.portal.show_message(
_(u"Failure while uploading: {}").format(e),
request=self.request,
)
msg = _(u"Failure while uploading: {}").format(e)
api.portal.show_message(msg, request=self.request)
else:
results = self.import_data(data)
msg = _(u"Imported {} comments").format(results)
Expand Down Expand Up @@ -688,10 +675,8 @@ def __call__(self, jsonfile=None, return_json=False):
except Exception as e:
status = "error"
logger.error(e)
api.portal.show_message(
_(u"Failure while uploading: {}").format(e),
request=self.request,
)
msg = _(u"Failure while uploading: {}").format(e)
api.portal.show_message(msg, request=self.request)
else:
portlets = self.import_portlets(data)
msg = _(u"Created {} portlets").format(portlets)
Expand Down Expand Up @@ -875,10 +860,8 @@ def __call__(self, jsonfile=None, return_json=False):
except Exception as e:
status = "error"
logger.error(e)
api.portal.show_message(
_(u"Failure while uploading: {}").format(e),
request=self.request,
)
msg = _(u"Failure while uploading: {}").format(e)
api.portal.show_message(msg, request=self.request)
else:
import_plone_redirects(data)
msg = _(u"Redirects imported")
Expand Down

0 comments on commit 968eaaf

Please sign in to comment.