def get_for_model(self, model):
        """
        Returns the ContentType object for a given model, creating the
        ContentType if necessary. Lookups are cached so that subsequent lookups
        for the same model don't hit the database.
        """
        opts = model._meta
        key = (opts.app_label, opts.object_name.lower())
        try:
            ct = self.__class__._cache[key]
        except __HOLE__:
            # Load or create the ContentType entry. The smart_unicode() is 
            # needed around opts.verbose_name_raw because name_raw might be a
            # django.utils.functional.__proxy__ object.
            ct, created = self.get_or_create(
                app_label = opts.app_label,
                model = opts.object_name.lower(), 
                defaults = {'name': smart_unicode(opts.verbose_name_raw)},
            )
            self._add_to_cache(ct)
            
        return ct
dataset/ETHPy150Open dcramer/django-compositepks/django/contrib/contenttypes/models.py/ContentTypeManager.get_for_model