def add_catalog_index(node, d): for k in d: v = d[k] if isinstance(v, dict): def to_xml(o): xml = '' if isinstance(o, list): for i in o: xml += '<%s>' % i['__nodeName__'] xml += to_xml(i) xml += '</%s>' % i['__nodeName__'] elif isinstance(o, dict): for k in [x for x in o if x != '__nodeName__']: xml += '<%s>' % k xml += to_xml(o[k]) xml += '</%s>' % k else: xml = str(o) return xml d[k] = '<![CDATA[<%s>%s</%s>]]>' % (k, to_xml(v), k) lang = node.REQUEST.get('lang') d['id'] = '%s_%s' % (d['id'], lang) d['lang'] = lang for attr_id in self.getAttrIds(): attr_type = self.getAttrs().get(attr_id, {}).get('type', 'string') value = '' try: value = node.attr(attr_id) except: msg = '[@%s.get_sitemap]: can\'t get attr \'%s.%s\' - see error-log for details' % ( node.getHome().id, node.meta_id, attr_id) standard.writeError(self, msg) if msg not in result: result.append(msg) if attr_type in ['date', 'datetime']: value = self.getLangFmtDate(value, 'eng', 'ISO8601') elif type(value) in (dict, list): value = standard.str_item(value, f=True) print(value) value = str(value) d[attr_id] = remove_tags(self, value) cb(node, d)
def str_item(self, i): warn(self, 'str_item', 'Products.zms.standard.str_item') return standard.str_item(i)