makes a "field" on this model called rdf_type
 and sets a class level _RDF_TYPE variable with the rdf_type passed in.
960078
def rdf_type(new_rdf_type)
      self._RDF_TYPE = RDF::URI.new(new_rdf_type.to_s)
      field :rdf_type, RDF.type, :multivalued => true, :is_uri => true # things can have more than 1 type and often do
    end
595498
def _create_model_by_type(self, type):
        
        klass = None
        for cls in eloquent.orm.model.Model.__subclasses__():
            morph_class = cls.__morph_class__ or cls.__name__
            if morph_class == type:
                klass = cls
                break

        return klass()
208799
def build_relational_field(self, field_name, relation_info):
        
        field_class = self.serializer_related_field
        field_kwargs = get_relation_kwargs(field_name, relation_info)

        to_field = field_kwargs.pop('to_field', None)
        if to_field and not relation_info.related_model._meta.get_field(to_field).primary_key:
            field_kwargs['slug_field'] = to_field
            field_class = self.serializer_related_to_field

        # `view_name` is only valid for hyperlinked relationships.
        if not issubclass(field_class, HyperlinkedRelatedField):
            field_kwargs.pop('view_name', None)

        return field_class, field_kwargs
722590
def _build_field_type_map(base_class):
    """"""
    mapping = {}

    for cls in _get_recursive_subclasses(base_class):
        if cls.field_type:
            if isinstance(cls.field_type, tuple):
                for field_type in cls.field_type:
                    mapping[field_type] = cls
            elif isinstance(cls.field_type, _string_types):
                mapping[cls.field_type] = cls
            else:
                raise ValueError('Field type must be str or tuple, cannot understand type "{}" on class "{}"'.format(
                    type(cls.field_type),
                    cls
                ))

    return mapping
208218
def create_many_to_many_intermediary_model(field, klass):
    
    managed = True
    if (isinstance(field.remote_field.to, basestring) and
            field.remote_field.to != related.RECURSIVE_RELATIONSHIP_CONSTANT):
        to_model = field.remote_field.to
        to = to_model.split('.')[-1]

        def set_managed(field, model, cls):
            managed = model._meta.managed or cls._meta.managed
            if issubclass(cls, VersionView):
                managed = False
            field.remote_field.through._meta.managed = managed
        related.add_lazy_relation(klass, field, to_model, set_managed)
    elif isinstance(field.remote_field.to, basestring):
        to = klass._meta.object_name
        to_model = klass
        managed = klass._meta.managed
    else:
        to = field.remote_field.to._meta.object_name
        to_model = field.remote_field.to
        managed = klass._meta.managed or to_model._meta.managed
        if issubclass(klass, VersionView):
            managed = False

    name = '%s_%s' % (klass._meta.object_name, field.name)
    if (field.remote_field.to == related.RECURSIVE_RELATIONSHIP_CONSTANT or
            to == klass._meta.object_name):
        from_ = 'from_%s' % to.lower()
        to = 'to_%s' % to.lower()
    else:
        from_ = klass._meta.object_name.lower()
        to = to.lower()
    meta = type('Meta', (object,), {
        'db_table': field._get_m2m_db_table(klass._meta),
        'managed': managed,
        'auto_created': klass,
        'app_label': klass._meta.app_label,
        'db_tablespace': klass._meta.db_tablespace,
        'unique_together': ('from', 'to'),
        'verbose_name': '%(from)s-%(to)s relationship' % {
            'from': from_, 'to': to},
        'verbose_name_plural': '%(from)s-%(to)s relationships' % {
            'from': from_, 'to': to},
        'apps': field.model._meta.apps,
    })

    # Construct and return the new class.
    return type(str(name), (models.Model,), {
        'Meta': meta,
        '__module__': klass.__module__,
        'from': FKToVersion(klass, related_name='%s+' % name,
                            db_tablespace=field.db_tablespace,
                            db_constraint=field.remote_field.db_constraint),
        'to': models.ForeignKey(to_model, related_name='%s+' % name,
                                db_tablespace=field.db_tablespace,
                                db_constraint=field.remote_field.db_constraint)
    })
1194132
def _create_plain_field(self, attr, options):
        """"""
        method = self._get_field_method(attr.py_type) or self._create_other_field
        klass, options = method(attr, options)

        if attr.is_unique:
            options['validators'].append(validators.UniqueEntityValidator(attr.entity))

        return klass, options
