Пример #1
0
    def __init__(self, conf, **local_conf):
        self.conf = conf
        mapper = routes.Mapper()

        mapper = routes.Mapper()
        controller_resource = watch.create_resource(conf)

        def conditions(action):
            api_action = self._actions[action]

            def action_match(environ, result):
                req = Request(environ)
                env_action = req.params.get("Action")
                return env_action == api_action

            return {'function': action_match}

        for action in self._actions:
            mapper.connect("/",
                           controller=controller_resource,
                           action=action,
                           conditions=conditions(action))

        mapper.connect("/", controller=controller_resource, action="index")

        super(API, self).__init__(mapper)
Пример #2
0
    def __init__(self, conf, **local_conf):
        self.conf = conf
        mapper = routes.Mapper()
        controller_resource = watch.create_resource(conf)

        def conditions(action):
            api_action = self._actions[action]

            def action_match(environ, result):
                req = Request(environ)
                env_action = req.params.get("Action")
                return env_action == api_action

            return {"function": action_match}

        for action in self._actions:
            mapper.connect("/", controller=controller_resource, action=action, conditions=conditions(action))

        mapper.connect("/", controller=controller_resource, action="index")

        super(API, self).__init__(mapper)