0

I am trying to load a static html page but I get load page as false. (This works locally but not inside docker container).

The file loadProgress is 100% but I get OK signa as false indicating there is an error loading the page. I am trying to use ErrorPageExtension (found from online) to figure out what is the detailed error message. Could some one throw some light how to get the extension invoked in case of error when loading the page ? am I missing any thing ?

  def setupWebView(self):
    # setting up web view objects
    #bla bla
    self._extension_handlers = {
      QWebPage.ErrorPageExtension: self._handle_errorpage,
    }

  def loadSetPage(self):
    print(":: OS Path is:"+os.getcwd())
    self.url2 = QUrl("file://"+os.getcwd()+"/dist/index.html")
    self.web2.load(self.url2)
    print("Checking if Load Page was successful")
    self.web2.loadFinished.connect(self.testIfPageLoaded)


  def testIfPageLoaded(self, ok):
    print(":: Loading of page finished successfully")
    testhtml = self.web2.page().currentFrame().toHtml()
    print(ok)  ##

 def _handle_errorpage(self, info, errorPage):
    # catch the error, populate self.errorInfo and return an error page
    info = sip.cast(info, QWebPage.ErrorPageExtensionOption)
    print("The error loading page is : "+info.errorString)
    return True

  def supportsExtension(self, ext):
    return ext in self._extension_handlers

  def extension(self, ext, opt, out):
    try:
      handler = self._extension_handlers[ext]
    except KeyError:
      print("Extension {} not supported!".format(ext))
      return super().extension(ext, opt, out)
    return handler(opt, out)
eyllanesc
  • 235,170
  • 19
  • 170
  • 241
user2608576
  • 747
  • 2
  • 7
  • 17
  • On what class do you define those methods? – The Compiler Mar 13 '17 at 22:01
  • I have a `class PDFService(QObject):` subclass of QObject - the signals work fine but I get loadFinished `bool OK` as false. – user2608576 Mar 14 '17 at 07:37
  • You'll need to subclass `QWebPage` and override `supportsExtension` and `extension` there. – The Compiler Mar 14 '17 at 10:50
  • I had subclassed the `QWebPage` and also overridden both `supportsExtension` and `extension` as well. This was an issue with in my docker container (with mounting the volume) and I have fixed it. Thank you for the response. – user2608576 Mar 14 '17 at 15:11

0 Answers0