portal = context.getPortalObject()

destination_project = context.getRelativeUrl()

ors_reference = 'ors.' + ors_tag
data_acquisition_unit = context.portal_catalog.getResultValue(
  portal_type='Data Acquisition Unit',
  reference=ors_reference,
  # Do not test for title collision: irrelevant
  validation_state='validated'
)
if data_acquisition_unit:
  portal_status_message = "ORS with tag %s already registered." % ors_tag
  kw['keep_items'] = dict(
    portal_status_message=portal_status_message,
    portal_status_level='error'
  )
  return context.Base_redirect(form_id, **kw)

data_acquisition_unit = portal.data_acquisition_unit_module.newContent(
  portal_type='Data Acquisition Unit',
  reference=ors_reference,
  title=ors_title
)
data_acquisition_unit.validate()
data_supply = data_acquisition_unit.DataAcquisitionUnit_createOrsDataSupply(destination_project, batch=1)

portal_status_message = "New ORS successfully added to project."
kw['keep_items'] = dict(portal_status_message=portal_status_message)
return context.Base_redirect(form_id, **kw)
