Open do3cc opened 10 years ago
Not using the component architecture would be a big backwards-incompatible change, but there's some work that should be done here.
Actually supermodel tries to defer loading of models, which is what uses utilities, until the end of configuration. This work is done by plone.supermodel.SchemaClass._SchemaClass_finalize, which is called from one of two places:
The problem happens if a schema gets imported in the middle of configuration (or test setup) at a point where the schema plugin adapters are registered but the various field handlers are not. We need to find a better way to defer loading until everything needed is in place.
We discovert simmilar problems, when we are using subclassing of schema interfaces which uses model.load() to load xml files. If we try later to omit a field with autoform, it works but makes trouble in tests, complaining that the field we want to omit does not exists. In pure Python schema this does not hapen.
Right now, supermodel tries to access utilities during import time, when being used to define a schema of an interface. It may or may not be that at that time all utilities have been loaded, bring back one of the problems the zcml component architecture tried to solve, namely not depend on import orders. Currently, when I use supermodel schemas, I have to create a different marker interface, contained within a different module and then declare browser views for that marker interface. Else, my tests won't run, because supermodel cannot initialize my schema.