#NEWLINE# def register( model , tag_descriptor_attr = 'tags' , tagged_item_manager_attr = 'tagged' ) : #NEWLINE# #INDENT# '\n    Sets the given model class up for working with tags.\n    ' #NEWLINE# from tagging.managers import ModelTaggedItemManager , TagDescriptor #NEWLINE# if ( model in registry ) : #NEWLINE# #INDENT# raise AlreadyRegistered ( ( "The model '%s' has already been registered." % model . _meta . object_name ) ) #NEWLINE# #UNINDENT# if hasattr ( model , tag_descriptor_attr ) : #NEWLINE# #INDENT# raise AttributeError ( ( "'%s' already has an attribute '%s'. You must provide a custom tag_descriptor_attr to register." % ( model . _meta . object_name , tag_descriptor_attr ) ) ) #NEWLINE# #UNINDENT# if hasattr ( tagged_item_manager_attr , tagged_item_manager_attr ) : #NEWLINE# #INDENT# raise AttributeError ( ( "'%s' already has an attribute '%s'. You must provide a custom tagged_item_manager_attr to register." % ( model . _meta . object_name , tagged_item_manager_attr ) ) ) #NEWLINE# #UNINDENT# setattr ( model , tag_descriptor_attr , TagDescriptor ( ) ) #NEWLINE# ModelTaggedItemManager ( ) . contribute_to_class ( model , tagged_item_manager_attr ) #NEWLINE# registry . append ( model )