예제 #1
0
def init_shell(self, url, comp, *args):
    o = self.shell(self.configuration)
    component.call_wrapper(lambda: comp.call(o))
    comp.init(url, *args)
예제 #2
0
파일: callbacks.py 프로젝트: apoirier/test
    def process_response(self, request, response):
        """Call the actions associated to the callback identifiers received

        In:
          - ``request`` -- the web request object
          - ``response`` -- the web response object

        Return:
          - the render function
        """
        # The structure of a callback identifier is
        # '_action<priority on 1 char><key into the callbacks dictionary>'
        actions = {}

        try:
            for (name, value) in request.params.items():
                if isinstance(value, basestring) and value.startswith('_action'):
                    # For the radio buttons, the callback identifier is the value,
                    # not the name
                    name = value

                if name and name.startswith('_action'):
                    v = actions.get(name)
                    if v is not None:
                        # Multiple values for the same callback are put into a tuple
                        v = v[3]
                        value = (v if isinstance(v, tuple) else (v,)) + (value,)

                    actions[name] = ((int(name[7]), len(actions)), int(name[8:16]), name, value)
        except ValueError:
            raise CallbackLookupError(name[8:])

        render = None
        callback_type = 0

        for ((callback_type, _), name, param, value) in sorted(actions.values()):
            (f, with_request, render) = self._search_by_callback_name(name)
            if f is None:
                continue

            # ``callback_type``:
            #
            # 0 : <form>.pre_action
            # 1 : action with value (<textarea>, checkbox ...)
            # 2 : action without value (radio button)
            # 3 : <form>.post_action
            # 4 : action with continuation and without value (<a>, submit button ...)
            # 5 : action with continuation and with value (special case for <input type='image'>)

            if with_request:
                if callback_type == 1:
                    f(request, response, value)
                elif callback_type == 4:
                    call_wrapper(f, request, response)
                elif callback_type == 5:
                    if param.endswith(('.x', '.y')):
                        call_wrapper(f, request, response, param.endswith('.y'), int(value))
                else: # 0, 2, 3
                    f(request, response)
            else:
                if callback_type == 1:
                    f(value)
                elif callback_type == 4:
                    call_wrapper(f)
                elif callback_type == 5:
                    if param.endswith(('.x', '.y')):
                        call_wrapper(f, param.endswith('.y'), int(value))
                else: # 0, 2, 3
                    f()

        return render
예제 #3
0
def init_shell(self, url, comp, *args):
    o = self.shell(self.configuration)
    component.call_wrapper(lambda: comp.call(o))
    comp.init(url, *args)
예제 #4
0
파일: test_form.py 프로젝트: apoirier/test
def call(o1, o2, model=None):
    component.call_wrapper(lambda: o1.call(o2, model))