def update_relative_links(self, source): Folder.update_relative_links(self, source) TagsAware.update_relative_links(self, source) target = self.get_canonical_path() resources_old2new = get_context().database.resources_old2new # metadata schema = self.class_schema for key, datatype in schema.iteritems(): if issubclass(datatype, PathDataType) is False: continue value = self.get_property(key) if not value: continue ref = get_reference(value) if ref.scheme: continue path, view = get_path_and_view(ref.path) # Calcul the old absolute path old_abs_path = source.resolve2(path) # Check if the target path has not been moved new_abs_path = resources_old2new.get(old_abs_path, old_abs_path) # Build the new path with the right path # Absolute path allow to call get_pathto with the target new_path = str(target.get_pathto(new_abs_path)) + view # Update the property self.set_property(key, Path(new_path)) # comments comments = self.metadata.get_property('comment') or [] for comment in comments: # XXX hardcoded, not typed for key in ('attachment',): value = comment.get_parameter(key) if not value: continue ref = get_reference(value) if ref.scheme: continue path, view = get_path_and_view(ref.path) # Calcul the old absolute path old_abs_path = source.resolve2(path) # Check if the target path has not been moved new_abs_path = resources_old2new.get(old_abs_path, old_abs_path) # Build the new path with the right path # Absolute path allow to call get_pathto with the target new_path = str(target.get_pathto(new_abs_path)) + view # Update the record comment.set_parameter(key, new_path) self.set_property('comment', comments)