def OnLinkClicked(self, linkinfo): href = linkinfo.GetHref() tab_to_return_to = None word = self.parent.parent.search_word.GetValue() if linkinfo.Event.ControlDown(): if linkinfo.Event.ShiftDown(): self.parent.add_html_page(activate=True) else: tab_to_return_to = self.parent.current_page self.parent.add_html_page(activate=True) self.parent.SetPageText(self.parent.current_page, word) self.parent.parent.search_word.SetValue(word) page, word = bu.page_word(self.GetParser().GetSource(), word, href) if page: if word: self.parent.SetPageText(self.parent.current_page, word) self.parent.parent.show_page_and_word(page, word) else: self.show_msg("The word was not found!") self.parent.parent.show_page_and_word(page) else: self.show_msg('Relation "%s" is not implemented yet!' % rel_name) # print 'Relation "%s" is not implemented yet!' % rel_name """ else: print 'We should be in a Help Window now! Are we?' super(MyHtmlWindow, self).OnLinkClicked(linkinfo) """ if tab_to_return_to is not None: self.parent.switch_html_page(tab_to_return_to) """
def OnLinkClicked(self, linkinfo): href = linkinfo.GetHref() tab_to_return_to = None word = self.parent.parent.search_word.GetValue() if linkinfo.Event.ControlDown(): if linkinfo.Event.ShiftDown(): self.parent.add_html_page(activate=True) else: tab_to_return_to = self.parent.current_page self.parent.add_html_page(activate=True) self.parent.SetPageText(self.parent.current_page, word) self.parent.parent.search_word.SetValue(word) page, word = bu.page_word(self.GetParser().GetSource(), word, href) if page: if word: self.parent.SetPageText(self.parent.current_page, word) self.parent.parent.show_page_and_word(page, word) else: self.show_msg('The word was not found!') self.parent.parent.show_page_and_word(page) else: self.show_msg('Relation "%s" is not implemented yet!' % rel_name) #print 'Relation "%s" is not implemented yet!' % rel_name ''' else: print 'We should be in a Help Window now! Are we?' super(MyHtmlWindow, self).OnLinkClicked(linkinfo) ''' if tab_to_return_to is not None: self.parent.switch_html_page(tab_to_return_to) '''
def do_GET(self): global page, word, firstClient global uc_to_pn, curr_page_num, viewed_pages #print 'path = ', self.path sp = self.path[1:] if unquote_plus(sp) == 'SHUTDOWN THE SERVER': print 'Server shutting down!' os._exit(0) if sp == 'favicon.ico': type = 'image/x-icon' page = open(sp).read() else: type = 'html' old_uc = uniq_cntr() # Trigger the update of old uc:s if sp == '': # We are starting if firstClient: firstClient = False page = open('index.html').read() else: page = open('index_2.html').read() word = 'green' elif sp.endswith('.html'): # Trying to fetch a HTML file usp = unquote_plus(sp) if usp == 'NLTK Wordnet Browser Database Info.html': word = '* Database Info *' if os.path.isfile(usp): page = open(usp).read() else: page = (html_header % word) + '<p>The database info file:'\ '<p><b>' + usp + '</b>' + \ '<p>was not found. Run this:' + \ '<p><b>python dbinfo_html.py</b>' + \ '<p>to produce it.' + html_trailer else: if os.path.isfile(usp): word = sp page = open(usp).read() else: word = '' page = (html_header % word) + '<p>The file:'\ '<p><b>' + usp + '</b>' + \ '<p>was not found.' + html_trailer #self.send_error(404) else: #print '######################################################' #print 'SP==>', sp, '\n<==SP' #print '######################################################' # Grab the unique counter uc = int(sp[sp.rfind('%23') + 3:]) # Page lookup needs not and cannot be done for the search words if uc: if uc in uc_to_pn and uc_to_pn[uc] in viewed_pages: page = viewed_pages[uc_to_pn[uc]] page,word = page_word(page, word, sp) page = uc_updated_page(page, old_uc) new_uc = uniq_cntr() for uc in range(old_uc, new_uc): uc_to_pn[uc] = curr_page_num viewed_pages[curr_page_num] = page curr_page_num += 1 self.send_head(type) self.wfile.write(page)