def update_links(self, source, target): OrderedTable.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) # languages site_root = self.get_site_root() available_languages = site_root.get_property('website_languages') # Append links contained in data handler = self.handler get_value = handler.get_record_value for record in handler.get_records_in_order(): for language in available_languages: data = get_value(record, 'data', language=language) if data is None: continue events = _change_link(source, target, old_base, new_base, data) events = list(events) p_events = Property(events, language=language) # TODO Update all language in one time self.update_record(record.id, **{'data': p_events}) get_context().database.change_resource(self)
def _make_resource(cls, folder, name, *args, **kw): OrderedTable._make_resource(cls, folder, name) table = BaseCountriesZones() zones = [] csv = ro_database.get_handler(get_abspath('data/countries.csv'), CSVFile) for line in csv.get_rows(): zone = unicode(line[1], 'utf-8') if zone not in zones: zones.append(zone) table.add_record({'title': Property(zone, language='fr')}) folder.set_handler(name, table)
def get_links(self): links = OrderedTable.get_links(self) base = self.get_canonical_path() # languages site_root = self.get_site_root() available_languages = site_root.get_property('website_languages') # Append links contained in data handler = self.handler get_value = handler.get_record_value for record in handler.get_records_in_order(): for language in available_languages: data = get_value(record, 'data', language=language) if data is None: continue links.update(_get_links(base, data)) return links
def get_metadata_schema(cls): return merge_dicts(OrderedTable.get_metadata_schema(), cls.edit_schema)