def get_links(self): links = RoleAware.get_links(self) | TagsAware.get_links(self) base = self.get_canonical_path() # 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) links.add(str(base.resolve2(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) links.add(str(base.resolve2(path))) return links
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)
def update_links(self, source, target): Folder.update_links(self, source, target) TagsAware.update_links(self, source, target) base = self.get_canonical_path() resources_new2old = get_context().database.resources_new2old base = str(base) old_base = resources_new2old.get(base, base) old_base = Path(old_base) new_base = Path(base) # 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) path = str(old_base.resolve2(path)) if path == source: # Hit the old name # Build the new path with the right path new_path = str(new_base.get_pathto(target)) + view 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) path = str(old_base.resolve2(path)) if path == source: # Hit the old name # Build the new path with the right path new_path = str(new_base.get_pathto(target)) + view comment.set_parameter(key, new_path) self.set_property('comment', comments)
def my_func(value): # Absolute URI or path uri = get_reference(value) if uri.scheme or uri.authority or uri.path.is_absolute(): return value path = uri.path if not path or path.is_absolute() and path[0] == 'ui': return value # Strip the view path, view = get_path_and_view(path) # Resolve Path # Calcul the old absolute path old_abs_path = source.resolve2(path) # Get the 'new' absolute parth new_abs_path = resources_old2new.get(old_abs_path, old_abs_path) path = str(target.get_pathto(new_abs_path)) + view value = Reference('', '', path, uri.query.copy(), uri.fragment) return str(value)