Changeset 1503
- Timestamp:
- 07/22/08 21:11:32 (7 weeks ago)
- Location:
- trunk/peppy
- Files:
-
- 3 modified
-
buffers.py (modified) (8 diffs)
-
frame.py (modified) (4 diffs)
-
hsi/loader.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/peppy/buffers.py
r1501 r1503 164 164 165 165 """ 166 def __init__(self, url, created_from_url=None ):166 def __init__(self, url, created_from_url=None, canonicalize=True): 167 167 """Initialize the mixin. 168 168 … … 173 173 for a local filesystem working directory if a working directory can't 174 174 be determined from the real url. 175 176 @param canonicalize: whether or not the url should be canonicalized 177 before storing in the buffer list. 175 178 """ 176 179 self.bfh = None 177 180 self.last_mtime = None 181 self.canonicalize = canonicalize 178 182 self.setURL(url) 179 183 self.created_from_url = created_from_url … … 184 188 if not url: 185 189 url = vfs.normalize("untitled") 186 el se:190 elif self.canonicalize: 187 191 url = vfs.canonical_reference(url) 192 else: 193 url = vfs.normalize(url) 188 194 self.url = url 189 195 self.saveTimestamp() 190 196 191 197 def isURL(self, url): 192 url = vfs.canonical_reference(url) 198 if self.canonicalize: 199 url = vfs.canonical_reference(url) 200 else: 201 url = vfs.normalize(url) 193 202 if url == self.url: 194 203 return True … … 393 402 394 403 if not self.permanent: 395 basename=self.stc.getShortDisplayName(self. url)404 basename=self.stc.getShortDisplayName(self.raw_url) 396 405 397 406 BufferList.removeBuffer(self) … … 408 417 409 418 def isBasename(self, basename): 410 return basename == self.stc.getShortDisplayName(self. url)419 return basename == self.stc.getShortDisplayName(self.raw_url) 411 420 412 421 def setName(self): 413 basename=self.stc.getShortDisplayName(self. url)422 basename=self.stc.getShortDisplayName(self.raw_url) 414 423 if basename in self.filenames: 415 424 count=self.filenames[basename]+1 … … 582 591 def createPostHook(self): 583 592 self.showBusy(True) 584 wx.CallAfter(self.frame.openThreaded, self.buffer. user_url,593 wx.CallAfter(self.frame.openThreaded, self.buffer.raw_url, 585 594 self.buffer, mode_to_replace=self) 586 595 587 596 class LoadingBuffer(BufferVFSMixin, debugmixin): 588 def __init__(self, url, modecls=None, created_from_url=None): 589 self.user_url = url 590 BufferVFSMixin.__init__(self, url, created_from_url) 597 def __init__(self, url, modecls=None, created_from_url=None, canonicalize=True): 598 BufferVFSMixin.__init__(self, url, created_from_url, canonicalize) 591 599 self.busy = True 592 600 self.readonly = False … … 598 606 self.modecls = modecls 599 607 else: 600 self.modecls = MajorModeMatcherDriver.match(self )608 self.modecls = MajorModeMatcherDriver.match(self, url=self.raw_url) 601 609 self.dprint("found major mode = %s" % self.modecls) 602 610 self.stc = LoadingSTC(unicode(url)) … … 608 616 609 617 def allowThreadedLoading(self): 610 return self.modecls.preferThreadedLoading(self. user_url)618 return self.modecls.preferThreadedLoading(self.raw_url) 611 619 612 620 def clone(self): 613 621 """Get a real Buffer instance from this temporary buffer""" 614 dprint(self.user_url) 615 return Buffer(self.user_url, self.modecls, self.created_from_url) 622 return Buffer(self.raw_url, self.modecls, self.created_from_url) 616 623 617 624 def addViewer(self, mode): -
trunk/peppy/frame.py
r1488 r1503 704 704 self.open(url) 705 705 706 def open(self, url, modecls=None, mode_to_replace=None, force_new_tab=False, created_from_url=None ):706 def open(self, url, modecls=None, mode_to_replace=None, force_new_tab=False, created_from_url=None, canonicalize=True): 707 707 """Open a new tab to edit the given URL. 708 708 … … 726 726 creating a new file in the mem: filesystem and want a working directory 727 727 on the local filesystem to be available if needed to save a copy. 728 729 @param canonicalize: (optional) whether or not the URL should be 730 canonicalized before searching the existing buffer list. This is used 731 in the rare case where a fragment or query string is significant to 732 locating the data on the file system. 728 733 """ 729 734 # The canonical url stored in the buffer will be without query string … … 731 736 # query string and fragment) it separately. 732 737 user_url = vfs.normalize(url) 733 try: 734 buffer = BufferList.findBufferByURL(user_url) 735 except NotImplementedError: 736 # This means that the vfs implementation doesn't recognize the 737 # filesystem type. This is the first place in the loading chain 738 # that the error can be encountered, so check for it here and load 739 # a new plugin if necessary. 740 found = False 741 plugins = wx.GetApp().plugin_manager.getActivePluginObjects() 742 for plugin in plugins: 743 assert self.dprint("Checking %s" % plugin) 744 plugin.loadVirtualFileSystem(user_url) 745 try: 746 buffer = BufferList.findBufferByURL(user_url) 747 found = True 748 break 749 except NotImplementedError: 750 pass 751 if not found: 752 self.openFailure(user_url, "Unknown URI scheme") 753 return 738 buffer = None 739 if canonicalize: 740 try: 741 buffer = BufferList.findBufferByURL(user_url) 742 except NotImplementedError: 743 # This means that the vfs implementation doesn't recognize the 744 # filesystem type. This is the first place in the loading chain 745 # that the error can be encountered, so check for it here and load 746 # a new plugin if necessary. 747 found = False 748 plugins = wx.GetApp().plugin_manager.getActivePluginObjects() 749 for plugin in plugins: 750 assert self.dprint("Checking %s" % plugin) 751 plugin.loadVirtualFileSystem(user_url) 752 try: 753 buffer = BufferList.findBufferByURL(user_url) 754 found = True 755 break 756 except NotImplementedError: 757 pass 758 if not found: 759 self.openFailure(user_url, "Unknown URI scheme") 760 return 754 761 755 762 if buffer is not None: … … 758 765 else: 759 766 try: 760 buffer = LoadingBuffer(user_url, modecls, created_from_url )767 buffer = LoadingBuffer(user_url, modecls, created_from_url, canonicalize) 761 768 except Exception, e: 762 769 import traceback -
trunk/peppy/hsi/loader.py
r1501 r1503 26 26 return False 27 27 28 def getShortDisplayName(self, url): 29 """Return a short name for display in tabs or other context without 30 needing a pathname. 31 """ 32 if url.fragment: 33 return "%s#%s" % (url.path.get_name(), url.fragment) 34 return url.path.get_name() 35 28 36 def getHandler(self): 29 37 return self.dataset.__class__
