forms process context entry
3150
def daemon_context_entry(process_name,
                         classname,
                         token,
                         exchange=EXCHANGE_UTILS,
                         present_on_boxes=None,
                         arguments=None,
                         queue=None,
                         routing=None,
                         pid_file=None,
                         log_file=None):
    
    _ROUTING_PREFIX = 'routing_'
    _QUEUE_PREFIX = 'queue_'
    _SUFFIX = '_daemon'

    if arguments is not None:
        assert isinstance(arguments, dict)

    process_entry = DaemonProcessEntry(
        process_name=process_name,
        classname=classname,
        token=token,
        mq_queue=queue if queue is not None else _QUEUE_PREFIX + token + _SUFFIX,
        mq_routing_key=routing if routing is not None else _ROUTING_PREFIX + token + _SUFFIX,
        mq_exchange=exchange,
        present_on_boxes=present_on_boxes,
        arguments=arguments if arguments is not None else dict(),
        log_filename=log_file if log_file is not None else token + _SUFFIX + '.log',
        pid_filename=pid_file if pid_file is not None else token + _SUFFIX + '.pid')
    return process_entry
1280706
def fields_for(context, form, template="includes/form_fields.html"):
    
    context["form_for_fields"] = form
    return get_template(template).render(context)
1140401
protected void updateStackingContexts()
    {
        if (parent != null)
        {
            if (parent.formsStackingContext())
                stackingParent = parent;
            else
                stackingParent = parent.getStackingParent();
        }
    }
1323345
def contextMenuEvent(self, event):
        """"""
        state = self.has_selected_text()
        self.copy_without_prompts_action.setEnabled(state)
        ShellBaseWidget.contextMenuEvent(self, event)
726201
function searchFormSubmitted(e){
    e = e || window.event;
    e.preventDefault();

    // If there's no selected item, do nothing
    if(!selectedItem) return false;

    // Otherwise, jump to the page
    window.location.href = relativeDir + selectedItem.getAttribute('data-value');

    return false;
  }
432714
public static void loadActionForm(JspContext jspContext, Object form) {
        jspContext.setAttribute(ACTION_FORM_IMPLICIT_OBJECT_KEY, unwrapForm(form));
    }
1009856
public function getContextSelectorForm()
    {
        if (!$this->contextSelectorForm) {
            if (!$this->contextSelectorType || !$this->formFactory) {
                return null;
            }

            $formOptions = [
                'action' => $this->requestUri,
                'attr' => [
                    'novalidate' => 'novalidate',
                    'class' => 'form-inline',
                ],
            ];
            $this->contextSelectorForm = $this->formFactory->createNamed(
                static::SESSION_KEY,
                $this->contextSelectorType,
                $this->getContext(),
                $formOptions
            );
        }

        return $this->contextSelectorForm;
    }
