Question

How can I use the navigation-policy-decision-requested (or equivalent) in association with webkit_web_policy_decision_ignore()?

The following is a small outtake form my code (the rest is just a wrapper and settings etc):

def check(view, frame, req, nav, policy):
    webkit_web_policy_decision_ignore(TRUE)
...
view.connect("navigation-policy-decision-requested", check)

When I load a new page this error is returned:

Traceback (most recent call last):
  File "browser.py", line 17, in check_exec
    webkit_web_policy_decision_ignore(TRUE)
NameError: global name 'webkit_web_policy_decision_ignore' is not defined

What I'm trying to achieve is that if a certain address have been given, actions will be taken to prevent it from loading via Python. Any suggestions are welcome in the comments and any additional information you may need will be provided upon request.

Now I'm new to Python so please be specific in your answer, criticism and suggestions.

Was it helpful?

Solution

If you are using pygtk, try policy.ignore().

The object names are mapped slightly differently in pygtk. In python shell you can try after executing from gi.repository import WebKit

print dir(WebKit)

to find corresponding object and in your case

help(WebKit.WebPolicyDecision)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top