Opened 10 years ago

Closed 9 years ago

Last modified 9 years ago

#522 closed defect (fixed)

Model methods should accept decorators

Reported by: adrian Owned by: adrian
Component: Metasystem Version:
Severity: normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

Model methods don't accept decorators, and they should. Here's a snippet from imaurer on the django-developers mailing list:

The one thing I don't like is that I cannot add decorators like
classmethod. For instance, this method:

   @classmethod
   def clsmethod(cls):
       print "HERE in", cls

Blows up like this for me:

File "C:\www\django\core\meta\__init__.py", line 490, in __new__
   assert callable(v), "%r is an invalid model parameter." % k
AssertionError: 'clsmethod' is an invalid model parameter.

I am also not able to create a 'memoize' decorator for caching method
results in an instance. Instead, I either have to do the "if
_cache_blah: return _cache_blah" pattern in each method I want
cacheable or call out to a non-model function that can be memoized but
using a global LRU dictionary.

Change History (2)

comment:1 Changed 10 years ago by adrian

  • Status changed from new to assigned

comment:2 Changed 9 years ago by adrian

  • Resolution set to fixed
  • Status changed from assigned to closed

This is fixed in magic-removal.

Note: See TracTickets for help on using tickets.
Back to Top