829165
function context(value) {
  var out = {}

  value = value || {}

  ;['priority', 'timeout'].forEach(function eachIntKey(key) {
    if (value.hasOwnProperty(key)) {
      out[key] = parseInt(value[key], 10)

      if (isNaN(out[key])) {
        throw new FieldTypeError('context.' + key, 'number')
      }
    }
  })


  if (value.hasOwnProperty('queryId')) {
    out.queryId = value.queryId + ''
  }

  ['bySegment', 'populateCache', 'useCache', 'finalize', 'skipEmptyBuckets'].forEach(function eachBoolKey(key) {
    if (value.hasOwnProperty(key)) {
      out[key] = !!((value[key]||false).valueOf())
    }
  })

  return out
}
678673
def post(self, request, *args, **kwargs):
        

        # Prepare base
        if 'pk' in kwargs:
            self.object = self.get_object()
        else:
            self.object = None
        form_class = self.get_form_class()

        # Get prefix
        if 'field_prefix' in form_class.Meta.__dict__:
            # Get name from the form
            field_prefix = form_class.Meta.field_prefix
            # Initialize list of fields
        else:
            # Get name from the class
            field_prefix = str(form_class).split("'")[1].split(".")[-1]
        self.field_prefix = field_prefix

        # Build the form
        form = self.get_form(form_class)

        # Find groups
        if 'groups' in dir(self):
            # Save groups
            groups = self.groups
            # Redefine groups inside the form
            form.__groups__ = lambda: groups
            # Initialize list of fields
            fields = []
        else:
            groups = None

        # Add special prefix support to properly support form independency
        form.add_prefix = lambda fields_name, field_prefix=field_prefix: "%s_%s" % (field_prefix, fields_name)

        # Check validation
        valid = form.is_valid()
        if (not valid) and ('non_field_errors' in dir(self)):
            errors = [element[5] for element in list(self.non_field_errors())[:-1]]
        elif form.errors.as_data():
            errors = []
            for element in form.errors.as_data():
                for err in form.errors.as_data()[element][0]:
                    errors.append(err)
        else:
            errors = []

        # For every extra form
        temp_forms = []
        position_form_default = 0
        for (formelement, linkerfield, modelfilter) in self.forms:
            if formelement is None:
                formobj = form
                position_form_default = len(temp_forms)
            else:
                # Locate linked element
                if self.object:
                    related_name = formelement._meta.model._meta.get_field(linkerfield).related_query_name()
                    queryset = getattr(self.object, related_name)
                    if modelfilter:
                        queryset = queryset.filter(eval("Q(%s)" % (modelfilter)))
                    get_method = getattr(queryset, 'get', None)
                    if get_method:
                        instance = queryset.get()
                    else:
                        instance = queryset
                else:
                    instance = None

                # Get prefix
                if 'field_prefix' in formelement.Meta.__dict__:
                    # Get name from the form
                    field_prefix = formelement.Meta.field_prefix
                else:
                    # Get name from the class
                    field_prefix = str(formelement).split("'")[1].split(".")[-1]
                self.field_prefix = field_prefix

                # Prepare form
                formobj = formelement(instance=instance, data=self.request.POST)
                formobj.form_name = form.form_name

                # Excluded fields
                if 'exclude' not in formobj.Meta.__dict__:
                    formobj.Meta.exclude = [linkerfield]
                elif linkerfield not in formobj.Meta.exclude:
                    formobj.Meta.exclude.append(linkerfield)
                if linkerfield in formobj.fields:
                    del(formobj.fields[linkerfield])

                # Link it to the main model
                formobj.add_prefix = lambda fields_name, field_prefix=field_prefix: "%s_%s" % (field_prefix, fields_name)

                # Validate
                valid *= formobj.is_valid()

                # append error
                if not formobj.is_valid() and ('non_field_errors' in dir(formobj)):
                    errors += [element[5] for element in list(formobj.non_field_errors())[:-1]]

            # Save fields to the list
            if groups:
                for field in formobj:
                    # raise Exception (field.__dict__)
                    if 'unblock_t2ime' in field.html_name:
                        raise Exception(field.field.__dict__)
                    fields.append(field)

            # Add a new form
            temp_forms.append((formobj, linkerfield))

        # execute validation specified
        validate_forms = None
        if valid and ("validate" in dir(self)):
            validate_forms = [tform[0] for tform in temp_forms]
            errors = self.validate(*validate_forms)
            # valid = len(errors) == 0
            valid = False
            if errors is None or len(errors) == 0:
                valid = True

        # Remember list of fields
        if groups:
            form.list_fields = fields
            forms = []
        else:
            if validate_forms:
                forms = validate_forms
            else:
                forms = [tform[0] for tform in temp_forms]

        if position_form_default == 0:
            open_tabs = 1
        else:
            open_tabs = 0

        # Check validation result
        if valid:
            # Everything is OK, call valid
            return self.form_valid(form, temp_forms)
        else:
            # Something went wrong, attach error and call invalid
            form.list_errors = errors
            return self.form_invalid(form, forms, open_tabs, position_form_default)
