<s> """<STR_LIT>""" <EOL> __all__ = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> from flask import current_app , url_for <EOL> from mongoengine import * <EOL> from tentd import __tent_version__ as tent_version <EOL> from tentd . documents import db , EntityMixin <EOL> from tentd . utils import json_attributes <EOL> from tentd . lib . mongoengine import URIField <EOL> class Profile ( EntityMixin , db . Document ) : <EOL> """<STR_LIT>""" <EOL> meta = { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : True , <EOL> '<STR_LIT>' : [ '<STR_LIT>' ] , <EOL> } <EOL> schema = URIField ( unique_with = '<STR_LIT>' , required = True ) <EOL> permissions = DictField ( ) <EOL> def __new__ ( cls , * args , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> if '<STR_LIT>' in kwargs : <EOL> cls = GenericProfile <EOL> if CoreProfile . __schema__ == kwargs [ '<STR_LIT>' ] : <EOL> cls = CoreProfile <EOL> return super ( Profile , cls ) . __new__ ( cls ) <EOL> def __init__ ( self , ** kwargs ) : <EOL> if self . __class__ is Profile : <EOL> raise NotImplementedError ( "<STR_LIT>" ) <EOL> super ( Profile , self ) . __init__ ( ** kwargs ) <EOL> if not self . schema and hasattr ( self . __class__ , '<STR_LIT>' ) : <EOL> self . schema = self . __class__ . __schema__ <EOL> def __repr__ ( self ) : <EOL> return "<STR_LIT>" . format ( self . __class__ . __name__ , self . schema ) <EOL> def update_values ( self , values ) : <EOL> raise NotImplementedError ( "<STR_LIT>" ) <EOL> class CoreProfile ( Profile ) : <EOL> """<STR_LIT>""" <EOL> meta = { <EOL> '<STR_LIT>' : [ { <EOL> '<STR_LIT>' : [ '<STR_LIT>' ] , <EOL> '<STR_LIT>' : True , <EOL> } ] , <EOL> } <EOL> __schema__ = '<STR_LIT>' <EOL> identity = URIField ( unique_with = '<STR_LIT>' , required = True ) <EOL> servers = ListField ( URIField ( ) ) <EOL> def __init__ ( self , * args , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> super ( CoreProfile , self ) . __init__ ( * args , ** kwargs ) <EOL> self . permissions [ '<STR_LIT>' ] = True <EOL> if not self . identity and self . entity is not None : <EOL> self . identity = url_for ( <EOL> '<STR_LIT>' , entity = self . entity , _external = True ) <EOL> def to_json ( self ) : <EOL> return { <EOL> '<STR_LIT>' : self . identity , <EOL> '<STR_LIT>' : [ ] , <EOL> '<STR_LIT>' : self . servers , <EOL> '<STR_LIT>' : tent_version <EOL> } <EOL> def update_values ( self , values ) : <EOL> if '<STR_LIT>' in values : <EOL> self . identity = values [ '<STR_LIT>' ] <EOL> if '<STR_LIT>' in values : <EOL> self . servers = values [ '<STR_LIT>' ] <EOL> class GenericProfile ( db . DynamicDocument , Profile ) : <EOL> def to_json ( self ) : <EOL> return json_attributes ( self , * self . _dynamic_fields ) <EOL> def update_values ( self , values ) : <EOL> pass </s>
