diff --git a/product/ERP5Type/dynamic/portal_type_class.py b/product/ERP5Type/dynamic/portal_type_class.py
index d97edc02ec98b5b45d8555d67fd47da1750fcf62..4a6e2f0ac48ac2ec949ebaf752200f948038adf1 100644
--- a/product/ERP5Type/dynamic/portal_type_class.py
+++ b/product/ERP5Type/dynamic/portal_type_class.py
@@ -382,23 +382,24 @@ def synchronizeDynamicModules(context, force=False):
       _bootstrapped.add(portal.id)
 
     LOG("ERP5Type.dynamic", 0, "Resetting dynamic classes")
-    for class_name, klass in inspect.getmembers(erp5.portal_type,
-                                                inspect.isclass):
-      klass.restoreGhostState()
-
-    # Clear accessor holders of ZODB Property Sheets and Portal Types
-    erp5.accessor_holder.clear()
-    erp5.accessor_holder.property_sheet.clear()
-
-    for name in erp5.accessor_holder.portal_type.__dict__.keys():
-      if name[0] != '_':
-        delattr(erp5.accessor_holder.portal_type, name)
-
-  except Exception:
-    # Allow easier debugging when the code is wrong as this exception
-    # is catched later and re-raised as a BadRequest
-    import traceback; traceback.print_exc()
-    raise
+    try:
+      for class_name, klass in inspect.getmembers(erp5.portal_type,
+                                                  inspect.isclass):
+        klass.restoreGhostState()
+
+      # Clear accessor holders of ZODB Property Sheets and Portal Types
+      erp5.accessor_holder.clear()
+      erp5.accessor_holder.property_sheet.clear()
+
+      for name in erp5.accessor_holder.portal_type.__dict__.keys():
+        if name[0] != '_':
+          delattr(erp5.accessor_holder.portal_type, name)
+
+    except Exception:
+      # Allow easier debugging when the code is wrong as this
+      # exception is catched later and re-raised as a BadRequest
+      import traceback; traceback.print_exc()
+      raise
 
   finally:
     Base.aq_method_lock.release()