1303042
def process_formdata(self, valuelist):
        """"""
        if valuelist:
            self.data = '\n'.join([
                x.strip() for x in
                filter(lambda x: x, '\n'.join(valuelist).splitlines())
            ])
509475
def process_form(self, instance, field, form, empty_marker=None,
                     emptyReturnsMarker=False):
        

        # a poor workaround for Plone repeating itself.
        # XXX this is important XXX
        key = field.getName() + '_value'
        if key in instance.REQUEST:
            return instance.REQUEST[key], {}
        value = form.get(field.getName(), empty_marker)
        # When a recordswidget's visibility is defined as hidden
        # '...visible={'view': 'hidden', 'edit': 'hidden'},...' the template
        # displays it as an input field with the attribute 'value' as a string
        # 'value="[{:},{:}]"'. This makes the system save the content of the
        # widget as the string instead of a dictionary inside a list, so we
        # need to check if the variable contains a python object as a string.
        if value and value is not empty_marker and isinstance(value, str):
            import ast
            try:
                value = ast.literal_eval(form.get(field.getName()))
            except:
                # cannot resolve string as a list!
                return empty_marker

        if not value:
            return value, {}
        if value is empty_marker:
            return empty_marker
        if emptyReturnsMarker and value == '':
            return empty_marker

        # we make sure that empty "value" inputs are saved as "" empty string.
        for i in range(len(value)):
            value[i] = dict(value[i])
            if 'value' not in value[i]:
                value[i]['value'] = ''

        instance.REQUEST[key] = value
        return value, {}
75065
def form_echo(cls, request,
                  foo: (Ptypes.form, String('A form parameter'))) -> [
            (200, 'Ok', String)]:
        ''''''
        log.info('Echoing form param, value is: {}'.format(foo))
        for i in range(randint(0, MAX_LOOP_DURATION)):
            yield
        msg = 'The value sent was: {}'.format(foo)
        Respond(200, msg)
1372020
def process_form(self, instance, field, form, empty_marker = None,
                     emptyReturnsMarker = False):
        
        bsc = getToolByName(instance, 'bika_setup_catalog')
        default = super(PartitionSetupWidget,self).process_form(
            instance, field, form, empty_marker, emptyReturnsMarker)
        if not default:
            return [], {}
        value = default[0]
        kwargs = len(default) > 1 and default[1] or {}
        newvalue = []
        for v in value:
            v = dict(v)
            if v.get('separate', '') == 'on' and not 'preservation' in v:
                container_uid = v.get('container', [''])[0];
                if container_uid:
                    container = bsc(UID=container_uid)[0].getObject();
                    if container.getPrePreserved():
                        pres = container.getPreservation()
                        if pres:
                            v['preservation'] = [pres.UID()]
            newvalue.append(v)
        return newvalue, kwargs
50212
def waitinglist_entry_form(context):
    
    initial = {}
    if "request" in context:
        initial.update({
            "referrer": context["request"].META.get("HTTP_REFERER", ""),
            "campaign": context["request"].GET.get("wlc", "")
        })
    return WaitingListEntryForm(initial=initial)
1285285
function handleResults(context, results) {

  if (checkedPages.indexOf(results.url) === -1) {

    checkedPages.push(results.url);

    results.violations.forEach(violation => {
      
      let specName = `${violation.help} (${results.url})`;
      let message = '\n' + buildMessage(violation);

      context.addFailure(message, {specName});

    });

  }

}
70058
def get_context(self, name, value, attrs):
        """"""
        context = super(CaptchaTextInput, self).get_context(name, value, attrs)
        context['image'] = self.image_url()
        context['audio'] = self.audio_url()
        return context
158975
function() {
        var form = this.element.find('form:first');

        if (!form) {
            return;
        }

        this.fireEvent('submit', [form]);

        var options = {
            url: form.attr('action'),
            type: (form.attr('method') || 'post').toUpperCase()
        };

        if (window.FormData) {
            options.processData = false;
            options.contentType = false;
            options.data = new FormData(form[0]);
        } else {
            options.data = form.serialize();
        }

        this.requestData(options);
    }