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

Add options for register decorator #429

Closed
singlecheeze opened this issue Sep 2, 2015 · 2 comments
Closed

Add options for register decorator #429

singlecheeze opened this issue Sep 2, 2015 · 2 comments

Comments

@singlecheeze
Copy link

Not sure if this has already been addressed, but the @wamp.register decorator does not include args for Register Options: http://crossbar.io/docs/Shared-Registrations/

Also, at the link above, I could only get shared registrations working for a python 3 guest on Crossbar 10.4 with this:

self.register(self.parse, 'com.example.parse', options=RegisterOptions(invoke='roundrobin'))

Not this, like it states in the docs, (I know that it shows a JS example, but I would think the args order would be the same for continuity sake):

session.register("com.myapp.procedure1", procedure1, { invoke: "roundrobin"});

Please add this capability:

@wamp.register('com.example.parse', options=RegisterOptions(invoke='roundrobin'))
    def parse(self, fname, reg):

Or like this:

@wamp.register('com.example.parse', { invoke: "roundrobin"})

This allows for all registrations in a file much easier:

@asyncio.coroutine
    def onJoin(self, details):
        res = yield from self.register(self)

Here:

def register(uri):
    """
    Decorator for WAMP procedure endpoints.
    """
    def decorate(f):
        assert(callable(f))
        if not hasattr(f, '_wampuris'):
            f._wampuris = []
        f._wampuris.append(Pattern(uri, Pattern.URI_TARGET_ENDPOINT))
        return f
    return decorate
@meejah
Copy link
Contributor

meejah commented Sep 2, 2015

You can already pass options to the self.register(self, options=...) call but of course then all the @-decorated registrations get the same options. Not quite as flexible of course.

Something like your above suggestion could probably be made to work as well, so leave this ticket open as an enhancement.

@oberstet
Copy link
Contributor

oberstet commented Sep 2, 2015

yes, it would be consequent if possible: this is an AutobahnPython issue, pls see crossbario/autobahn-python#336

@oberstet oberstet closed this as completed Sep 2, 2015
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

3 participants