def contribute_to_class(self, cls, name):
        self.name = name
        self.model = cls
        self.cache_attr = "_%s_cache" % name
        cls._meta.add_virtual_field(self)

        # For some reason I don't totally understand, using weakrefs here doesn't work.
        signals.pre_init.connect(self.instance_pre_init, sender=cls, weak=False)

        # Connect myself as the descriptor for this field
        setattr(cls, name, self)
dataset/ETHPy150Open AppScale/appscale/AppServer/lib/django-1.4/django/contrib/contenttypes/generic.py/GenericForeignKey.contribute_to_class/original