<s> import traceback <EOL> import sys <EOL> from django . core . exceptions import ImproperlyConfigured <EOL> class BaseRegistry ( set ) : <EOL> """<STR_LIT>""" <EOL> def register ( self , model ) : <EOL> from django . db import models <EOL> if model in self : <EOL> raise ImproperlyConfigured ( <EOL> "<STR_LIT>" <EOL> . format ( model ) <EOL> ) <EOL> if not issubclass ( model , models . Model ) : <EOL> raise ImproperlyConfigured ( ( "<STR_LIT>" <EOL> "<STR_LIT>" ) . format ( model ) ) <EOL> if model . _meta . abstract : <EOL> raise ImproperlyConfigured ( "<STR_LIT>" . format ( model ) ) <EOL> self . add ( model ) <EOL> return model <EOL> def unregister ( self , model ) : <EOL> self . remove ( model ) <EOL> class Registry ( BaseRegistry ) : <EOL> """<STR_LIT>""" <EOL> def register ( self , content ) : <EOL> from widgy . models import Content <EOL> if not issubclass ( content , Content ) : <EOL> raise ImproperlyConfigured ( <EOL> "<STR_LIT>" . format ( content ) <EOL> ) <EOL> return super ( Registry , self ) . register ( content ) <EOL> registry = Registry ( ) <EOL> register = registry . register <EOL> unregister = registry . unregister </s>
