original_docstring: 
      * Check that the signer is registered.
      * Check that the record doesn't already exist.
      * Check that the record type exists.
      * Check that the required properties have been provided.
      * Create the record (and record container if needed).
      * Create the associated properties.
      * Post the provided property values.
      
docstring: Check that the signer is registered.
  Check that the record doesn't already exist.
  Check that the record type exists.
  Check that the required properties have been provided.
  Create the record (and record container if needed).
  Create the associated properties.
  Post the provided property values.
docstring_tokens: Check that the signer is registered . Check that the record doesn ' t already exist . Check that the record type exists . Check that the required properties have been provided . Create the record ( and record container if needed ) . Create the associated properties . Post the provided property values .
code: def _create_record(payload, signer, timestamp, state):
      '''
      * Check that the signer is registered.
      * Check that the record doesn't already exist.
      * Check that the record type exists.
      * Check that the required properties have been provided.
      * Create the record (and record container if needed).
      * Create the associated properties.
      * Post the provided property values.
      '''
  
      # Check that the signer is registered.
      _verify_agent(state, signer)
  
      # Check that the record doesn't already exist
      record_id = payload.record_id
  
      if not record_id:
          raise InvalidTransaction(
              'Record id cannot be empty string')
  
      record_address = addressing.make_record_address(record_id)
      record_container = _get_container(state, record_address)
  
      if any(rec.record_id == record_id for rec in record_container.entries):
          raise InvalidTransaction(
              'Record {} already exists'.format(record_id))
  
      # Check that the record type exists.
      type_name = payload.record_type
      record_type, _, _ = _get_record_type(state, type_name)
  
      type_schemata = {
          prop.name: prop
          for prop in record_type.properties
      }
  
      required_properties = {
          name: prop
          for name, prop in type_schemata.items()
          if prop.required
      }
  
      provided_properties = {
          prop.name: prop
          for prop in payload.properties
      }
  
      # Make sure the required properties are all provided
      for name in required_properties:
          if name not in provided_properties:
              raise InvalidTransaction(
                  'Required property {} not provided'.format(
                      name))
  
      # Make sure the provided properties have the right type
      for provided_name in provided_properties:
          required_type = type_schemata[provided_name].data_type
          provided_type = provided_properties[provided_name].data_type
          if required_type != provided_type:
              raise InvalidTransaction(
                  'Value provided for {} is the wrong type'.format(
                      provided_name))
  
      # Create the record
      record = Record(
          record_id=record_id,
          record_type=type_name,
          final=False,
      )
  
      record.owners.extend([
          Record.AssociatedAgent(
              agent_id=signer,
              timestamp=timestamp,
          )
      ])
  
      record.custodians.extend([
          Record.AssociatedAgent(
              agent_id=signer,
              timestamp=timestamp,
          )
      ])
  
      record_container.entries.extend([record])
      record_container.entries.sort(key=lambda rec: rec.record_id)
  
      _set_container(state, record_address, record_container)
  
      # Create the associated properties
      for property_name, prop in type_schemata.items():
          _make_new_property(
              state=state,
              record_id=record_id,
              property_name=property_name,
              data_type=prop.data_type,
              signer=signer,
          )
  
          _make_new_property_page(
              state=state,
              timestamp=timestamp,
              record_id=record_id,
              property_name=property_name,
              value=(
                  None if property_name not in provided_properties
                  else provided_properties[property_name]
              ),
              page_number=1,
          )
code_tokens: def _create_record ( payload , signer , timestamp , state ) : _verify_agent ( state , signer ) record_id = payload . record_id if not record_id : raise InvalidTransaction ( 'Record id cannot be empty string' ) record_address = addressing . make_record_address ( record_id ) record_container = _get_container ( state , record_address ) if any ( rec . record_id == record_id for rec in record_container . entries ) : raise InvalidTransaction ( 'Record {} already exists' . format ( record_id ) ) type_name = payload . record_type record_type , _ , _ = _get_record_type ( state , type_name ) type_schemata = { prop . name : prop for prop in record_type . properties } required_properties = { name : prop for name , prop in type_schemata . items ( ) if prop . required } provided_properties = { prop . name : prop for prop in payload . properties } for name in required_properties : if name not in provided_properties : raise InvalidTransaction ( 'Required property {} not provided' . format ( name ) ) for provided_name in provided_properties : required_type = type_schemata [ provided_name ] . data_type provided_type = provided_properties [ provided_name ] . data_type if required_type != provided_type : raise InvalidTransaction ( 'Value provided for {} is the wrong type' . format ( provided_name ) ) record = Record ( record_id = record_id , record_type = type_name , final = False , ) record . owners . extend ( [ Record . AssociatedAgent ( agent_id = signer , timestamp = timestamp , ) ] ) record . custodians . extend ( [ Record . AssociatedAgent ( agent_id = signer , timestamp = timestamp , ) ] ) record_container . entries . extend ( [ record ] ) record_container . entries . sort ( key = lambda rec : rec . record_id ) _set_container ( state , record_address , record_container ) for property_name , prop in type_schemata . items ( ) : _make_new_property ( state = state , record_id = record_id , property_name = property_name , data_type = prop . data_type , signer = signer , ) _make_new_property_page ( state = state , timestamp = timestamp , record_id = record_id , property_name = property_name , value = ( None if property_name not in provided_properties else provided_properties [ property_name ] ) , page_number = 1 , )
short_docstring: Check that the signer is registered.
short_docstring_tokens: Check that the signer is registered .
comment: '''
      * Check that the signer is registered.
      * Check that the record doesn't already exist.
      * Check that the record type exists.
      * Check that the required properties have been provided.
      * Create the record (and record container if needed).
      * Create the associated properties.
      * Post the provided property values.
      '''$SEP$# Check that the signer is registered.$SEP$# Check that the record doesn't already exist$SEP$# Check that the record type exists.$SEP$# Make sure the required properties are all provided$SEP$# Make sure the provided properties have the right type$SEP$# Create the record$SEP$# Create the associated properties