def _name_value_to_bson(name, value, check_keys, opts):
 try:
  return _ENCODERS[type(value)](name, value, check_keys, opts)
 except KeyError:
  pass
 marker = getattr(value, '_type_marker', None)
 if (isinstance(marker, int) and (marker in _MARKERS)):
  func = _MARKERS[marker]
  _ENCODERS[type(value)] = func
  return func(name, value, check_keys, opts)
 for base in _ENCODERS:
  if isinstance(value, base):
   func = _ENCODERS[base]
   _ENCODERS[type(value)] = func
   return func(name, value, check_keys, opts)
 raise InvalidDocument(('cannot convert value of type %s to bson' % type(value)))

def _name_value_to_bson ( name , value , check_keys , opts ) : try : return _ENCODERS [ type ( value ) ] ( name , value , check_keys , opts ) except KeyError : pass marker = getattr ( value , '_type_marker' , None ) if ( isinstance ( marker , int ) and ( marker in _MARKERS ) ) : func = _MARKERS [ marker ] _ENCODERS [ type ( value ) ] = func return func ( name , value , check_keys , opts ) for base in _ENCODERS : if isinstance ( value , base ) : func = _ENCODERS [ base ] _ENCODERS [ type ( value ) ] = func return func ( name , value , check_keys , opts ) raise InvalidDocument ( ( 'cannot convert value of type %s to bson' % type ( value ) ) )
encode a single name .