Skip to content

Commit

Permalink
Fixed plugin_pool.register_plugin with a list of plugins
Browse files Browse the repository at this point in the history
added a deprecation warning. registering lists will be removed in 2.3 (because there should be one way to do it)
  • Loading branch information
Jonas Obrist committed Aug 29, 2011
1 parent 66fbff0 commit 61e3877
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions cms/plugin_pool.py
Expand Up @@ -6,6 +6,7 @@
from cms.utils.placeholder import get_placeholder_conf
from django.conf import settings
from django.core.exceptions import ImproperlyConfigured
import warnings

class PluginPool(object):
def __init__(self):
Expand All @@ -25,8 +26,10 @@ def register_plugin(self, plugin):
If a plugin is already registered, this will raise PluginAlreadyRegistered.
"""
if hasattr(plugin,'__iter__'):
warnings.warn("Registering more than one plugin at once will be deprecated in 2.3", DeprecationWarning)
for single_plugin in plugin:
self.register_plugin(single_plugin)
return
if not issubclass(plugin, CMSPluginBase):
raise ImproperlyConfigured(
"CMS Plugins must be subclasses of CMSPluginBase, %r is not."
Expand Down Expand Up @@ -58,8 +61,10 @@ def unregister_plugin(self, plugin):
If a plugin isn't already registered, this will raise PluginNotRegistered.
"""
if hasattr(plugin,'__iter__'):
warnings.warn("Unregistering more than one plugin at once will be deprecated in 2.3", DeprecationWarning)
for single_plugin in plugin:
self.unregister_plugin(single_plugin)
return
plugin_name = plugin.__name__
if plugin_name not in self.plugins:
raise PluginNotRegistered(
Expand Down

0 comments on commit 61e3877

Please sign in to comment.