#20442: Stale ContentType objects cause a NoneType error in get_for_id
-------------------------------------+-------------------------------------
Reporter: vdboor | Owner: vdboor
Type: Bug | Status: assigned
Component: | Version: 1.4
contrib.contenttypes | Resolution:
Severity: Normal | Triage Stage:
Keywords: dceu13 | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by vdboor):
* status: new => assigned
* needs_better_patch: => 0
* type: Uncategorized => Bug
* needs_tests: => 0
* needs_docs: => 0
Comment:
I was thinking about solving this in a few possible ways:
* Let `_add_to_cache` use `(ct.app_label, ct.model)` as key instead of the
model object. I think they are always identical, so this would allow
caching the stale content type. Nothing changes for calling code, they
still need to check whether `ct.model_class()` returns `None` as it
explicitly does already.
* Raise a `StaleContentTypeError` in `get_for_id()`. This would require
updating code everywhere else too.
* Raise a `ContentType.DoesNotExist`. This gives consistent output from
`ContentType.objects.get_for_id()` I don't like it as will leak out the
inconsistency elsewhere.
My preference goes to the first option.
--
Ticket URL: <https://code.djangoproject.com/ticket/20442#comment:1>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.