Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion cache_toolbox/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,14 @@ def instance_key(model, instance_or_pk):
Returns the cache key for this (model, instance) pair.
"""

try:
model_name = model._meta.model_name
except AttributeError:
# Django version <1.6
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using a previous django version isn't exactly an exceptional situation, so rather than handling an exception here you ought to be using getattr.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also missing "pass" or something so this isn't a hanging block

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pass is only used to mark an empty block as being empty. This isn't an empty block.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh it got interrupted by these comments

model_name = model._meta.module_name

return '%s.%s:%d' % (
model._meta.app_label,
model._meta.module_name,
model_name,
getattr(instance_or_pk, 'pk', instance_or_pk),
)