Commit b9ed6f66 authored by Jérome Perrin's avatar Jérome Perrin

tout le bordel

parent 12775b38
......@@ -1657,6 +1657,7 @@ class CategoryTemplateItem(ObjectTemplateItem):
def afterInstall(self):
if self._installed_new_category:
# reset accessors if we installed a new category
# XXX do not reset test
self.portal_types.resetDynamicDocumentsOnceAtTransactionBoundary()
class SkinTemplateItem(ObjectTemplateItem):
......@@ -3509,6 +3510,7 @@ class FilesystemDocumentTemplateItem(BaseTemplateItem):
return modified_object_list
def _resetDynamicModules(self):
print "_resetDynamicModules"
# before any import, flush all ZODB caches to force a DB reload
# otherwise we could have objects trying to get commited while
# holding reference to a class that is no longer the same one as
......@@ -3520,7 +3522,7 @@ class FilesystemDocumentTemplateItem(BaseTemplateItem):
# connection
portal = self.getPortalObject()
portal._p_jar.db().cacheMinimize()
synchronizeDynamicModules(portal, force=True)
synchronizeDynamicModules(portal, force=True, reset_test=False)
gc.collect()
def install(self, context, trashbin, **kw):
......
......@@ -72,7 +72,7 @@ class PermissionConfiguratorItem(ConfiguratorItemMixin, XMLObject):
# add to module map
module_permissions_map[module_id] = module_permissions
# set permissions in fake site
# set permissions on site
portal = self.getPortalObject()
for module_id, permissions_map in module_permissions_map.items():
if permissions_map != {}:
......
......@@ -86,7 +86,6 @@ class RoleConfiguratorItem(ConfiguratorItemMixin, XMLObject):
mod_conf_list.append(conf_dict)
portal_type_dict[portal_type] = mod_conf_list
## Update fake site
# XXX rafael: improve this, the ignore list is quite ugly.
ignore_list = []
portal_type_id_list = portal.portal_types.objectIds()
......
......@@ -35,8 +35,7 @@ from Products.ERP5Type.Cache import CachingMethod
from zLOG import LOG, INFO
class StandardBT5ConfiguratorItem(ConfiguratorItemMixin, XMLObject):
""" This class will install standard ERP5 template from a repository to
fake site. """
""" This class will install standard ERP5 template from a repository """
meta_type = 'ERP5 Standard BT5 Configurator Item'
portal_type = 'Standard BT5 Configurator Item'
......
......@@ -232,9 +232,10 @@ class TALESValue(StaticValue):
except:
# We add this safety exception to make sure we always get
# something reasonable rather than generate plenty of errors
LOG('ERP5Form', PROBLEM,
'Field.get_value %r [%s], exception on tales_expr: ' %
(field, id), error=sys.exc_info())
if 0:
LOG('ERP5Form', PROBLEM,
'Field.get_value %r [%s], exception on tales_expr: ' %
(field, id), error=sys.exc_info())
# field may be ProxyField
# here we avoid calling field.get_recursive_orig_value
# on all fields because it can be acquired from another
......
......@@ -284,7 +284,7 @@ class TypesTool(TypeProvider):
WARNING: COSTLY! Please double-check that
resetDynamicDocumentsOnceAtTransactionBoundary can't be used instead.
"""
synchronizeDynamicModules(self, force=True)
synchronizeDynamicModules(self, force=True, reset_test=False)
def _finalizeMigration(self):
"""Compatibility code to finalize migration from CMF Types Tool"""
......
......@@ -78,7 +78,7 @@ class ComponentDynamicPackage(ModuleType):
self.__registry_dict = collections.defaultdict(dict)
self.__fullname_source_code_dict = {}
# Add this module to sys.path for future imports
# Add this module to sys.module for future imports
sys.modules[namespace] = self
# Add the import hook
......@@ -253,6 +253,8 @@ class ComponentDynamicPackage(ModuleType):
#
# Also, handle the case where find_module() may be called without import
# statement as it does change anything in sys.modules
if 'test' in fullname:
print "Ahaha", fullname
import_lock_held = True
try:
imp.release_lock()
......
......@@ -103,6 +103,7 @@ def initializeDynamicModules():
erp5.component.test:
holds Live Test modules previously found in bt5 in $INSTANCE_HOME/test
"""
print "initializeDynamicModules"
erp5 = PackageType("erp5")
# Document classes without physical import path
......
......@@ -20,6 +20,7 @@ from zLOG import LOG, WARNING, BLATHER
from portal_type_class import generatePortalTypeClass
from accessor_holder import AccessorHolderType
import persistent_migration
import weakref
class ERP5BaseBroken(Broken, ERP5Base):
# PersistentBroken can't be reused directly
......@@ -132,6 +133,7 @@ class PortalTypeMetaClass(GhostBaseMetaClass, PropertyHolder):
# register which classes subclass portal type classes
subclass_register = {} # XXX ideal defaultdict(list) wannabe
# XXX weak ref ???
def __init__(cls, name, bases, dictionary):
"""
......@@ -139,9 +141,13 @@ class PortalTypeMetaClass(GhostBaseMetaClass, PropertyHolder):
created, or when a class inheriting a portal type
class is created
"""
#print "__init__", cls, name
for parent in bases:
if issubclass(type(parent), PortalTypeMetaClass):
PortalTypeMetaClass.subclass_register.setdefault(parent, []).append(cls)
PortalTypeMetaClass.subclass_register.setdefault(parent,
weakref.WeakSet([])
#set()
).add(cls)
cls.workflow_method_registry = {}
......@@ -183,6 +189,7 @@ class PortalTypeMetaClass(GhostBaseMetaClass, PropertyHolder):
return property_dict.itervalues()
def resetAcquisition(cls):
#print "resetAcquisition", cls
# First, fill the __get__ slot of the class
# that has been null'ed after resetting its __bases__
# This descriptor is the magic allowing __of__ and our
......@@ -191,6 +198,7 @@ class PortalTypeMetaClass(GhostBaseMetaClass, PropertyHolder):
# And we need to do the same thing on subclasses
for subclass in PortalTypeMetaClass.getSubclassList(cls):
#print " resetAcquisition", subclass
pmc_init_of(subclass)
def setupSecurity(cls):
......
......@@ -286,7 +286,7 @@ def loadTempPortalTypeClass(portal_type_name):
last_sync = -1
_bootstrapped = set()
def synchronizeDynamicModules(context, force=False):
def synchronizeDynamicModules(context, force=False, reset_test=True):
"""
Allow resetting all classes to ghost state, most likely done after
adding and removing mixins on the fly
......@@ -362,11 +362,17 @@ def synchronizeDynamicModules(context, force=False):
" property sheet tool failed", error=sys.exc_info())
raise
LOG("ERP5Type.dynamic", 0, "Resetting dynamic classes")
LOG("ERP5Type.dynamic", 0, "Resetting dynamic classes (reset_test:%s)" %
reset_test)
if reset_test:
import ipdb; ipdb.set_trace()
try:
for class_name, klass in inspect.getmembers(erp5.portal_type,
inspect.isclass):
klass.restoreGhostState()
if reset_test:
klass.restoreGhostState()
elif not 'Test' in class_name:
klass.restoreGhostState()
# Clear accessor holders of ZODB Property Sheets and Portal Types
erp5.accessor_holder.clear()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment