Пример #1
0
    def wrapper(wrapped):
        def action(app):
            # This is here so the app won't start if any of the args
            # passed to @config are invalid. Otherwise, the invalid args
            # wouldn't be detected until a request is made to a resource
            # that was decorated with invalid args. NOTE: We can't check
            # *everything* pre-emptively here, but we do what we can.
            if isinstance(wrapped, type):
                Config(app, 'GET', content_type, **kwargs)
            elif wrapped.__name__ in ALL_HTTP_METHODS:
                Config(app, wrapped.__name__, content_type, **kwargs)

            differentiator = fully_qualified_name(wrapped), content_type
            if app.contains(config, differentiator):
                app.get(config, differentiator).update(kwargs)
            else:
                app.register(config, kwargs, differentiator)

        register_action(wrapped, action, 'tangled.web')
        return wrapped
Пример #2
0
    def wrapper(wrapped):
        def action(app):
            # This is here so the app won't start if any of the args
            # passed to @config are invalid. Otherwise, the invalid args
            # wouldn't be detected until a request is made to a resource
            # that was decorated with invalid args. NOTE: We can't check
            # *everything* pre-emptively here, but we do what we can.
            if isinstance(wrapped, type):
                Config(app, 'GET', content_type, **kwargs)
            elif wrapped.__name__ in ALL_HTTP_METHODS:
                Config(app, wrapped.__name__, content_type, **kwargs)

            differentiator = fully_qualified_name(wrapped), content_type
            if app.contains(config, differentiator):
                app.get(config, differentiator).update(kwargs)
            else:
                app.register(config, kwargs, differentiator)

        register_action(wrapped, action, 'tangled.web')
        return wrapped
Пример #3
0
 def wrapper(wrapped):
     register_action(
         wrapped,
         lambda app: app.add_subscriber(event_type, wrapped, *args, **kw),
         tag='tangled.web')
     return wrapped
Пример #4
0
 def wrapper(wrapped):
     register_action(
         wrapped,
         lambda app: app.add_subscriber(event_type, wrapped, *args, **kw),
         tag='tangled.web')
     return wrapped