Changeset 4234
- Timestamp:
- 07/04/2008 12:45:31 PM (2 months ago)
- Files:
-
- trunk/dabo/dApp.py (modified) (5 diffs)
- trunk/dabo/ui/uiwx/__init__.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/dabo/dApp.py
r4226 r4234 222 222 # Form to open if no forms were passed as a parameter 223 223 self.default_form = None 224 # For web-enabled apps, this is the base URL from which the source225 # files wil be retrieved226 self._sourceURL = ""227 224 # Dict of "Last-Modified" values for dynamic web resources 228 225 self._sourceLastModified = {} … … 614 611 615 612 616 def urlFetch(self, pth ):613 def urlFetch(self, pth, errorOnNotFound=False): 617 614 """Fetches the specified resource from the internet using the SourceURL value 618 615 as the base for the resource URL. If a newer version is found, the local copy 619 is updated with the retrieved resource. 616 is updated with the retrieved resource. If the resource isn't found, nothing 617 happens by default. If you want the error to be raised, pass True for the 618 parameter 'errorOnNotFound'. 620 619 """ 621 620 base = self.SourceURL … … 624 623 return 625 624 u2 = urllib2 626 # os.path.join works great for this 627 url = os.path.join(self.SourceURL, pth) 625 # os.path.join works great for this; just make sure that the 626 # pth value doesn't begin with a slash 627 url = os.path.join(self.SourceURL, pth.lstrip("/")) 628 628 req = u2.Request(url) 629 629 lastmod = self._sourceLastModified.get(url) … … 640 640 if code in (304, 404): 641 641 # Not changed or not found; nothing to do 642 if code == 404 and errorOnNotFound: 643 # Re-raise the error 644 raise u2.HTTPError, e 642 645 return 643 646 newFile = resp.read() … … 1330 1333 1331 1334 def _getSourceURL(self): 1332 return self._sourceURL 1335 try: 1336 return self._sourceURL 1337 except AttributeError: 1338 self._sourceURL = "" 1339 return self._sourceURL 1333 1340 1334 1341 def _setSourceURL(self, val): trunk/dabo/ui/uiwx/__init__.py
r4196 r4234 1088 1088 # The srcFile has an absolute path; the URLs work on relative. 1089 1089 try: 1090 splt = srcFile.split(cwd)[1] 1090 splt = srcFile.split(cwd)[1].lstrip("/") 1091 1091 except IndexError: 1092 1092 splt = srcFile 1093 1093 app.urlFetch(splt) 1094 try: 1095 nm, ext = os.path.splitext(splt) 1096 except ValueError: 1097 # No extension; skip it 1098 nm = ext = "" 1099 if ext == ".cdxml": 1100 # There might be an associated code file. If not, the error 1101 # will be caught in the app method, and no harm will be done. 1102 codefile = "%s-code.py" % nm 1103 app.urlFetch(codefile) 1094 1104 # At this point the file should be present and updated. If not... 1095 1105 if not os.path.exists(srcFile):
