def reset(self, reload=0): # Should only be used inside constructor function. # For next release, make it __reset self.reloading = reload self.api = protocols.protocol_access(self.url, self.mode, self.params, data=self.postdata) self.stage = self.api.state self.init_new_load(META)
def refresh(self,when): params = copy.copy(self.params) params['If-Modified-Since'] = when.get_str() self.api = protocols.protocol_access(self.url, self.mode, params, data=self.postdata) self.meta = None self.stage = self.api.state self.hidden_getmeta = self.getmeta self.getmeta = self.refresh_getmeta
def restart(self, url): self.maxrestarts = self.maxrestarts - 1 self.viewer = self.last_context.viewer self.app = self.last_context.app self.parser = None tuple = urlparse.urlparse(url) # it's possible that the url send in a 301 or 302 error is a # relative URL. if there's no scheme or netloc in the # returned tuple, try joining the URL with the previous URL # and retry parsing it. if not (tuple[0] and tuple[1]): url = urlparse.urljoin(self.url, url) tuple = urlparse.urlparse(url) self.url = url self.fragment = tuple[-1] tuple = tuple[:-1] + ("", ) if self.user_passwd: netloc = tuple[1] i = string.find(netloc, '@') if i >= 0: netloc = netloc[i + 1:] netloc = self.user_passwd + '@' + netloc tuple = (tuple[0], netloc) + tuple[2:] realurl = urlparse.urlunparse(tuple) # Check first to see if the previous Context has any protocol handlers api = self.last_context.get_local_api(realurl, self.method, self.params) if not api: if self.app: api = self.app.open_url(realurl, self.method, self.params, self.reload, data=self.data) else: import protocols api = protocols.protocol_access(realurl, self.method, self.params, data=self.data) BaseReader.__init__(self, self.last_context, api)
def restart(self, url): self.maxrestarts = self.maxrestarts - 1 self.viewer = self.last_context.viewer self.app = self.last_context.app self.parser = None tuple = urlparse.urlparse(url) # it's possible that the url send in a 301 or 302 error is a # relative URL. if there's no scheme or netloc in the # returned tuple, try joining the URL with the previous URL # and retry parsing it. if not (tuple[0] and tuple[1]): url = urlparse.urljoin(self.url, url) tuple = urlparse.urlparse(url) self.url = url self.fragment = tuple[-1] tuple = tuple[:-1] + ("",) if self.user_passwd: netloc = tuple[1] i = string.find(netloc, '@') if i >= 0: netloc = netloc[i+1:] netloc = self.user_passwd + '@' + netloc tuple = (tuple[0], netloc) + tuple[2:] realurl = urlparse.urlunparse(tuple) # Check first to see if the previous Context has any protocol handlers api = self.last_context.get_local_api(realurl, self.method, self.params) if not api: if self.app: api = self.app.open_url(realurl, self.method, self.params, self.reload, data=self.data) else: import protocols api = protocols.protocol_access(realurl, self.method, self.params, data=self.data) BaseReader.__init__(self, self.last_context, api)