For generic class based views we return information about
        the fields that are accepted for 'PUT' and 'POST' methods.
342145
def determine_actions(self, request, view):
        
        actions = {}
        for method in {'PUT', 'POST'} & set(view.allowed_methods):
            view.request = clone_request(request, method)
            try:
                # Test global permissions
                if hasattr(view, 'check_permissions'):
                    view.check_permissions(view.request)
                # Test object permissions
                if method == 'PUT' and hasattr(view, 'get_object'):
                    view.get_object()
            except (exceptions.APIException, PermissionDenied, Http404):
                pass
            else:
                # If user has appropriate permissions for the view, include
                # appropriate metadata about the fields that should be supplied.
                serializer = view.get_serializer()
                actions[method] = self.get_serializer_info(serializer)
            finally:
                view.request = request

        return actions
440510
def get_fieldsets(self, request, obj=None):
        
        fieldsets = super(BaseDynamicInlineAdmin, self).get_fieldsets(
                                                            request, obj)
        if issubclass(self.model, Orderable):
            for fieldset in fieldsets:
                fields = [f for f in list(fieldset[1]["fields"])
                          if not hasattr(f, "translated_field")]
                try:
                    fields.remove("_order")
                except ValueError:
                    pass
                fieldset[1]["fields"] = fields
            fieldsets[-1][1]["fields"].append("_order")
        return fieldsets
603720
private void ensureFields(ClassDescriptorDef classDef, Collection fields) throws ConstraintException
    {
        boolean forceVirtual = !classDef.getBooleanProperty(PropertyHelper.OJB_PROPERTY_GENERATE_REPOSITORY_INFO, true);

        for (Iterator it = fields.iterator(); it.hasNext();)
        {
            FieldDescriptorDef fieldDef = (FieldDescriptorDef)it.next();

            // First we check whether this field is already present in the class
            FieldDescriptorDef foundFieldDef = classDef.getField(fieldDef.getName());

            if (foundFieldDef != null)
            {
                if (isEqual(fieldDef, foundFieldDef))
                {
                    if (forceVirtual)
                    {
                        foundFieldDef.setProperty(PropertyHelper.OJB_PROPERTY_VIRTUAL_FIELD, "true");
                    }
                    continue;
                }
                else
                {
                    throw new ConstraintException("Cannot pull up the declaration of the required field "+fieldDef.getName()+
                            " from type "+fieldDef.getOwner().getName()+" to basetype "+classDef.getName()+
                            " because there is already a different field of the same name");
                }
            }

            // perhaps a reference or collection ?
            if (classDef.getCollection(fieldDef.getName()) != null)
            {
                throw new ConstraintException("Cannot pull up the declaration of the required field "+fieldDef.getName()+
                                              " from type "+fieldDef.getOwner().getName()+" to basetype "+classDef.getName()+
                                              " because there is already a collection of the same name");
            }
            if (classDef.getReference(fieldDef.getName()) != null)
            {
                throw new ConstraintException("Cannot pull up the declaration of the required field "+fieldDef.getName()+
                                              " from type "+fieldDef.getOwner().getName()+" to basetype "+classDef.getName()+
                                              " because there is already a reference of the same name");
            }
            classDef.addFieldClone(fieldDef);
            classDef.getField(fieldDef.getName()).setProperty(PropertyHelper.OJB_PROPERTY_VIRTUAL_FIELD, "true");
        }
    }
85458
def _update_fields_with_objects(self):
        
        # Update the data with photo objects
        if self.type is not None:
            if self.type.startswith("photo"):
                self.data = Photo(self._client, self.data)
            else:
                raise NotImplementedError("Unrecognised activity type: %s"
                                          % self.type)
849276
public function getPostFields()
    {
        $this->validate();
        $mappedFields = $this->getMappedFields();
        $this->paymentMethod->addAdditionalFields($mappedFields);
        return $mappedFields;
    }
1028930
def _handle_post(self, request):
        # type: (Post) -> CallbackResponses
        """"""
        method_name = request.path[1]

        method = self._block[method_name]
        assert isinstance(method, MethodModel), \
            "Cannot Post to %s which is a %s" % (method.path, type(method))
        self.check_field_writeable(method)

        post_function = self.get_post_function(method_name)
        args = method.validate(request.parameters)

        with self.lock_released:
            result = post_function(**args)

        # Don't need to serialize as the result should be immutable
        ret = [request.return_response(result)]
        return ret
