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): 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) site_root = self.get_site_root() languages = site_root.get_property('website_languages') links = [] for key, datatype in self.get_metadata_schema().items(): multilingual = getattr(datatype, 'multilingual', False) langs = languages if multilingual is True else [None] if issubclass(datatype, XHTMLBody): for lang in langs: events = self.get_property(key, language=lang) if not events: continue events = _change_link(source, target, old_base, new_base, events) events = list(events) self.set_property(key, events, language=lang) elif issubclass(datatype, PathDataType): # Relative path for lang in langs: path = self.get_property(key, language=lang) if path is None: continue path = str(old_base.resolve2(path)) if path == source: # Hit the old name new_path = str(new_base.get_pathto(target)) self.set_property(key, new_path, language=lang) elif issubclass(datatype, AbsolutePathDataTypeEnumerate): # Absolute path for lang in langs: path = self.get_property(key, language=lang) if path is None: continue path = str(path) path = resources_new2old.get(path, path) if path == source: # Hit the old name self.set_property(key, str(target), language=lang) # Tagaware ? if isinstance(self, TagsAware): TagsAware.update_links(self, source, target) # Change resource get_context().database.change_resource(self)
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 get_links(self): links = Folder.get_links(self) # General informations base = self.get_canonical_path() site_root = self.get_site_root() languages = site_root.get_property('website_languages') # We update XHTMLBody links for key, datatype in self.get_metadata_schema().items(): multilingual = getattr(datatype, 'multilingual', False) langs = languages if multilingual is True else [None] if issubclass(datatype, XHTMLBody): for lang in langs: events = self.get_property(key, language=lang) if not events: continue links.extend(_get_links(base, events)) elif issubclass(datatype, PathDataType): # Relative path for lang in langs: path = self.get_property(key, language=lang) if path is None: continue links.append(str(base.resolve2(path))) elif issubclass(datatype, AbsolutePathDataTypeEnumerate): # Absolute path for lang in langs: path = self.get_property(key, language=lang) if path is None: continue links.append(str(path)) # Tagaware ? if isinstance(self, TagsAware): links.extend(TagsAware.get_links(self)) return links
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 _get_catalog_values(self): values = merge_dicts(DynamicFolder._get_catalog_values(self), TagsAware._get_catalog_values(self), self._get_dynamic_catalog_values()) # Data data = self.get_property('data') if data is not None: data = xml_to_text(data) values['data'] = data # Reference values['reference'] = self.get_property('reference') # Manufacturer values['manufacturer'] = str(self.get_property('manufacturer')) # Supplier values['supplier'] = str(self.get_property('supplier')) # Stock quantity values['stock_quantity'] = self.get_property('stock-quantity') # Product models values['product_model'] = str(self.get_property('product_model')) # Images order = self.get_resource('order-photos', soft=True) if order: ordered_names = list(order.get_ordered_names()) values['has_images'] = (len(ordered_names) != 0) else: values['has_images'] = False # Price # XXX We can't sort decimal, so transform to int values['stored_price'] = int(self.get_price_with_tax() * 100) values['stored_weight'] = int(self.get_weight() * 100) # Price values['ht_price'] = self.get_price_without_tax() values['ttc_price'] = self.get_price_with_tax() # Creation time values['ctime'] = self.get_property('ctime') # Publication date values['pub_datetime'] = self.get_property('pub_datetime') # Promotion values['has_reduction'] = self.get_property('has_reduction') # not_buyable_by_groups values['not_buyable_by_groups'] = self.get_property( 'not_buyable_by_groups') return values
def _get_catalog_values(self): values = merge_dicts(DynamicFolder._get_catalog_values(self), TagsAware._get_catalog_values(self), self._get_dynamic_catalog_values()) # Data data = self.get_property('data') if data is not None: data = xml_to_text(data) values['data'] = data # Reference values['reference'] = self.get_property('reference') # Manufacturer values['manufacturer'] = str(self.get_property('manufacturer')) # Supplier values['supplier'] = str(self.get_property('supplier')) # Stock quantity values['stock_quantity'] = self.get_property('stock-quantity') # Product models values['product_model'] = str(self.get_property('product_model')) # Images order = self.get_resource('order-photos', soft=True) if order: ordered_names = list(order.get_ordered_names()) values['has_images'] = (len(ordered_names) != 0) else: values['has_images'] = False # Price # XXX We can't sort decimal, so transform to int values['stored_price'] = int(self.get_price_with_tax() * 100) values['stored_weight'] = int(self.get_weight() * 100) # Price values['ht_price'] = self.get_price_without_tax() values['ttc_price'] = self.get_price_with_tax() # Creation time values['ctime'] = self.get_property('ctime') # Publication date values['pub_datetime'] = self.get_property('pub_datetime') # Promotion values['has_reduction'] = self.get_property('has_reduction') # not_buyable_by_groups values['not_buyable_by_groups'] = self.get_property('not_buyable_by_groups') return values
def to_text(self): return TagsAware.to_text(self)
def get_catalog_values(self): return merge_dicts(ResourcesOrderedContainer.get_catalog_values(self), TagsAware.get_catalog_values(self), SideBarAware.get_catalog_values(self), ContentBarAware.get_catalog_values(self))
def get_catalog_values(self): return merge_dicts( Folder.get_catalog_values(self), TagsAware.get_catalog_values(self), sprite16=self.class_sprite16)