1# Copyright (c) 2004-2006 The Regents of The University of Michigan 2# All rights reserved. 3# 4# Redistribution and use in source and binary forms, with or without 5# modification, are permitted provided that the following conditions are 6# met: redistributions of source code must retain the above copyright 7# notice, this list of conditions and the following disclaimer; 8# redistributions in binary form must reproduce the above copyright --- 68 unchanged lines hidden (view full) --- 77 def unproxy(self, base): 78 obj = base 79 done = False 80 81 if self._search_self: 82 result, done = self.find(obj) 83 84 if self._search_up: |
85 # Search up the tree but mark ourself 86 # as visited to avoid a self-reference 87 self._visited = True 88 obj._visited = True |
89 while not done: 90 obj = obj._parent 91 if not obj: 92 break 93 result, done = self.find(obj) 94 |
95 self._visited = False 96 base._visited = False 97 |
98 if not done: 99 raise AttributeError, \ 100 "Can't resolve proxy '%s' of type '%s' from '%s'" % \ 101 (self.path(), self._pdesc.ptype_str, base.path()) 102 103 if isinstance(result, BaseProxy): 104 if result == self: 105 raise RuntimeError, "Cycle in unproxy" --- 47 unchanged lines hidden (view full) --- 153 raise AttributeError, "Index operation on bound proxy" 154 new_self = copy.deepcopy(self) 155 new_self._modifiers.append(key) 156 return new_self 157 158 def find(self, obj): 159 try: 160 val = getattr(obj, self._attr) |
161 visited = False 162 if hasattr(val, '_visited'): 163 visited = getattr(val, '_visited') 164 165 if not visited: 166 # for any additional unproxying to be done, pass the 167 # current, rather than the original object so that proxy 168 # has the right context 169 obj = val 170 else: 171 return None, False |
172 except: 173 return None, False 174 while isproxy(val): 175 val = val.unproxy(obj) 176 for m in self._modifiers: 177 if isinstance(m, str): 178 val = getattr(val, m) 179 elif isinstance(m, int): --- 67 unchanged lines hidden --- |