def _get_catalog_values(self): # Get the languages site_root = self.get_site_root() languages = site_root.get_property('website_languages') # Titles m_title = {} m_breadcrumb_title = {} for language in languages: value = self.get_property('title', language=language) if value: m_title[language] = value value = self.get_property('breadcrumb_title', language=language) if value: m_breadcrumb_title[language] = value # Data data = self.get_property('data') if data is not None: data = xml_to_text(data) return merge_dicts( super(Category, self)._get_catalog_values(), data=data, # XXX Hack to be on sitemap workflow_state='public', m_title=m_title, m_breadcrumb_title=m_breadcrumb_title)
def encode(cls, value): """Encode to a unicode or a Python value compatible with str(). """ # TODO in 0.70 read datatype from class_schema datatype = cls.datatype # Replace enumerate name by value if issubclass(datatype, Enumerate): value = datatype.get_value(value) if value is None: return '' # Default encoders value_type = type(value) if value_type is XMLParser or value_type is list: return xml_to_text(value) if is_thingy(value, MSG): value = value.gettext() return value
def get_item_value(self, resource, context, item, column, site_root): brain, item_resource = item if isinstance(item_resource, Product) is False: return NeutralWS_RSS.get_item_value(self, resource, context, item, column, site_root) if column == 'description': value = item_resource.get_property('data') if value: value = unicode(xml_to_text(value)) value += u'<br/><br/>' else: value = '' # Add category category = item_resource.parent value += u'Catégorie %s' % category.get_title() return value return NeutralWS_RSS.get_item_value(self, resource, context, item, column, site_root)
def encode(self, resource, column, value, encoding='utf-8'): file_schema = self.get_file_schema(resource) datatype = file_schema[column] data = value # Replace enumerate name by value if issubclass(datatype, Enumerate): data = datatype.get_value(data) if data is None: return '' # Default encoders data_type = type(data) if data_type is XMLParser: return xml_to_text(data) elif data_type is list: return str(data) if isinstance(data, MSG): data = data.gettext() return data
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): """Removes the markup and returns a plain text string. """ return xml_to_text(self.events)
def to_text(self): content = self.get_file('content.xml') return xml_to_text(content)