def strip_ccx(val):
 retval = val
 ccx_id = None
 if isinstance(retval, CCXLocator):
  ccx_id = retval.ccx
  retval = retval.to_course_locator()
 elif isinstance(retval, CCXBlockUsageLocator):
  ccx_id = retval.course_key.ccx
  retval = retval.to_block_locator()
 else:
  for field_name in XMODULE_FIELDS_WITH_USAGE_KEYS:
   if hasattr(retval, field_name):
    (stripped_field_value, ccx_id) = strip_ccx(getattr(retval, field_name))
    setattr(retval, field_name, stripped_field_value)
 return (retval, ccx_id)

def strip_ccx ( val ) : retval = val ccx_id = None if isinstance ( retval , CCXLocator ) : ccx_id = retval . ccx retval = retval . to_course_locator ( ) elif isinstance ( retval , CCXBlockUsageLocator ) : ccx_id = retval . course_key . ccx retval = retval . to_block_locator ( ) else : for field_name in XMODULE_FIELDS_WITH_USAGE_KEYS : if hasattr ( retval , field_name ) : ( stripped_field_value , ccx_id ) = strip_ccx ( getattr ( retval , field_name ) ) setattr ( retval , field_name , stripped_field_value ) return ( retval , ccx_id )
remove any reference to a ccx from the incoming value return a tuple of the stripped value and the id of the ccx .