Changeset 1306

Show
Ignore:
Timestamp:
05/23/07 04:25:16 (2 years ago)
Author:
arj..@yirdis.nl
Message:

Make buil_action_group() work better and prevent vague exceptions from being thrown due to services being initialized too early.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • gaphor/trunk/gaphor/action.py

    r1282 r1306  
    9797    import gtk 
    9898    group = gtk.ActionGroup(name or obj) 
     99    objtype = type(obj) 
    99100 
    100101    for attrname in dir(obj): 
    101102        try: 
    102             method = getattr(obj, attrname) 
     103            # Fetch the methods from the object's type instead of the object 
     104            # itself. This prevents some desciptors (mainly gaphor.core.inject) 
     105            # from executing. 
     106            # Otherwise stuff like dependency resolving (=inject) may kick in 
     107            # too early. 
     108            method = getattr(objtype, attrname) 
    103109        except: 
    104110            continue 
  • gaphor/trunk/gaphor/core.py

    r1264 r1306  
    2727         
    2828    def __get__(self, obj, class_=None): 
     29        """ 
     30        Resolve a dependency, but only if we're called from an object instance. 
     31        """ 
     32        if not obj: 
     33            return self 
    2934        if self._inj is None: 
    3035            self._inj = _Application.get_service(self._name) 
  • gaphor/trunk/gaphor/ui/mainwindow.py

    r1301 r1306  
    3434    action_manager = inject('action_manager') 
    3535 
    36     # <old> 
    37 #            _('_Edit'), ( 
    38 #                'Undo', 
    39 #                'Redo', 
    40 #                'separator', 
    41 #                'EditCopy', 
    42 #                'EditPaste', 
    43 #                'separator', 
    44 #                'ResetToolAfterCreate', 
    45  
    46     # </old> 
    47  
    4836    title = 'Gaphor' 
    4937    size = property(lambda s: s.properties.get('ui.window-size', (760, 580))) 
     
    5644          <menu action="file"> 
    5745            <placeholder name="primary" /> 
     46            <separator /> 
     47            <menu action="file-export" /> 
     48            <menu action="file-import" /> 
     49            <separator /> 
    5850            <placeholder name="secondary" /> 
    5951            <placeholder name="ternary" /> 
     
    116108        self.action_group = build_action_group(self) 
    117109        for name, label in (('file', '_File'), 
     110                             ('file-export', '_Export'), 
     111                             ('file-import', '_Import'), 
    118112                             ('edit', '_Edit'), 
    119113                             ('diagram', '_Diagram'),