87394
def create_values(self, base_model=models.Model, base_manager=models.Manager):
        

        _builder = self

        class CustomContentTypeFieldValueManager(base_manager):
            def create(self, **kwargs):
                """
                Subclass create in order to be able to use "value" in kwargs
                instead of using "value_%s" passing also type directly
                """
                if 'value' in kwargs:
                    value = kwargs.pop('value')
                    created_object = super(CustomContentTypeFieldValueManager, self).create(**kwargs)
                    created_object.value = value
                    return created_object
                else:
                    return super(CustomContentTypeFieldValueManager, self).create(**kwargs)

        @python_2_unicode_compatible
        class CustomContentTypeFieldValue(base_model):
            custom_field = models.ForeignKey('.'.join(_builder.fields_model),
                                             verbose_name=_('custom field'),
                                             related_name='+')
            content_type = models.ForeignKey(ContentType, editable=False,
                                             verbose_name=_('content type'),
                                             limit_choices_to=_builder.content_types_query)
            object_id = models.PositiveIntegerField(_('object id'), db_index=True)
            content_object = GenericForeignKey('content_type', 'object_id')

            value_text = models.TextField(blank=True, null=True)
            value_integer = models.IntegerField(blank=True, null=True)
            value_float = models.FloatField(blank=True, null=True)
            value_time = models.TimeField(blank=True, null=True)
            value_date = models.DateField(blank=True, null=True)
            value_datetime = models.DateTimeField(blank=True, null=True)
            value_boolean = models.NullBooleanField(blank=True)

            objects = CustomContentTypeFieldValueManager()

            def _get_value(self):
                return getattr(self, 'value_%s' % self.custom_field.data_type)

            def _set_value(self, new_value):
                setattr(self, 'value_%s' % self.custom_field.data_type, new_value)

            value = property(_get_value, _set_value)

            class Meta:
                unique_together = ('custom_field', 'content_type', 'object_id')
                verbose_name = _('custom field value')
                verbose_name_plural = _('custom field values')
                abstract = True

            def save(self, *args, **kwargs):
                # save content type as user shouldn't be able to change it
                self.content_type = self.custom_field.content_type
                super(CustomContentTypeFieldValue, self).save(*args, **kwargs)

            def validate_unique(self, exclude=None):
                qs = self.__class__._default_manager.filter(
                    custom_field=self.custom_field,
                    content_type=self.custom_field.content_type,
                    object_id=self.object_id,
                )
                if not self._state.adding and self.pk is not None:
                    qs = qs.exclude(pk=self.pk)
                if qs.exists():
                    raise ValidationError({ NON_FIELD_ERRORS: (_('A value for this custom field already exists'),) })

            def __str__(self):
                return "%s: %s" % (self.custom_field.name, self.value)

        return CustomContentTypeFieldValue
896419
def update_relation(field_name, *obj)
      # Should be an Array of RDF::Term objects
      return unless obj

      obj.map! { |item| item.is_a?(RDF::URI) ? Ladder::Resource.from_uri(item) : item }
      relation = send(field_name)

      if Mongoid::Relations::Targets::Enumerable == relation.class
        obj.map { |item| relation.send(:push, item) unless relation.include? item }
      else
        send("#{field_name}=", obj.size > 1 ? obj : obj.first)
      end
    end
997295
def build_nested_field(self, field_name, relation_info, nested_depth):
        
        if field_name != 'children':
            return super(PriceEstimateSerializer, self).build_nested_field(field_name, relation_info, nested_depth)
        field_class = self.__class__
        field_kwargs = {'read_only': True, 'many': True, 'context': {'depth': nested_depth - 1}}
        return field_class, field_kwargs
688380
def field(self, name, fieldType="C", size="50", decimal=0):
        """"""
        if fieldType == "D":
            size = "8"
            decimal = 0
        elif fieldType == "L":
            size = "1"
            decimal = 0
        if len(self.fields) >= 2046:
            raise ShapefileException(
                "Shapefile Writer reached maximum number of fields: 2046.")
        self.fields.append((name, fieldType, size, decimal))
553648
private static void setField(Class<?> expectedType, Object value, boolean saveOriginal) throws IllegalStateException {
        try {
            for (Field field : NamingManager.class.getDeclaredFields()) {
                if (expectedType.equals(field.getType())) {
                    field.setAccessible(true);
                    if (saveOriginal) {
                        if (expectedType.equals(InitialContextFactoryBuilder.class)) {
                            originalICFBuilder = (InitialContextFactoryBuilder) field.get(null);
                        } else {
                            originalOFBuilder = (ObjectFactoryBuilder) field.get(null);
                        }
                    }

                    field.set(null, value);
                }
            }
        } catch (Throwable t) {
            // Ignore
            LOGGER.debug("Error setting field.", t);
            throw new IllegalStateException(t);
        }
    }
614384
def generate_field(name, data):
    
    assert 'type' in data
    field = TYPES_TO_FIELDS.get(data['type'], Unknown)(name, data)
    return field
1026949
def set_class_dict(self):
        

        self.class_dict = {}
        for name, cls_defs in self.defs.items():
            def_type = set(cls_defs.get(self.rdf_type, []))
            if name.type == 'bnode':
                continue
            # a class can be determined by checking to see if it is of an
            # rdf_type listed in the classes_key or has a property that is
            # listed in the inferred_key
            if def_type.intersection(self.classes_key) or \
                    list([cls_defs.get(item) for item in self.inferred_key]):
                self.class_dict[name] = cls_defs
854096
def field_type(field):
    
    if hasattr(field, 'field') and field.field:
        return field.field.__class__.__name__.lower()
    return ''
825566
def contribute_to_class(self, model, name, **kwargs):
        
        super(LocalizedField, self).contribute_to_class(model, name, **kwargs)
        setattr(model, self.name, self.descriptor_class(self))
705853
private FieldDefinition declareTypeField()
    {
        FieldDefinition typeField = new FieldDefinition(a(PRIVATE, FINAL), "type", type(ThriftType.class));
        classDefinition.addField(typeField);

        // add constructor parameter to initialize this field
        parameters.add(typeField, ThriftType.struct(metadata));

        return typeField;
    }
1089861
def rdfs_classes(rdf):
    """"""

    # find out the subclass mappings
    upperclasses = {}  # key: class val: set([superclass1, superclass2..])
    for s, o in rdf.subject_objects(RDFS.subClassOf):
        upperclasses.setdefault(s, set())
        for uc in rdf.transitive_objects(s, RDFS.subClassOf):
            if uc != s:
                upperclasses[s].add(uc)

    # set the superclass type information for subclass instances
    for s, ucs in upperclasses.items():
        logging.debug("setting superclass types: %s -> %s", s, str(ucs))
        for res in rdf.subjects(RDF.type, s):
            for uc in ucs:
                rdf.add((res, RDF.type, uc))