~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/lazy_import.py

  • Committer: John Arbash Meinel
  • Date: 2007-04-12 20:27:42 UTC
  • mto: (2399.1.15 doc-cleanup)
  • mto: This revision was merged to the branch mainline in revision 2431.
  • Revision ID: john@arbash-meinel.com-20070412202742-4cr2qmchdfe9mg7n
Cherrypick just the epydoc builder changes.
This is just the piece of change that makes 'make api-docs' work,
without any actual documentation changes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
48
48
    needed.
49
49
    """
50
50
 
51
 
    __slots__ = ('_scope', '_factory', '_name')
 
51
    __slots__ = ('_scope', '_factory', '_name', '_real_obj')
 
52
 
 
53
    # Setting this to True will allow you to do x = y, and still access members
 
54
    # from both variables. This should not normally be enabled, but is useful
 
55
    # when building documentation.
 
56
    _should_proxy = False
52
57
 
53
58
    def __init__(self, scope, factory, name):
54
59
        """Create a temporary object in the specified scope.
62
67
        self._scope = scope
63
68
        self._factory = factory
64
69
        self._name = name
 
70
        self._real_obj = None
65
71
        scope[name] = self
66
72
 
67
73
    def _replace(self):
81
87
                          " to another variable?",
82
88
                extra=e)
83
89
        obj = factory(self, scope, name)
 
90
        if ScopeReplacer._should_proxy:
 
91
            self._real_obj = obj
84
92
        scope[name] = obj
85
93
        return obj
86
94
 
92
100
        # del self._name
93
101
 
94
102
    def __getattribute__(self, attr):
95
 
        _replace = object.__getattribute__(self, '_replace')
96
 
        obj = _replace()
97
 
        _cleanup = object.__getattribute__(self, '_cleanup')
98
 
        _cleanup()
 
103
        obj = object.__getattribute__(self, '_real_obj')
 
104
        if obj is None:
 
105
            _replace = object.__getattribute__(self, '_replace')
 
106
            obj = _replace()
 
107
            _cleanup = object.__getattribute__(self, '_cleanup')
 
108
            _cleanup()
99
109
        return getattr(obj, attr)
100
110
 
101
111
    def __call__(self, *args, **kwargs):