Ok, fair enough this explains the behavior and that is ok for me...
I could make the Option work, but I am still not to sure I understand... I did copy it from other source plugin without really understanding. All options do work like I expected...
Code:
options = (
Option(
'priority_handling',
'choices',
'1le_plus_ancien_avec_un_isbn',
_('priorité de tri:'),
_("Comment pousser la priorité d'un volume, si plusieurs existent."),
choices=PRIORITY_HANDLING
),
Option(
'fat_publisher',
'bool',
False,
_("Ajoute collection et son numéro d'ordre au champ èditeur"),
_("Cochez cette case pour ajouter la collection et son numéro d'ordre au champs de l'éditeur.")
),
Option(
'debug_level',
'number',
0,
_('Loquacité du journal, de 0 à 7'),
_('Le niveau de loquacité. O un minimum de rapport, 1 rapport etendu de __init__,'
' 2 rapport étendu de worker, 4 rapport etendu des annexes... La somme 3, 5 ou 7'
' peut etre introduite. Ainsi 7 donne un maximun de rapport. Note: ce sont les 3'
' derniers bits de debug_level en notation binaire')
),
)
@property
def priority_handling(self):
x = getattr(self, 'prio_handling', None)
if x is not None:
return x
prio_handling = self.prefs['priority_handling']
if prio_handling not in self.PRIORITY_HANDLING:
prio_handling = self.PRIORITY_HANDLING[0]
return prio_handling
@property
def extended_publisher(self):
x = getattr(self, 'ext_pub', None)
if x is not None:
return x
ext_pub = self.prefs.get('fat_publisher', False)
return ext_pub
@property
def dbg_lvl(self):
x = getattr(self, 'dl', None)
if x is not None:
return x
dl = self.prefs.get('debug_level', False)
return dl
May I assume that priority_handling, fat_publisher and debug_level as I define it in the option are in fact variables somewhere in calibre that will be remembered across restart?
Then may I assume that self.prefs and self.prefs.get are 2 versions of the same code? What is the role of the @property decorator in the case of self.prefs.get??
Not that this will make my code better, but I really would like to understand what I am doing (blindly)
Again, thanks in advance.