Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass keyword arguments to Handlers' callbacks and other interfaces (breaks backward compatibility!) #291

Closed
cztomczak opened this issue Dec 20, 2016 · 1 comment
Milestone

Comments

@cztomczak
Copy link
Owner

cztomczak commented Dec 20, 2016

Since upstream CEF constantly changes, to minimize code breaking when updating to newer CEF, it would be best to use keyword arguments in callbacks, so that when a new argument is added it will not break existing code. And when argument is removed in upstream CEF, we might still keep the old argument for BC.

Using keyword arguments would also be useful in PyCharm so that it doesn't generate warnings when there are unused parameters in callbacks.

For example a callback would be defined like this:

def OnLoadStart(self, **kwargs):
    browser = kwargs["browser"]    

or:

def OnLoadStart(self, browser, **_):
    pass

To make this possible, src/handlers/ need to be modified, so that keyword arguments are specified when calling user-provided callback.

This will break existing code! So changes will be required.

There is also a related feature to catch possible errors in parameters when declaring Handlers - Issue #215 "Expose handlers as classes/interfaces: ClientHandler, DisplayHandler, LifespanHandler, etc.". This feature does not conflict with using **kwargs, there would just be two ways for doing it.

@cztomczak cztomczak changed the title Pass keyword arguments to Handlers' callbacks Pass keyword arguments to Handlers' callbacks and other interfaces Dec 20, 2016
@cztomczak cztomczak changed the title Pass keyword arguments to Handlers' callbacks and other interfaces Pass keyword arguments to Handlers' callbacks and other interfaces (breaks backward compatibility!) Dec 20, 2016
cztomczak added a commit that referenced this issue Dec 20, 2016
…AK!).

Fix focus issue in qt.py and gtk2.py examples during app initial
loading (#284). The solution is to call SetFocus in OnLoadStart once.

Pass keyword arguments to Handlers' callbacks (#291). This will break
many of existing code for Handlers' callbacks. Similar changes were also
applied to: CookieVisitor, StringVisitor, WebRequestClient.

In JavascriptDialogCallback.Continue "userInput" argument was renamed
to "user_input".

Fix PyCharm warnings in kivy_.py example (#285).

Rename JavascriptContextHandler to V8ContextHandler (API docs only
changes).

Update tools/apidocs.py. Sort top-level headings by name.
@cztomczak
Copy link
Owner Author

Done in commit 0a7d8d6. All examples and unit tests updated to use the new style.

@cztomczak cztomczak added this to the v55 milestone Feb 24, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant