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

Cannot access special attributes from the Proxy #104

Closed
Faraphel opened this issue Jan 14, 2025 · 1 comment
Closed

Cannot access special attributes from the Proxy #104

Faraphel opened this issue Jan 14, 2025 · 1 comment

Comments

@Faraphel
Copy link

It seem like there is no way to access the __doc__ or __annotations__ objects of a method or any other objects that is behind the Proxy directly, because it is instead using the value of the Proxy.

import Pyro5.api
import typing


@Pyro5.api.expose
class Model:
    def echo(self, message: str) -> str:
        """
        Hello ! I am a docstring.
        :param messages: a message
        :return: the same message
        """
        return message


daemon = Pyro5.api.Daemon(port=9555)
daemon.register(Model, objectId="model")
daemon.requestLoop()

import Pyro5.api

model = Pyro5.api.Proxy("PYRO:model@localhost:9555")

print(model.echo("hello !"))
print(model.echo.__annotations__)
print(model.echo.__doc__)
hello !
<Pyro5.client._RemoteMethod object at 0x000002196F3C4350>
method call abstraction

It would be better if the Proxy was also redirecting theses attributes through a kind of property or some specials attributes ?

This is a very minor issue, there are just some case where it would help make some rare program a bit cleaner (in my case it help with an API that get its own documentation from theses classes that are exposed) and for the sake of completion.

@irmen
Copy link
Owner

irmen commented Feb 15, 2025

Can't do that, Python is returning the value of the local attribute over anything else. Pyro can not intercept local attributes

Suggestion: make an explicit remote method that returns the attribute values.

@irmen irmen closed this as not planned Won't fix, can't repro, duplicate, stale Feb 15, 2025
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

No branches or pull requests

2 participants