1254582
def _handle_put(self, request):
        # type: (Put) -> CallbackResponses
        """"""
        attribute_name = request.path[1]

        attribute = self._block[attribute_name]
        assert isinstance(attribute, AttributeModel), \
            "Cannot Put to %s which is a %s" % (attribute.path, type(attribute))
        self.check_field_writeable(attribute)

        put_function = self.get_put_function(attribute_name)
        value = attribute.meta.validate(request.value)

        with self.lock_released:
            result = put_function(value)

        if request.get and result is None:
            # We asked for a Get, and didn't get given a return, so do return
            # the current value. Don't serialize here as value is immutable
            # (as long as we don't try too hard to break the rules)
            result = self._block[attribute_name].value
        elif not request.get:
            # We didn't ask for a Get, so throw result away
            result = None
        ret = [request.return_response(result)]
        return ret
1289418
def show_form_for_method(self, view, method, request, obj):
        
        if method not in view.allowed_methods:
            return  # Not a valid method

        try:
            view.check_permissions(request)
            if obj is not None:
                view.check_object_permissions(request, obj)
        except exceptions.APIException:
            return False  # Doesn't have permissions
        return True
1017286
protected <View> void processViewFieldAnnotations(final View view) {
        Class<?> handledClass = view.getClass();
        while (handledClass != null && !handledClass.equals(Object.class)) {
            for (final Field field : ClassReflection.getDeclaredFields(handledClass)) {
                processLmlActorAnnotation(view, field);
                processOnChangeAnnotation(view, field);
                processLmlInjectAnnotation(view, field);
            }
            handledClass = handledClass.getSuperclass();
        }
    }
964437
def determine_actions(self, request, view):
        """"""
        from rest_framework.generics import GenericAPIView
        actions = {}
        excluded_methods = {'HEAD', 'OPTIONS', 'PATCH', 'DELETE'}
        for method in set(view.allowed_methods) - excluded_methods:
            view.request = clone_request(request, method)
            try:
                if isinstance(view, GenericAPIView):
                    has_object = view.lookup_url_kwarg or view.lookup_field in view.kwargs
                elif method in {'PUT', 'POST'}:
                    has_object = method in {'PUT'}
                else:
                    continue
                # Test global permissions
                if hasattr(view, 'check_permissions'):
                    view.check_permissions(view.request)
                # Test object permissions
                if has_object and hasattr(view, 'get_object'):
                    view.get_object()
            except (exceptions.APIException, PermissionDenied, Http404):
                pass
            else:
                # If user has appropriate permissions for the view, include
                # appropriate metadata about the fields that should be supplied.
                serializer = view.get_serializer()
                actions[method] = self.get_serializer_info(serializer)
            finally:
                view.request = request

        return actions
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)
913805
def serialize_fields
      serialized = {}
      post_fields.visibles.roots.order('position ASC').each do |post_field|
        serialized[post_field.key] = post_field.serialize_base
      end
      serialized
    end
1186081
def get_generic_fields():
    """"""
    generic_fields = []
    for model in apps.get_models():
        for field_name, field in model.__dict__.items():
            if isinstance(field, GenericForeignKey):
                generic_fields.append(field)
    return generic_fields
344804
function allowedMethods(methods) {
  // default values
  var methodsAllowed = { 'GET': true, 'POST': false, 'PUT': false, 'HEAD': false, 'DELETE': false  };
  // check and override if one of the default methods
  for (var key in methods) {
    var newKey = key.toUpperCase();
    if ( methodsAllowed[newKey]!=undefined) {
      methodsAllowed[newKey] = Boolean(methods[key]);
    }
  }
  return methodsAllowed;
}
490336
def post(self, request, *args, **kwargs):
        
        return self.update_type(request, *args, **kwargs)
