<s> from django . core . exceptions import ValidationError <EOL> from django . utils . module_loading import import_string <EOL> from sellmo . conf import get_setting <EOL> from sellmo . core . loading import load <EOL> from . constants import MAX_TIER_ATTRIBUTES <EOL> import sellmo . contrib . settings as _settings <EOL> def _attribute_types ( value ) : <EOL> types = { } <EOL> for typ in value : <EOL> if isinstance ( typ , basestring ) : <EOL> typ = import_string ( typ ) ( ) <EOL> types [ typ . key ] = typ <EOL> return types <EOL> @ load ( before = '<STR_LIT>' ) <EOL> def load_model ( ) : <EOL> if MAX_TIER_ATTRIBUTES == <NUM_LIT:0> : <EOL> return <EOL> tiered_attribute_types = _attribute_types ( <EOL> get_setting ( <EOL> '<STR_LIT>' , <EOL> default = [ <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> ] <EOL> ) <EOL> ) <EOL> class SiteSettings ( _settings . models . SiteSettings ) : <EOL> def clean ( self ) : <EOL> errors = { } <EOL> for i in range ( MAX_TIER_ATTRIBUTES ) : <EOL> attr = '<STR_LIT>' . format ( i + <NUM_LIT:1> ) <EOL> attribute = getattr ( self , attr , None ) <EOL> if attribute is None : <EOL> continue <EOL> attribute_type = type ( attribute . get_type ( ) ) <EOL> if ( <EOL> not any ( <EOL> [ <EOL> issubclass ( attribute_type , <EOL> typ ) for typ in tiered_attribute_types <EOL> ] <EOL> ) <EOL> ) : <EOL> errors [ attr ] = [ <EOL> _ ( "<STR_LIT>" ) <EOL> ] <EOL> if errors : <EOL> raise ValidationError ( errors ) <EOL> class Meta ( _settings . models . SiteSettings . Meta ) : <EOL> abstract = True <EOL> _settings . models . SiteSettings = SiteSettings </s>
