Eel icon indicating copy to clipboard operation
Eel copied to clipboard

AssertionError: Already exposed function with name "test"

Open nricciardi opened this issue 2 years ago • 4 comments

Hi, I'm trying to expose the method test of class Test using eel._expose(test, 'foo'), but I have an error: AssertionError: Already exposed function with name "test"

How to fix it?

nricciardi avatar May 09 '23 17:05 nricciardi

Hello,

I'm struggling to reproduce the issue

Does using @eel.expose work?

Can you share some more information if you are still facing the issue?

Thanks

  • Doug

doug-benn avatar May 17 '23 19:05 doug-benn

Thanks for interesting.

I can't use @eel.expose because it doesn't allow me to use alias.

Anyway, I have a class Test which accepts an object obj as parameter to be initialized, it has a method test where uses obj.

class Test:
    def __init__(self, obj):
        self.obj = obj

    def test(self):
        a = self.obj.a + "!!!"

        return a

test = Test(obj)
eel._expose(test.test, "foo")

Then I would expose a new method with the same name (foo).

nricciardi avatar May 17 '23 19:05 nricciardi

I don't get your error it just doesn't work. As per #679 Couldn't you wrap it in a function?

class Test:
    def __init__(self, obj):
        self.obj = obj

    def test(self):
        a = self.obj.a + "!!!"

        return a

test = Test(obj)

@eel.expose
def call_test():
    data = test.test()
    print(data)

This seems to work and I don't see a problem with it - not the nicest way of doing it but

doug-benn avatar May 17 '23 20:05 doug-benn

Thanks for answering me, but I change the test reference after first assignment, this is the problem in my point of view.

nricciardi avatar May 18 '23 17:05 nricciardi