-
Notifications
You must be signed in to change notification settings - Fork 235
Description
Context: When creating a FeinCMS site using some kind of plugin mechanism, I ran into this problem.
Each plugin wants to contribute some Template to the main project. To do that, it will do something like
from feincms.module.page.models import Page
regions_main = (('main', 'Content'), )
Page.register_templates(
{'key': 'mmmmh', 'title': 'Tasty template', 'path': 'munch/nomnom.html', 'regions': regions_main}
)This will not work.
Each region holds a list of content types that can be used in that region. Unfortunately, this list is built when a concrete content type is created, so calling register_templates again later will add regions that have no content types at all.
I can paper over this by patching in all content types here
for region in Page._feincms_all_regions:
if not region._content_types:
region._content_types = Page._feincms_content_types.copy() # copy is important otherwise CTs will be duplicatedbut that is not always what is wanted, since I can't restrict CTs to a region that way.
If we ever want to restrict a CT to a certain region, things will become more complicated (the region set for each CT is not stored anywhere, so that information is lost once the CT has been instanciated).
Food for thought...