-
Notifications
You must be signed in to change notification settings - Fork 30
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
only auto call finish if view function return a list #84
Conversation
Let's make that iterable |
Is this still necessary after this fix, e004188? Views will either return lists or None if something went wrong. If set_resolved_url is called, the endOfDirectory call will be skipped due to the above fix. Do you have an example where a view might return something else? |
What? What does set_resolved_url have to do with this? Views returning None does not mean something went wrong, that's the problem. The same example applies. |
In your example you use plugin.redirect(). You can simply return the result of plugin.redirect. The reason you run into the issue is because you call endOfDirectory yourself. |
Not sure what you're talking about (again). The original problem I was trying to solve is this: xbmc queries a plugin directory, but the plugin cancels. This is normal, and xbmc stays in current directory. But swift force call endOfDirectory and xbmc goes into an empty directory instead. |
I am confused how this commit 89d145f does not solve your issue then. If your view returns None (a GUI dialog was cancelled for example) then endOfDirectory is called with succeeded=False (this is equivalent to not calling endOfDirectory at all). This keeps XBMC in the current directory and doesn't show an empty directory. |
Right, that was the problem. I say so in the other thread: it fails on other returns. It force fail on anything you know it isn't going to handle. Actually, current develop branch doesn't work at all now, without this applied. Probably because it currently calls finish no matter what and somebody made a mistake in that function. But that's for another issue I guess.. |
What else do your views return besides lists or None? The cancelable search functionality that you pointed to as an example can be implemented like so: @plugin.route('/search/')
def search():
query = plugin.keyboard('Enter search term')
if query:
return do_the_search(query)
@plugin.route('/search/<query>')
def do_the_search(query):
return get_items(query) Feel free to give other code samples that are broken. |
Things besides lists and None. What kind of answer do you expect? A list? I know how to implement the search functionally, that example is exactly the same as the one I pointed to. But enough talk. The problem is clear: I cant use functions for anything else because swift is force calling and raising exceptions. This makes absolutely no sense. Now decide. I could have implemented wrapper functions for everything by the time spent on this pr. |
It's not the same, you don't return the result of plugin.redirect(), in your example you return None, which would call finish() indicating an error.
Then please provide a code sample. I'm tired of arguing over this as well. |
It wasn't the redirect case that cause any trouble, but the other case. @plugin.route('/one'):
def one():
#plugin stuff
return 1 .. will fail |
In the context of a real addon I don't understand the purpose of returning 1 (or something besides a list or None). It'd be helpful to see real xbmc addon code where this situation occurs. Somewhere in your NRK addon you can point to perhaps? |
The purpose is reuse, I said this before, and I planed to do it. 1 is an example! I'm just trying to be helpful but I really don't have time for this. I'll just write wrapper functions for everything I need to also interface with xbmcswift. What I'm not going to do is write essays about why I want behavior that serves no purpose and does nothing other than hand you an uncatchable exception, removed. Take it or leave it. |
I know, that's why I asked for real code. xbmcswift has an opinionated way of doing things, like returning items from views. I was trying to understand an example when it might be helpful to not assume this but you refrained from showing me any real code. |
As discussed in #72