PluginPool

Note

Attenzione

la presente configurazione rende invisibili i moduli cms_plugins

Django-cms has a standard way to discover plugins that is via plugin_pool.plugin_pool.discover_plugins() called within cms.admin’ init file.

Since jumbo project tries to keep cms’files in a separate directory (app.cms) we need to discover plugins (and apps/toolbars) in the new position by out own.

discover_plugins uses load(‘cms_plugins’) that in turn uses a imp.find_utils from the app directory. The simples this is to to uses JmbPluginPool that looks for cms instead. Cms will be a directory it’s __init__.py must not import plugins or other module that in turn import models

urls.py

This PluginPool must be called by hand before admin.autodiscover() in urls.py:

from jmb.cms.plugin_pool import JmbPluginPool
from cms import plugin_pool

plugin_pool.plugin_pool = JmbPluginPool()
admin.autodiscover()

models

To keep models related to cms in cms’directory and avoid circular dependencies, we will use strings instead of object in ForeignKey and ManyToMany fields:

class Foo(CMSPlugin):
  bar = models.ManyToManyField('app.MyModel')

At the end of models.py we will import this module:

if settings.CMS_ENABLED:
import my.app.cms.models

Apps & Toolbar

Apps and toolbar can be imported directly at the end of the plugin module

This Page