<s> from django . template . loader import render_to_string <EOL> import mimetypes <EOL> from wellknown . resources import HostMeta <EOL> _cache = { } <EOL> def get_hostmeta ( ) : <EOL> return get_resource ( '<STR_LIT>' ) [ <NUM_LIT:0> ] <EOL> def get_resource ( path ) : <EOL> return _cache . get ( path , ( None , None ) ) <EOL> def register ( path , handler = None , template = None , content = None , content_type = None , update = False ) : <EOL> if path in _cache : <EOL> raise ValueError ( u"<STR_LIT>" % path ) <EOL> if content_type is None and not update : <EOL> content_type = mimetypes . guess_type ( path ) [ <NUM_LIT:0> ] or '<STR_LIT>' <EOL> if handler : <EOL> _cache [ path ] = ( handler , content_type ) <EOL> elif template : <EOL> _cache [ path ] = ( render_to_string ( template ) , content_type ) <EOL> elif content : <EOL> _cache [ path ] = ( content , content_type ) <EOL> else : <EOL> raise ValueError ( u"<STR_LIT>" ) <EOL> __all__ = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> register ( '<STR_LIT>' , handler = HostMeta ( ) , <EOL> content_type = '<STR_LIT>' ) </s>
