parameters: (self, custom_values={})
return_statement: return Instance(xml=instance_xml)
docstring: 1. Checks to see if the registration form has been created alread. If not, it loads it in.
          
          2. Loads a registration instance.
docstring_summary: 1. Checks to see if the registration form has been created alread. If not, it loads it in.
          
          2. Loads a registration instance.
docstring_tokens: 1 . Checks to see if the registration form has been created alread . If not it loads it in . 2 . Loads a registration instance .
function: def get_registration_instance(self, custom_values={}):
          """
          1. Checks to see if the registration form has been created alread. If not, it loads it in.
          
          2. Loads a registration instance.
          """
          registration_xforms = XForm.objects.filter(title=u"registration")
          if registration_xforms.count() == 0:
              xf = self.create_registration_xform()
          else:
              xf = registration_xforms[0]
          
          values = {
              u'device_id': u'12345',
              u'start': u'2011-01-01T09:50:06.966',
              u'end': u'2011-01-01T09:53:22.965'
          }
          
          if u'start' in custom_values:
              st = custom_values[u'start']
              custom_values[u'start'] = st.strftime(XFORM_TIME_FORMAT)
  
              #if no end_time is specified, defaults to 1 hour
              values[u'end'] = (st+ONE_HOUR).strftime(XFORM_TIME_FORMAT)
          
          if u'end' in custom_values:
              custom_values[u'end'] = custom_values[u'end'].strftime(XFORM_TIME_FORMAT)
          
          values.update(custom_values)
          
          reg_xform = _load_registration_survey_object()
          reg_instance = reg_xform.instantiate()
          reg_instance._id = xf.id_string
          
          for k, v in values.items():
              reg_instance.answer(name=k, value=v)
          
          instance_xml = reg_instance.to_xml()
          
          return Instance(xml=instance_xml)
function_tokens: def get_registration_instance ( self , custom_values = { } ) : registration_xforms = XForm . objects . filter ( title = u"registration" ) if registration_xforms . count ( ) == 0 : xf = self . create_registration_xform ( ) else : xf = registration_xforms [ 0 ] values = { u'device_id' : u'12345' , u'start' : u'2011-01-01T09:50:06.966' , u'end' : u'2011-01-01T09:53:22.965' } if u'start' in custom_values : st = custom_values [ u'start' ] custom_values [ u'start' ] = st . strftime ( XFORM_TIME_FORMAT ) #if no end_time is specified, defaults to 1 hour values [ u'end' ] = ( st + ONE_HOUR ) . strftime ( XFORM_TIME_FORMAT ) if u'end' in custom_values : custom_values [ u'end' ] = custom_values [ u'end' ] . strftime ( XFORM_TIME_FORMAT ) values . update ( custom_values ) reg_xform = _load_registration_survey_object ( ) reg_instance = reg_xform . instantiate ( ) reg_instance . _id = xf . id_string for k , v in values . items ( ) : reg_instance . answer ( name = k , value = v ) instance_xml = reg_instance . to_xml ( ) return Instance ( xml = instance_xml )