Changeset 673
- Timestamp:
- 08/25/03 17:42:52 (5 years ago)
- Files:
-
- trunk/RBSkinning/RBSkinning/XMLSkinner.py (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/RBSkinning/RBSkinning/XMLSkinner.py
r528 r673 41 41 42 42 DefaultContext = None 43 rootPath = '' 43 44 44 45 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ … … 46 47 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 47 48 48 def __init__(self, mapSupportedSkinNamespaces={}, rootPath=''): 49 self.rootPath = rootPath 49 def __init__(self, mapSupportedSkinNamespaces={}, rootPath=None): 50 if self.rootPath is not None: 51 self.rootPath = rootPath 50 52 XMLClassBuilder.__init__(self) 51 53 self.AddElementFactories(mapSupportedSkinNamespaces) … … 62 64 63 65 def SkinXML(self, xml, contextIn=None, **kwAddedContext): 64 rootPath = self. rootPath or os.getcwd()66 rootPath = self._GetRootPath(kwAddedContext) 65 67 self._elements, self._LastCompleteElement = [], None 66 68 parser = self._CreateParser() … … 85 87 file = os.path.abspath(file) 86 88 file = open(file, 'r') 87 else: rootPath = kwAddedContext.get('__root__', None) or self.rootPath or os.getcwd() 89 else: 90 rootPath = self._GetRootPath(kwAddedContext) 88 91 89 92 self._elements, self._LastCompleteElement = [], None … … 105 108 106 109 def GraftXML(self, GraftElements, xml, **kwAddedContext): 107 rootPath = self. rootPath or os.getcwd()110 rootPath = self._GetRootPath(kwAddedContext) 108 111 self._elements, self._LastCompleteElement = GraftElements, GraftElements[-1] 109 112 … … 132 135 file = os.path.abspath(file) 133 136 file = open(file, 'r') 134 else: rootPath = kwAddedContext.get('__root__', None) or self.rootPath or os.getcwd() 137 else: 138 rootPath = self._GetRootPath(kwAddedContext) 135 139 136 140 self._elements, self._LastCompleteElement = GraftElements, GraftElements[-1] … … 162 166 element.context.__skinner__ = weakref.ref(self) 163 167 element.context._update(kwAddedContext) 168 rootPath = self._GetRootPath(kwAddedContext) 169 if rootPath: element.context.__root__ = rootPath 164 170 165 171 self._do_parse(parser.Parse, xml) … … 176 182 file = os.path.abspath(file) 177 183 file = open(file, 'r') 178 else: rootPath = ''184 else: self._GetRootPath(kwAddedContext) 179 185 180 186 parser = self._CreateParser() … … 186 192 187 193 return self._LastCompleteElement 194 195 def _GetRootPath(self, context, default=None): 196 if default is None: 197 result = context.get('__root__', None) or self.rootPath or os.getcwd() 198 else: 199 result = context.get('__root__', default) 200 return result 201
