sopel had the idea of a GenericForeignKey, which would abstract the concept of "content_type_id" and "object_id". Basically, it'd be a way to relate an object to "one of several types of objects."
For example, we currently have this in the Comment model:
class Comment(meta.Model):
# ...
content_type = meta.ForeignKey(core.ContentType)
object_id = meta.IntegerField()
That could be replaced with this:
class Comment(meta.Model):
# ...
content_object = meta.GenericForeignKey()
With that, Comment objects would get an automatic get_content_object() method, which would return whatever object was related, regardless of its type.
This is a messy problem, so we'd have to figure out a couple of loose ends:
- Does every other object in the system get a get_comment_list method?
- Do we enforce referential integrity, so that, for example, all the appropriate comments would be deleted if a story was deleted?