IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Python Discussion :

AttributeError: 'FamilyGroupOptions' object has no attribute 'ok_column31'


Sujet :

Python

  1. #1
    Futur Membre du Club
    Homme Profil pro
    retraité en informatique
    Inscrit en
    Novembre 2013
    Messages
    6
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Lot (Midi Pyrénées)

    Informations professionnelles :
    Activité : retraité en informatique
    Secteur : High Tech - Opérateur de télécommunications

    Informations forums :
    Inscription : Novembre 2013
    Messages : 6
    Points : 5
    Points
    5
    Par défaut AttributeError: 'FamilyGroupOptions' object has no attribute 'ok_column31'
    Bon, tout d'abord, je suis bien sur débutant.

    J'ai le message d'erreur (titre du post)
    J'ai un fichier xml qui comporte les options d'un plugin (de Gramps, pour la petite histoire).
    en voici un extrait:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
      <item name="family_group" trans_name="Fiche familiale">
      <option name="add_path" type="unicode" value=""/>
    
      <option name="add_column32" type="int" value="40"/>
      <option name="add_column31" type="int" value="40"/>
    ...
      <option name="add_missing" type="bool" value="True"/>
      <option name="add_test" type="bool" value="False"/>
    ...
      <option name="add_photo" type="bool" value="True"/>
      <option name="add_column42" type="int" value="35"/>
      <option name="add_column43" type="int" value="40"/>
      <option name="add_column41" type="int" value="18"/>
    ...
      </item>
    J'ai ensuite une classe avec plusieurs fonctions:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    import gen.lib
    from gen.plug.menu import (BooleanOption, NumberOption, TextOption, FamilyOption, EnumeratedListOption)
    from gen.plug.report import Report
    from gen.plug.report import utils as ReportUtils
    from gen.plug.report import MenuReportOptions
    from gen.plug.docgen import (IndexMark, FontStyle, ParagraphStyle, TableStyle,
                                TableCellStyle, FONT_SANS_SERIF, FONT_SERIF, 
                                INDEX_TYPE_TOC, PARA_ALIGN_CENTER)
    import DateHandler
    from gen.ggettext import sgettext as _
    from gen.display.name import displayer as global_name_display
    
    #------------------------------------------------------------------------
    #
    # FamilyGroup
    #
    #------------------------------------------------------------------------
    class FamilyGroup(Report):
    
        def __init__(self, database, options, user):
            """
            Create the DetAncestorReport object that produces the report.
            
            The arguments are:
    
            database        - the GRAMPS database instance
            options         - instance of the Options class for this report
            user            - a gen.user.User() instance
    
            This report needs the following parameters (class variables)
            that come in the options class.
            
            family_handle - Handle of the family to write report on.
            includeAttrs  - Whether to include attributes
            name_format   - Preferred format to display names
            """
            Report.__init__(self, database, options, user)
            menu = options.menu
    
            self.family_handle = None
    
            family_id = menu.get_option_by_name('family_id').get_value()
            family = database.get_family_from_gramps_id(family_id)
            if family:
                self.family_handle = family.get_handle()
            else:
                self.family_handle = None
    
            # Copy the global NameDisplay so that we don't change application 
            # defaults.
            self._name_display = copy.deepcopy(global_name_display)
            name_format = menu.get_option_by_name("name_format").get_value()
            if name_format != 0:
                self._name_display.set_default_format(name_format)
    
            get_option_by_name = menu.get_option_by_name
            get_value = lambda name:get_option_by_name(name).get_value()        
      ...
            self.ok_photo      = get_value('add_photo')
            self.ok_missing    = get_value('add_missing')
            self.ok_test       = get_value('add_test')
            self.ok_path       = get_value('add_path')
    
            self.ok_column31   = int(get_value('add_column31'))
            self.ok_column32   = int(get_value('add_column32'))
            self.ok_column41   = get_value('add_column41')
            self.ok_column42   = get_value('add_column42')
            self.ok_column43   = get_value('add_column43')
    
    #------------------------------------------------------------------------
    #
    # MenuReportOptions
    #
    #------------------------------------------------------------------------
    class FamilyGroupOptions(MenuReportOptions):
    
        """
        Defines options and provides handling interface.
        """
    
        def __init__(self, name, dbase):
            MenuReportOptions.__init__(self, name, dbase)
            
        def add_menu_options(self, menu):
    ...
            ##########################
            add_option = partial(menu.add_option, _("Photos"))
            ##########################
                    
            add_photo = BooleanOption(_("Add photos to parents and childs "),False)
            add_photo.set_help(_("Add photos to parents and childs "))
            add_option("add_photo", add_photo)
    
            add_missing = BooleanOption(_("Add default photos when missing "),True)
            add_missing.set_help(_("Add default photos when missing "))
            add_option("add_missing", add_missing)
    
            add_test = BooleanOption(_("Add personID for test "),False)
            add_test.set_help(_("Add personID to test if photo names are ok"))
            add_option("add_test", add_test)
    
            add_path = TextOption(_("Photos path "),"")
            add_path.set_help(_("The path where to find book photos. If empty, uses MediaPath "))
            add_option("add_path", add_path)
    
    
           add_column31 = NumberOption(_('Parent 2st tab Width (date)'), 40, 15, 40)
           add_column31.set_help(_("Set the width of the second column (line date tab) in parent table. "))
           menu.add_option("Photos", 'add_column31', add_column31)
    
           add_column32 = NumberOption(_('Parent 3rd tab Width (place)'), 40, 40, 65)
           add_column32.set_help(_("Set the width of the third column (line place tab) in parent table. "))
           menu.add_option("Photos", 'add_column32', add_column32)
    
           add_column41 = NumberOption(_('Child 2st tab Width (title)'), 18, 10, 18)
           add_column41.set_help(_("Set the width of the second column (line title tab) in child table. "))
           menu.add_option("Photos", 'add_column41', add_column41)
    
           add_column42 = NumberOption(_('Child 3rd tab Width (date)'), 35, 15, 40)
           add_column42.set_help(_("Set the width of the third column (line date tab) in child table. "))
           menu.add_option("Photos", 'add_column42', add_column42)
    
           add_column43 = NumberOption(_('Child 4th tab Width (place)'), 40, 40, 65)
           add_column43.set_help(_("Set the width of the fourth column (line place tab) in child table. "))
           menu.add_option("Photos", 'add_column43', add_column43)
    ...
        def make_default_style(self,default_style):
            """Make default output style for the Family Group Report."""
    ...
            table = TableStyle()
            table.set_width(100)
            table.set_columns(3)
            table.set_column_width(0,20)
    
    #      table.set_column_width(1,27)
           table.set_column_width(1,self.ok_column31)
    #      table.set_column_width(2,53)
           table.set_column_width(2,self.ok_column32)
            default_style.add_table_style('FGR-ParentTable',table)
    
            table = TableStyle()
            table.set_width(100)
            table.set_columns(4)
            table.set_column_width(0,7)
            table.set_column_width(1,13)
    
    #      table.set_column_width(1,self.ok_column41)
           table.set_column_width(2,27)
    #      table.set_column_width(1,self.ok_column42)
           table.set_column_width(3,53)
    #      table.set_column_width(1,self.ok_column43)
            default_style.add_table_style('FGR-ChildTable',table)
    Le problème n'est pas du à l'indentation, ici généré par le flag bold.

    si les lignes utilisant self.ok_columnxx sont commentées et que je remplace par les valeurs, çà fonctionne correctement
    si je tente d'utiliser les self.ok_columnxx, j'ai le message d'erreur.

    Etant que le choix des options fonctionne, il semblerait que le système fonctionne, mais des que j'essaye de les utiliser, patatrac ...

    Si quelqu'un a une idée de pourquoi je me plante ...

    Merci
    A+

  2. #2
    Futur Membre du Club
    Homme Profil pro
    retraité en informatique
    Inscrit en
    Novembre 2013
    Messages
    6
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Lot (Midi Pyrénées)

    Informations professionnelles :
    Activité : retraité en informatique
    Secteur : High Tech - Opérateur de télécommunications

    Informations forums :
    Inscription : Novembre 2013
    Messages : 6
    Points : 5
    Points
    5
    Par défaut
    Citation Envoyé par JujuLand Voir le message

    self.ok_column31 = int(get_value('add_column31'))
    self.ok_column32 = int(get_value('add_column32'))
    self.ok_column41 = get_value('add_column41')
    self.ok_column42 = get_value('add_column42')
    self.ok_column43 = get_value('add_column43')
    Je précise, que j'utilisais int(get_value())... qui semble être une erreur, mais qu'auparavant, j'utilisais get_value() sans le int()

    A+

  3. #3
    Expert éminent sénior
    Homme Profil pro
    Architecte technique retraité
    Inscrit en
    Juin 2008
    Messages
    21 287
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Manche (Basse Normandie)

    Informations professionnelles :
    Activité : Architecte technique retraité
    Secteur : Industrie

    Informations forums :
    Inscription : Juin 2008
    Messages : 21 287
    Points : 36 776
    Points
    36 776
    Par défaut
    Salut,


    Un attribut comme ok_column31 devrait être définit dans FamilyGroup(Report)/__init__ (à la ligne 64).
    Si ce n'est pas le cas, c'est qu'on ne passe pas par cette ligne.

    Comme il est impossible de faire fonctionner votre code, il ne vous reste plus qu'à lancer le debuggeur symbolique et vous assurer qu'on passe bien par les instructions attendues.

    - W
    Architectures post-modernes.
    Python sur DVP c'est aussi des FAQs, des cours et tutoriels

Discussions similaires

  1. AttributeError "nonetype" object has no attribute
    Par Invité dans le forum Général Python
    Réponses: 2
    Dernier message: 14/12/2010, 20h49
  2. Selenium - AttributeError: 'module' object has no attribute
    Par bender1979 dans le forum Général Python
    Réponses: 4
    Dernier message: 09/11/2010, 22h03
  3. Probleme : AttributeError: 'tuple' object has no attribute
    Par MrGecko dans le forum Général Python
    Réponses: 1
    Dernier message: 27/05/2007, 09h59
  4. Réponses: 2
    Dernier message: 26/05/2006, 14h48

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo