def resolve_embedded_fields(resource, req):
 embedded_fields = []
 non_embedded_fields = []
 if req.embedded:
  try:
   client_embedding = json.loads(req.embedded)
  except ValueError:
   abort(400, description='Unable to parse `embedded` clause')
  try:
   embedded_fields = [k for (k, v) in client_embedding.items() if (v == 1)]
   non_embedded_fields = [k for (k, v) in client_embedding.items() if (v == 0)]
  except AttributeError:
   abort(400, description='Unable to parse `embedded` clause')
 embedded_fields = list(((set(config.DOMAIN[resource]['embedded_fields']) | set(embedded_fields)) - set(non_embedded_fields)))
 enabled_embedded_fields = []
 for field in sorted(embedded_fields, key=(lambda a: a.count('.'))):
  field_def = field_definition(resource, field)
  if field_def:
   if (field_def.get('type') == 'list'):
    field_def = field_def['schema']
   if (('data_relation' in field_def) and field_def['data_relation'].get('embeddable')):
    enabled_embedded_fields.append(field)
 return enabled_embedded_fields

def resolve_embedded_fields ( resource , req ) : embedded_fields = [ ] non_embedded_fields = [ ] if req . embedded : try : client_embedding = json . loads ( req . embedded ) except ValueError : abort ( 400 , description = 'Unable to parse `embedded` clause' ) try : embedded_fields = [ k for ( k , v ) in client_embedding . items ( ) if ( v == 1 ) ] non_embedded_fields = [ k for ( k , v ) in client_embedding . items ( ) if ( v == 0 ) ] except AttributeError : abort ( 400 , description = 'Unable to parse `embedded` clause' ) embedded_fields = list ( ( ( set ( config . DOMAIN [ resource ] [ 'embedded_fields' ] ) | set ( embedded_fields ) ) - set ( non_embedded_fields ) ) ) enabled_embedded_fields = [ ] for field in sorted ( embedded_fields , key = ( lambda a : a . count ( '.' ) ) ) : field_def = field_definition ( resource , field ) if field_def : if ( field_def . get ( 'type' ) == 'list' ) : field_def = field_def [ 'schema' ] if ( ( 'data_relation' in field_def ) and field_def [ 'data_relation' ] . get ( 'embeddable' ) ) : enabled_embedded_fields . append ( field ) return enabled_embedded_fields
returns a list of validated embedded fields from the incoming request or from the resource definition is the request does not specify .