Changeset 644
- Timestamp:
- 07/22/03 17:28:08 (5 years ago)
- Files:
-
- trunk/RBFoundation/RBFoundation/XMLBuilder.py (modified) (2 diffs)
- trunk/RBFoundation/RBFoundation/XMLClassBuilder.py (modified) (8 diffs)
- trunk/RBSkinning/RBSkinning/SkinObject.py (modified) (1 diff)
- trunk/RBSkinning/RBSkinning/skin/trylist.py (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/RBFoundation/RBFoundation/XMLBuilder.py
r612 r644 44 44 #~ Classes 45 45 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 46 47 class ElementFactoryError(Exception): 48 pass 46 49 47 50 class XMLBuilderObjectBase(object): … … 88 91 this particular data. The template method makes no restrictions, except that the instance factory 89 92 must be able to accept the same arguments as this method.""" 90 raise KeyError, 'No Class Registered: %s %s' % node93 raise ElementFactoryError('No Class Registered for %r' % (node,)) 91 94 92 95 def _SaveStackState(self, bFull=0): trunk/RBFoundation/RBFoundation/XMLClassBuilder.py
r619 r644 32 32 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 33 33 34 ElementFactoryError = XMLBuilder.ElementFactoryError 35 34 36 class ElementFactory(object): 35 37 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ … … 46 48 47 49 class Raise(object): 48 def __init__(self, exception= KeyError, message=''):50 def __init__(self, exception=ElementFactoryError, message=''): 49 51 self.exception = exception 50 52 self.message = message … … 89 91 PyPath = self.PyPathRoot 90 92 module = __import__(PyPath, globals(), {}, Name) 93 91 94 try: 92 95 return getattr(module, Name) … … 94 97 if self.retryimport: 95 98 module = reload(module) 96 return getattr(module, Name) 97 raise 99 try: return getattr(module, Name) 100 except AttributeError: pass 101 raise ElementFactoryError, 'Could not find "%s" in module %r' % (Name, module) 98 102 99 103 def __call__(self, owner, parent, node, attributes, namespacemap): … … 109 113 self._CachedElementFactories[node] = result 110 114 return result 115 111 116 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 112 117 … … 157 162 158 163 class TryList(object): 159 def __init__(self, trylist, ignoreExceptions=[ ImportError, AttributeError, KeyError]):164 def __init__(self, trylist, ignoreExceptions=[ElementFactoryError, ImportError]):#, AttributeError, KeyError]): 160 165 self._trylist = trylist 161 166 self._ignoreExceptions = tuple(ignoreExceptions) 162 167 163 def __call__(self, *args, **kw):168 def __call__(self, owner, parent, node, attributes, namespacemap): 164 169 for each in self._trylist: 165 170 try: 166 return each( *args, **kw)171 return each(owner, parent, node, attributes, namespacemap) 167 172 except self._ignoreExceptions: 168 173 pass 174 175 raise ElementFactoryError('No suitable element factory for node %r' % (node,)) 169 176 170 177 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ … … 184 191 self._CachedElementFactories[node] = result 185 192 return result 186 except self._ignoreExceptions :193 except self._ignoreExceptions, e: 187 194 pass 195 196 raise ElementFactoryError('No suitable element factory for node %r' % (node,)) 188 197 189 198 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ … … 244 253 return self.NextFactorySet._GetElementFactory(*args, **kw) 245 254 246 raise KeyError, "Could not find a class to build for node %r" % (node,)255 raise ElementFactoryError("Could not find a class to build for node %r" % (node,)) 247 256 248 257 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ trunk/RBSkinning/RBSkinning/SkinObject.py
r606 r644 234 234 variables['self'] = weakref.proxy(self) 235 235 variables['ctx'] = variables['context'] = weakref.proxy(self.context) 236 if self.parent(): 237 variables['parentObj'] = self.parent().object 236 parent = self.parent() 237 if parent: 238 variables['parent'] = parent 239 variables['parentObj'] = parent.object 238 240 return variables 239 241 trunk/RBSkinning/RBSkinning/skin/trylist.py
r545 r644 24 24 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 25 25 26 from RBFoundation.XMLBuilder import ElementFactoryError 26 27 from RBSkinning.SkinObject import SkinObject 27 28 from RBSkinning.UtilitySkinElements import StoreXML, RestoreStoredXMLMixin … … 39 40 default_settings = SkinObject.default_settings.copy() 40 41 #default_settings.update({ 41 # 'catch': '(ImportError, )'42 # 'catch': '(ImportError, ElementFactoryError)' 42 43 # }) 43 44 44 45 ElementFactories = TemplateElementFactorySet 45 DefaultCatchlist = (ImportError, NameError,LookupError,AttributeError)46 DefaultCatchlist = (ImportError, ElementFactoryError) 46 47 47 48 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ … … 60 61 61 62 try: 62 catchtuple = self.EvalLocal(self.settings['catch'] )63 catchtuple = self.EvalLocal(self.settings['catch'], ElementFactoryError=ElementFactoryError) 63 64 except (KeyError, IndexError): 64 65 catchtuple = self.DefaultCatchlist
