Fixed a bug in malthes rewrite of the schema cache, since invalidate on the schema cache can be invoked for a non-registered FTI, which caused an error, furthermore invalidate schema was called for an unregistered FTI, which was definitely also a mistake.

This commit is contained in:
Headnet 2012-11-06 15:33:37 +01:00 committed by Malthe Borch
parent 75d2b6dd5d
commit 412e370d28
2 changed files with 6 additions and 5 deletions

View File

@ -367,11 +367,11 @@ def unregister(fti, old_name=None):
site_manager = getSiteManager(site)
portal_type = old_name or fti.getId()
notify(SchemaInvalidatedEvent(portal_type))
site_manager.unregisterUtility(provided=IDexterityFTI, name=portal_type)
unregister_factory(fti.factory, site_manager)
notify(SchemaInvalidatedEvent(portal_type))
unregister_factory(fti.factory, site_manager)
def unregister_factory(factory_name, site_manager):
"""Helper method to unregister factories when unused by any dexterity
@ -465,4 +465,4 @@ def ftiModified(object, event):
model = fti.lookupModel()
syncSchema(model.schema, schema, overwrite=True)
notify(SchemaInvalidatedEvent(portal_type))
notify(SchemaInvalidatedEvent(portal_type))

View File

@ -115,7 +115,8 @@ class SchemaCache(object):
@synchronized(lock)
def invalidate(self, portal_type):
fti = queryUtility(IDexterityFTI, name=portal_type)
invalidate_cache(fti)
if fti is not None:
invalidate_cache(fti)
SCHEMA_CACHE = SchemaCache()