#NEWLINE# def register( self , plugin ) : #NEWLINE# #INDENT# '\n        Make a plugin known to the CMS.\n\n        :param plugin: The plugin class, deriving from :class:`ContentPlugin`.\n        :type plugin: :class:`ContentPlugin`\n\n        The plugin will be instantiated once, just like Django does this with :class:`~django.contrib.admin.ModelAdmin` classes.\n        If a plugin is already registered, this will raise a :class:`PluginAlreadyRegistered` exception.\n        ' #NEWLINE# assert issubclass ( plugin , ContentPlugin ) , 'The plugin must inherit from `ContentPlugin`' #NEWLINE# assert plugin . model , 'The plugin has no model defined' #NEWLINE# assert issubclass ( plugin . model , ContentItem ) , 'The plugin model must inherit from `ContentItem`' #NEWLINE# assert issubclass ( plugin . form , ContentItemForm ) , 'The plugin form must inherit from `ContentItemForm`' #NEWLINE# name = plugin . __name__ #NEWLINE# if ( name in self . plugins ) : #NEWLINE# #INDENT# raise PluginAlreadyRegistered ( '{0}: a plugin with this name is already registered' . format ( name ) ) #NEWLINE# #UNINDENT# name = name . lower ( ) #NEWLINE# if ( plugin . model in self . _name_for_model ) : #NEWLINE# #INDENT# existing_plugin = self . plugins [ self . _name_for_model [ plugin . model ] ] #NEWLINE# raise ModelAlreadyRegistered ( "Can't register the model {0} to {2}, it's already registered to {1}!" . format ( plugin . model . __name__ , existing_plugin . name , plugin_instance . __name__ ) ) #NEWLINE# #UNINDENT# plugin_instance = plugin ( ) #NEWLINE# self . plugins [ name ] = plugin_instance #NEWLINE# self . _name_for_model [ plugin . model ] = name #NEWLINE# if ( self . _name_for_ctype_id is not None ) : #NEWLINE# #INDENT# self . _name_for_ctype_id [ plugin . type_id ] = name #NEWLINE# #UNINDENT# return plugin