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

only auto call finish if view function return a list #84

Closed
wants to merge 1 commit into from

Conversation

tamland
Copy link

@tamland tamland commented Jan 15, 2013

As discussed in #72

@tamland
Copy link
Author

tamland commented Jan 15, 2013

Let's make that iterable

@jbeluch
Copy link
Owner

jbeluch commented Feb 12, 2013

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?

@tamland
Copy link
Author

tamland commented Feb 12, 2013

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.

@jbeluch
Copy link
Owner

jbeluch commented Feb 12, 2013

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.

@tamland
Copy link
Author

tamland commented Feb 12, 2013

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.

@jbeluch
Copy link
Owner

jbeluch commented Feb 12, 2013

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.

@tamland
Copy link
Author

tamland commented Feb 13, 2013

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..

@jbeluch
Copy link
Owner

jbeluch commented Feb 13, 2013

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.

@tamland
Copy link
Author

tamland commented Feb 13, 2013

What else do your views return besides lists or None?

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.

@jbeluch
Copy link
Owner

jbeluch commented Feb 13, 2013

I know how to implement the search functionally, that example is exactly the same as the one I pointed to.

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.

Things besides lists and None

Then please provide a code sample. I'm tired of arguing over this as well.

@tamland
Copy link
Author

tamland commented Feb 13, 2013

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

@jbeluch
Copy link
Owner

jbeluch commented Feb 13, 2013

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?

@tamland
Copy link
Author

tamland commented Feb 13, 2013

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.

@tamland tamland closed this Feb 13, 2013
@jbeluch
Copy link
Owner

jbeluch commented Feb 13, 2013

1 is an example!

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants