def clone_to(self, target_catalog):
def _clone(obj_id):<EOL><INDENT>package_name = obj_id.get_identifier_namespace().split('<STR_LIT:.>')[<NUM_LIT:0>]<EOL>obj_name = obj_id.get_identifier_namespace().split('<STR_LIT:.>')[<NUM_LIT:1>].lower()<EOL>catalogs = {<EOL>'<STR_LIT>': '<STR_LIT>',<EOL>'<STR_LIT>': '<STR_LIT>'<EOL>}<EOL>my_catalog_name = catalogs[package_name.lower()]<EOL>mgr = self.my_osid_object._get_provider_manager(package_name.upper())<EOL>if self.my_osid_object._proxy is not None:<EOL><INDENT>catalog_lookup_session = getattr(mgr, '<STR_LIT>' + my_catalog_name + '<STR_LIT>')(<EOL>proxy=self.my_osid_object._proxy<EOL>)<EOL><DEDENT>else:<EOL><INDENT>catalog_lookup_session = getattr(mgr, '<STR_LIT>' + my_catalog_name + '<STR_LIT>')()<EOL><DEDENT>catalog = getattr(catalog_lookup_session, '<STR_LIT>' + my_catalog_name)(target_catalog.ident)<EOL>if self.my_osid_object._proxy is not None:<EOL><INDENT>admin_session = getattr(mgr, '<STR_LIT>' + obj_name + '<STR_LIT>' + my_catalog_name)(<EOL>catalog.ident,<EOL>proxy=self.my_osid_object._proxy<EOL>)<EOL><DEDENT>else:<EOL><INDENT>admin_session = getattr(mgr, '<STR_LIT>' + obj_name + '<STR_LIT>' + my_catalog_name)(catalog.ident)<EOL><DEDENT>new_obj = getattr(admin_session, '<STR_LIT>' + obj_name)(obj_id)<EOL>try:<EOL><INDENT>form = getattr(admin_session, '<STR_LIT>' + obj_name + '<STR_LIT>')(new_obj.ident)<EOL>form.set_provenance(str(obj_id))<EOL>new_obj = getattr(admin_session, '<STR_LIT>' + obj_name)(form)<EOL><DEDENT>except AttributeError:<EOL><INDENT>pass<EOL><DEDENT>return new_obj<EOL><DEDENT>enclosed_object_id = self.get_enclosed_object_id()<EOL>new_enclosed_object = _clone(enclosed_object_id)<EOL>enclosure_id = self.my_osid_object.ident<EOL>new_asset = _clone(enclosure_id)<EOL>package_name = enclosure_id.get_identifier_namespace().split('<STR_LIT:.>')[<NUM_LIT:0>]<EOL>obj_name = enclosure_id.get_identifier_namespace().split('<STR_LIT:.>')[<NUM_LIT:1>].lower()<EOL>catalogs = {<EOL>'<STR_LIT>': '<STR_LIT>',<EOL>'<STR_LIT>': '<STR_LIT>'<EOL>}<EOL>my_catalog_name = catalogs[package_name.lower()]<EOL>mgr = self.my_osid_object._get_provider_manager(package_name.upper())<EOL>if self.my_osid_object._proxy is not None:<EOL><INDENT>catalog_lookup_session = getattr(mgr, '<STR_LIT>' + my_catalog_name + '<STR_LIT>')(<EOL>proxy=self.my_osid_object._proxy<EOL>)<EOL><DEDENT>else:<EOL><INDENT>catalog_lookup_session = getattr(mgr, '<STR_LIT>' + my_catalog_name + '<STR_LIT>')()<EOL><DEDENT>catalog = getattr(catalog_lookup_session, '<STR_LIT>' + my_catalog_name)(target_catalog.ident)<EOL>if self.my_osid_object._proxy is not None:<EOL><INDENT>admin_session = getattr(mgr, '<STR_LIT>' + obj_name + '<STR_LIT>' + my_catalog_name)(<EOL>catalog.ident,<EOL>proxy=self.my_osid_object._proxy<EOL>)<EOL><DEDENT>else:<EOL><INDENT>admin_session = getattr(mgr, '<STR_LIT>' + obj_name + '<STR_LIT>' + my_catalog_name)(catalog.ident)<EOL><DEDENT>form = getattr(admin_session, '<STR_LIT>' + obj_name + '<STR_LIT>')(new_asset.ident)<EOL>form.set_enclosed_object(new_enclosed_object.ident)<EOL>return getattr(admin_session, '<STR_LIT>' + obj_name)(form)<EOL>
need to clone both the enclosed object + the wrapping asset