1

I am trying to use cefPython and the OnBeforeResourceLoad method.

I have implemented it as follows:

    def OnBeforeResourceLoad(self, browser, request, redirectURL, streamReader, response, loadFlags):
    #
    if request.GetUrl() == "http://firsturl":
        redirectURL = "http://secondurl"

    return False

However when running the program i get the following:

TypeError: OnBeforeResourceLoad() takes exactly 7 arguments (4 given)

What am I doing wrong here ?

The documentation for this is here:

https://code.google.com/p/cefpython/wiki/RequestHandler

Paul
  • 1,375
  • 4
  • 16
  • 29
  • The error is not coming from the definition, but from wherever you call the function. How do you call it? – SethMMorton Apr 19 '14 at 19:20
  • I have just modified the wxpython.py file in the examples of the project – Paul Apr 19 '14 at 20:01
  • The error message tells you that where the function is called, only 4 arguments are being passed to it. The error message will give you the line number in the file that it is being called. You need to either modify the function so that it takes only 4 arguments, or modify how you call it so that you pass 7 arguments. – SethMMorton Apr 19 '14 at 20:05

1 Answers1

0

In CEF 1 that callback takes six arguments. In CEF 3 only three arguments. (with "self" these are seven and four respectively). On the RequestHandler wiki page to which you link to, there are two signatures of that callback, one for CEF 3 and the other for CEF 1.

Czarek Tomczak
  • 20,079
  • 5
  • 49
  • 56