913100
def post_collection(self, session, data, api_type):
        
        model = self._fetch_model(api_type)
        self._check_json_data(data)

        orm_desc_keys = model.__mapper__.all_orm_descriptors.keys()

        if 'type' not in data['data'].keys():
            raise MissingTypeError()

        if data['data']['type'] != model.__jsonapi_type__:
            raise InvalidTypeForEndpointError(
                model.__jsonapi_type__, data['data']['type'])

        resource = model()
        check_permission(resource, None, Permissions.CREATE)

        data['data'].setdefault('relationships', {})
        data['data'].setdefault('attributes', {})

        data_keys = set(map((
            lambda x: resource.__jsonapi_map_to_py__.get(x, MissingKey(x))),
            data['data'].get('relationships', {}).keys()))
        model_keys = set(resource.__mapper__.relationships.keys())
        if not data_keys <= model_keys:
            data_keys = set([key.elem if isinstance(key, MissingKey) else key for key in data_keys])
            # pragma: no cover
            raise BadRequestError(
                    '{} not relationships for {}'.format(
                    ', '.join([repr(key) for key in list(data_keys - model_keys)]), model.__jsonapi_type__))

        attrs_to_ignore = {'__mapper__', 'id'}

        setters = []

        try:
            if 'id' in data['data'].keys():
                resource.id = data['data']['id']

            for key, relationship in resource.__mapper__.relationships.items():
                attrs_to_ignore |= set(relationship.local_columns) | {key}
                api_key = resource.__jsonapi_map_to_api__[key]

                if 'relationships' not in data['data'].keys()\
                        or api_key not in data['data']['relationships'].keys():
                    continue

                data_rel = data['data']['relationships'][api_key]
                if 'data' not in data_rel.keys():
                    raise BadRequestError(
                        'Missing data key in relationship {}'.format(key))
                data_rel = data_rel['data']

                remote_side = relationship.back_populates
                if relationship.direction == MANYTOONE:
                    setter = get_rel_desc(resource, key,
                                          RelationshipActions.SET)
                    if data_rel is None:
                        setters.append([setter, None])
                    else:
                        if not isinstance(data_rel, dict):
                            raise BadRequestError(
                                '{} must be a hash'.format(key))
                        if not {'type', 'id'} == set(data_rel.keys()):
                            raise BadRequestError(
                                '{} must have type and id keys'.format(key))
                        to_relate = self._fetch_resource(
                            session, data_rel['type'], data_rel['id'],
                            Permissions.EDIT)
                        rem = to_relate.__mapper__.relationships[remote_side]
                        if rem.direction == MANYTOONE:
                            check_permission(to_relate, remote_side,
                                             Permissions.EDIT)
                        else:
                            check_permission(to_relate, remote_side,
                                             Permissions.CREATE)
                        setters.append([setter, to_relate])
                else:
                    setter = get_rel_desc(resource, key,
                                          RelationshipActions.APPEND)
                    if not isinstance(data_rel, list):
                        raise BadRequestError(
                            '{} must be an array'.format(key))
                    for item in data_rel:
                        if 'type' not in item.keys() or 'id' not in item.keys():
                            raise BadRequestError(
                                '{} must have type and id keys'.format(key))
                        # pragma: no cover
                        to_relate = self._fetch_resource(session, item['type'],
                                                         item['id'],
                                                         Permissions.EDIT)
                        rem = to_relate.__mapper__.relationships[remote_side]
                        if rem.direction == MANYTOONE:
                            check_permission(to_relate, remote_side,
                                             Permissions.EDIT)
                        else:
                            check_permission(to_relate, remote_side,
                                             Permissions.CREATE)
                        setters.append([setter, to_relate])

            data_keys = set(map((
                lambda x: resource.__jsonapi_map_to_py__.get(x, None)),
                data['data'].get('attributes', {}).keys()))
            model_keys = set(orm_desc_keys) - attrs_to_ignore

            if not data_keys <= model_keys:
                raise BadRequestError(
                    '{} not attributes for {}'.format(
                        ', '.join(list(data_keys -
                                       model_keys)), model.__jsonapi_type__))

            with session.no_autoflush:
                for setter, value in setters:
                    setter(resource, value)

                for key in data_keys:
                    api_key = resource.__jsonapi_map_to_api__[key]
                    setter = get_attr_desc(resource, key, AttributeActions.SET)
                    setter(resource, data['data']['attributes'][api_key])

                session.add(resource)
                session.commit()

        except IntegrityError as e:
            session.rollback()
            raise ValidationError(str(e.orig))
        except AssertionError as e:
            # pragma: no cover
            session.rollback()
            raise ValidationError(e.msg)
        except TypeError as e:
            session.rollback()
            raise ValidationError('Incompatible data type')
        session.refresh(resource)
        response = self.get_resource(
            session, {}, model.__jsonapi_type__, resource.id)
        response.status_code = 201
        return response
411089
private static MethodRef getPutMethod(FieldDescriptor descriptor) {
    Preconditions.checkState(descriptor.isMapField());
    List<FieldDescriptor> mapFields = descriptor.getMessageType().getFields();
    TypeInfo builder = builderRuntimeType(descriptor.getContainingType());
    return MethodRef.createInstanceMethod(
        builder,
        new Method(
            "put" + getFieldName(descriptor, true),
            builder.type(),
            new Type[] {getRuntimeType(mapFields.get(0)), getRuntimeType(mapFields.get(1))}));
  }