#NEWLINE# def register_sizer( self , attr_name , sizedimage_cls ) : #NEWLINE# #INDENT# '\n        Register a new SizedImage subclass (`sizedimage_cls`) to be used\n        via the attribute (`attr_name`)\n        ' #NEWLINE# if ( attr_name . startswith ( '_' ) or ( attr_name in self . unallowed_sizer_names ) ) : #NEWLINE# #INDENT# raise UnallowedSizerName ( ( '`%s` is an unallowed Sizer name. Sizer names cannot begin with an underscore or be named any of the following: %s.' % ( attr_name , ', ' . join ( [ name for name in self . unallowed_sizer_names ] ) ) ) ) #NEWLINE# #UNINDENT# if ( not issubclass ( sizedimage_cls , SizedImage ) ) : #NEWLINE# #INDENT# raise InvalidSizedImageSubclass ( 'Only subclasses of versatileimagefield.datastructures.SizedImage may be registered with register_sizer' ) #NEWLINE# #UNINDENT# if ( attr_name in self . _sizedimage_registry ) : #NEWLINE# #INDENT# raise AlreadyRegistered ( ( 'A SizedImage class is already registered to the `%s` attribute. If you would like to override this attribute, use the unregister method' % attr_name ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . _sizedimage_registry [ attr_name ] = sizedimage_cls