View Single Post
Old 07-08-2014, 05:55 PM   #1
DaltonST
Deviser
DaltonST ought to be getting tired of karma fortunes by now.DaltonST ought to be getting tired of karma fortunes by now.DaltonST ought to be getting tired of karma fortunes by now.DaltonST ought to be getting tired of karma fortunes by now.DaltonST ought to be getting tired of karma fortunes by now.DaltonST ought to be getting tired of karma fortunes by now.DaltonST ought to be getting tired of karma fortunes by now.DaltonST ought to be getting tired of karma fortunes by now.DaltonST ought to be getting tired of karma fortunes by now.DaltonST ought to be getting tired of karma fortunes by now.DaltonST ought to be getting tired of karma fortunes by now.
 
DaltonST's Avatar
 
Posts: 2,265
Karma: 2090983
Join Date: Aug 2013
Location: Texas
Device: none
Metadata(_('Unknown')) : How To Dynamically Add Custom Columns To Definition

The plugin code fragment below is for updating a custom column "genre". However, Metadata(_('Unknown')) does not show that custom column being available for updating, as shown below.

id_map = {}
for line in book_new_genre_list:
s = line.split("$")
s_book = s[0]
s_genre = s[1]
n_book = int(s_book)
mi = Metadata(_('Unknown')) << So Only Updates Custom Column
i = n_book
mi.genre= s_genre << This does nothing
for item in mi:
print(str(item)) <<<<Output Shown Below
id_map[i] = mi

(output from print above)
author_link_map
author_sort
cover_data
tags
user_categories
identifiers
author_sort_map
languages
user_metadata
authors
title
device_collections

edit_metadata_action = self.gui.iactions['Edit Metadata']

edit_metadata_action.apply_metadata_changes(id_map ,
callback=self._finish_displaying_results(payload))

Besides the unsuccessful "mi.genre" test, I also tried appending the new custom column, and even treating mi like a dictionary with a key = custom column name. Nothing works.

Question: how does one add a custom column value to Metadata(_('Unknown')) "on the fly" so that the id_map is properly constructed?

Thank you in advance for sharing your knowledge.
DaltonST is offline   Reply With Quote