| 1 | from functoolsscip-python python python-stdlib 3.11 functools/__init__: import partialscip-python python python-stdlib 3.11 functools/partial# |
| 2 | from tastypiescip-python python django-tastypie 0.15.1 tastypie/__init__: import fieldsscip-python python django-tastypie 0.15.1 `tastypie.fields`/__init__: |
| 3 | from tastypie.resourcesscip-python python django-tastypie 0.15.1 `tastypie.resources`/__init__: import Resourcescip-python python django-tastypie 0.15.1 `tastypie.resources`/Resource# |
| 4 | from tastypie.exceptionsscip-python python django-tastypie 0.15.1 `tastypie.exceptions`/__init__: import ApiFieldErrorscip-python python django-tastypie 0.15.1 `tastypie.exceptions`/ApiFieldError# |
| 5 | from django.dbscip-python python django-tastypie 0.15.1 `django.db`/__init__: import models |
| 6 | from django.core.exceptionsscip-python python django-tastypie 0.15.1 `django.core.exceptions`/__init__: import ObjectDoesNotExist |
| 7 | from .resourcesscip-python python django-tastypie 0.15.1 resources/__init__: import GenericResourcescip-python python django-tastypie 0.15.1 `tastypie.contrib.contenttypes.resources`/GenericResource# |
| 8 | |
| 9 | |
| 10 | class GenericForeignKeyFieldscip-python python django-tastypie 0.15.1 `tastypie.contrib.contenttypes.fields`/GenericForeignKeyField#(fieldsscip-python python django-tastypie 0.15.1 `tastypie.fields`/__init__:.ToOneFieldscip-python python django-tastypie 0.15.1 `tastypie.fields`/ToOneField#): |
| 11 | """ |
| 12 | Provides access to GenericForeignKey objects from the django content_types |
| 13 | framework. |
| 14 | """ |
| 15 | |
| 16 | def __init__scip-python python django-tastypie 0.15.1 `tastypie.contrib.contenttypes.fields`/GenericForeignKeyField#__init__().(selfscip-python python django-tastypie 0.15.1 `tastypie.contrib.contenttypes.fields`/GenericForeignKeyField#__init__().(self), toscip-python python django-tastypie 0.15.1 `tastypie.contrib.contenttypes.fields`/GenericForeignKeyField#__init__().(to), attributescip-python python django-tastypie 0.15.1 `tastypie.contrib.contenttypes.fields`/GenericForeignKeyField#__init__().(attribute), **kwargsscip-python python django-tastypie 0.15.1 `tastypie.contrib.contenttypes.fields`/GenericForeignKeyField#__init__().(kwargs)): |
| 17 | if not isinstance(toscip-python python django-tastypie 0.15.1 `tastypie.contrib.contenttypes.fields`/GenericForeignKeyField#__init__().(to), dictscip-python python python-stdlib 3.11 builtins/dict#): |
| 18 | raise ValueErrorscip-python python python-stdlib 3.11 builtins/ValueError#('to field must be a dictionary in GenericForeignKeyField') |
| 19 | |
| 20 | if len(toscip-python python django-tastypie 0.15.1 `tastypie.contrib.contenttypes.fields`/GenericForeignKeyField#__init__().(to)) <= 0: |
| 21 | raise ValueErrorscip-python python python-stdlib 3.11 builtins/ValueError#('to field must have some values') |
| 22 | |
| 23 | for k, v in toscip-python python django-tastypie 0.15.1 `tastypie.contrib.contenttypes.fields`/GenericForeignKeyField#__init__().(to).itemsscip-python python python-stdlib 3.11 builtins/dict#items().(): |
| 24 | if not issubclass(k, models.Model) or not issubclass(v, Resourcescip-python python django-tastypie 0.15.1 `tastypie.resources`/Resource#): |
| 25 | raise ValueErrorscip-python python python-stdlib 3.11 builtins/ValueError#('to field must map django models to tastypie resources') |
| 26 | |
| 27 | superscip-python python python-stdlib 3.11 builtins/super#(GenericForeignKeyFieldscip-python python django-tastypie 0.15.1 `tastypie.contrib.contenttypes.fields`/GenericForeignKeyField#, selfscip-python python django-tastypie 0.15.1 `tastypie.contrib.contenttypes.fields`/GenericForeignKeyField#__init__().(self)).__init__scip-python python django-tastypie 0.15.1 `tastypie.fields`/ToOneField#__init__().(toscip-python python django-tastypie 0.15.1 `tastypie.contrib.contenttypes.fields`/GenericForeignKeyField#__init__().(to), attributescip-python python django-tastypie 0.15.1 `tastypie.contrib.contenttypes.fields`/GenericForeignKeyField#__init__().(attribute), **kwargsscip-python python django-tastypie 0.15.1 `tastypie.contrib.contenttypes.fields`/GenericForeignKeyField#__init__().(kwargs)) |
| 28 | |
| 29 | def get_related_resourcescip-python python django-tastypie 0.15.1 `tastypie.contrib.contenttypes.fields`/GenericForeignKeyField#get_related_resource().(selfscip-python python django-tastypie 0.15.1 `tastypie.contrib.contenttypes.fields`/GenericForeignKeyField#get_related_resource().(self), related_instancescip-python python django-tastypie 0.15.1 `tastypie.contrib.contenttypes.fields`/GenericForeignKeyField#get_related_resource().(related_instance)): |
| 30 | selfscip-python python django-tastypie 0.15.1 `tastypie.contrib.contenttypes.fields`/GenericForeignKeyField#get_related_resource().(self)._to_classscip-python python django-tastypie 0.15.1 `tastypie.contrib.contenttypes.fields`/GenericForeignKeyField#_to_class. = selfscip-python python django-tastypie 0.15.1 `tastypie.contrib.contenttypes.fields`/GenericForeignKeyField#get_related_resource().(self).toscip-python python django-tastypie 0.15.1 `tastypie.fields`/RelatedField#to..get(typescip-python python python-stdlib 3.11 builtins/type#(related_instancescip-python python django-tastypie 0.15.1 `tastypie.contrib.contenttypes.fields`/GenericForeignKeyField#get_related_resource().(related_instance)), None) |
| 31 | |
| 32 | if selfscip-python python django-tastypie 0.15.1 `tastypie.contrib.contenttypes.fields`/GenericForeignKeyField#get_related_resource().(self)._to_classscip-python python django-tastypie 0.15.1 `tastypie.contrib.contenttypes.fields`/GenericForeignKeyField#_to_class. is None: |
| 33 | raise TypeErrorscip-python python python-stdlib 3.11 builtins/TypeError#('no resource for model %s' % typescip-python python python-stdlib 3.11 builtins/type#(related_instancescip-python python django-tastypie 0.15.1 `tastypie.contrib.contenttypes.fields`/GenericForeignKeyField#get_related_resource().(related_instance))) |
| 34 | |
| 35 | return superscip-python python python-stdlib 3.11 builtins/super#(GenericForeignKeyFieldscip-python python django-tastypie 0.15.1 `tastypie.contrib.contenttypes.fields`/GenericForeignKeyField#, selfscip-python python django-tastypie 0.15.1 `tastypie.contrib.contenttypes.fields`/GenericForeignKeyField#get_related_resource().(self)).get_related_resourcescip-python python django-tastypie 0.15.1 `tastypie.fields`/RelatedField#get_related_resource().(related_instancescip-python python django-tastypie 0.15.1 `tastypie.contrib.contenttypes.fields`/GenericForeignKeyField#get_related_resource().(related_instance)) |
| 36 | |
| 37 | @propertyscip-python python python-stdlib 3.11 builtins/property# |
| 38 | def to_classscip-python python django-tastypie 0.15.1 `tastypie.contrib.contenttypes.fields`/GenericForeignKeyField#to_class().(selfscip-python python django-tastypie 0.15.1 `tastypie.contrib.contenttypes.fields`/GenericForeignKeyField#to_class().(self)): |
| 39 | if selfscip-python python django-tastypie 0.15.1 `tastypie.contrib.contenttypes.fields`/GenericForeignKeyField#to_class().(self)._to_classscip-python python django-tastypie 0.15.1 `tastypie.contrib.contenttypes.fields`/GenericForeignKeyField#_to_class. and not issubclass(GenericResourcescip-python python django-tastypie 0.15.1 `tastypie.contrib.contenttypes.resources`/GenericResource#, selfscip-python python django-tastypie 0.15.1 `tastypie.contrib.contenttypes.fields`/GenericForeignKeyField#to_class().(self)._to_classscip-python python django-tastypie 0.15.1 `tastypie.contrib.contenttypes.fields`/GenericForeignKeyField#_to_class.): |
| 40 | return selfscip-python python django-tastypie 0.15.1 `tastypie.contrib.contenttypes.fields`/GenericForeignKeyField#to_class().(self)._to_classscip-python python django-tastypie 0.15.1 `tastypie.contrib.contenttypes.fields`/GenericForeignKeyField#_to_class. |
| 41 | |
| 42 | return partialscip-python python python-stdlib 3.11 functools/partial#(GenericResourcescip-python python django-tastypie 0.15.1 `tastypie.contrib.contenttypes.resources`/GenericResource#, resources=selfscip-python python django-tastypie 0.15.1 `tastypie.contrib.contenttypes.fields`/GenericForeignKeyField#to_class().(self).toscip-python python django-tastypie 0.15.1 `tastypie.fields`/RelatedField#to..values()) |
| 43 | |
| 44 | def resource_from_uriscip-python python django-tastypie 0.15.1 `tastypie.contrib.contenttypes.fields`/GenericForeignKeyField#resource_from_uri().(selfscip-python python django-tastypie 0.15.1 `tastypie.contrib.contenttypes.fields`/GenericForeignKeyField#resource_from_uri().(self), fk_resourcescip-python python django-tastypie 0.15.1 `tastypie.contrib.contenttypes.fields`/GenericForeignKeyField#resource_from_uri().(fk_resource), uriscip-python python django-tastypie 0.15.1 `tastypie.contrib.contenttypes.fields`/GenericForeignKeyField#resource_from_uri().(uri), requestscip-python python django-tastypie 0.15.1 `tastypie.contrib.contenttypes.fields`/GenericForeignKeyField#resource_from_uri().(request)=None, related_objscip-python python django-tastypie 0.15.1 `tastypie.contrib.contenttypes.fields`/GenericForeignKeyField#resource_from_uri().(related_obj)=None, related_namescip-python python django-tastypie 0.15.1 `tastypie.contrib.contenttypes.fields`/GenericForeignKeyField#resource_from_uri().(related_name)=None): |
| 45 | try: |
| 46 | obj = fk_resourcescip-python python django-tastypie 0.15.1 `tastypie.contrib.contenttypes.fields`/GenericForeignKeyField#resource_from_uri().(fk_resource).get_via_uri(uriscip-python python django-tastypie 0.15.1 `tastypie.contrib.contenttypes.fields`/GenericForeignKeyField#resource_from_uri().(uri), request=requestscip-python python django-tastypie 0.15.1 `tastypie.contrib.contenttypes.fields`/GenericForeignKeyField#resource_from_uri().(request)) |
| 47 | fk_resourcescip-python python django-tastypie 0.15.1 `tastypie.contrib.contenttypes.fields`/GenericForeignKeyField#resource_from_uri().(fk_resource) = selfscip-python python django-tastypie 0.15.1 `tastypie.contrib.contenttypes.fields`/GenericForeignKeyField#resource_from_uri().(self).get_related_resourcescip-python python django-tastypie 0.15.1 `tastypie.contrib.contenttypes.fields`/GenericForeignKeyField#get_related_resource().(obj) |
| 48 | return superscip-python python python-stdlib 3.11 builtins/super#(GenericForeignKeyFieldscip-python python django-tastypie 0.15.1 `tastypie.contrib.contenttypes.fields`/GenericForeignKeyField#, selfscip-python python django-tastypie 0.15.1 `tastypie.contrib.contenttypes.fields`/GenericForeignKeyField#resource_from_uri().(self)).resource_from_uriscip-python python django-tastypie 0.15.1 `tastypie.fields`/RelatedField#resource_from_uri().(fk_resourcescip-python python django-tastypie 0.15.1 `tastypie.contrib.contenttypes.fields`/GenericForeignKeyField#resource_from_uri().(fk_resource), uriscip-python python django-tastypie 0.15.1 `tastypie.contrib.contenttypes.fields`/GenericForeignKeyField#resource_from_uri().(uri), requestscip-python python django-tastypie 0.15.1 `tastypie.contrib.contenttypes.fields`/GenericForeignKeyField#resource_from_uri().(request), related_objscip-python python django-tastypie 0.15.1 `tastypie.contrib.contenttypes.fields`/GenericForeignKeyField#resource_from_uri().(related_obj), related_namescip-python python django-tastypie 0.15.1 `tastypie.contrib.contenttypes.fields`/GenericForeignKeyField#resource_from_uri().(related_name)) |
| 49 | except ObjectDoesNotExist: |
| 50 | raise ApiFieldErrorscip-python python django-tastypie 0.15.1 `tastypie.exceptions`/ApiFieldError#("Could not find the provided object via resource URI '%s'." % uriscip-python python django-tastypie 0.15.1 `tastypie.contrib.contenttypes.fields`/GenericForeignKeyField#resource_from_uri().(uri)) |
| 51 | |
| 52 | def build_related_resourcescip-python python django-tastypie 0.15.1 `tastypie.contrib.contenttypes.fields`/GenericForeignKeyField#build_related_resource().(selfscip-python python django-tastypie 0.15.1 `tastypie.contrib.contenttypes.fields`/GenericForeignKeyField#build_related_resource().(self), *argsscip-python python django-tastypie 0.15.1 `tastypie.contrib.contenttypes.fields`/GenericForeignKeyField#build_related_resource().(args), **kwargsscip-python python django-tastypie 0.15.1 `tastypie.contrib.contenttypes.fields`/GenericForeignKeyField#build_related_resource().(kwargs)): |
| 53 | selfscip-python python django-tastypie 0.15.1 `tastypie.contrib.contenttypes.fields`/GenericForeignKeyField#build_related_resource().(self)._to_classscip-python python django-tastypie 0.15.1 `tastypie.contrib.contenttypes.fields`/GenericForeignKeyField#_to_class. = None |
| 54 | return superscip-python python python-stdlib 3.11 builtins/super#(GenericForeignKeyFieldscip-python python django-tastypie 0.15.1 `tastypie.contrib.contenttypes.fields`/GenericForeignKeyField#, selfscip-python python django-tastypie 0.15.1 `tastypie.contrib.contenttypes.fields`/GenericForeignKeyField#build_related_resource().(self)).build_related_resourcescip-python python django-tastypie 0.15.1 `tastypie.fields`/RelatedField#build_related_resource().(*argsscip-python python django-tastypie 0.15.1 `tastypie.contrib.contenttypes.fields`/GenericForeignKeyField#build_related_resource().(args), **kwargsscip-python python django-tastypie 0.15.1 `tastypie.contrib.contenttypes.fields`/GenericForeignKeyField#build_related_resource().(kwargs)) |