django.core.checks.register shouldn't be (primarily) a decorator

69 views
Skip to first unread message

Shai Berger

unread,
Jan 22, 2014, 7:29:30 PM1/22/14
to django-d...@googlegroups.com
Hi,

I took a look at PR 2192[1] earlier, and noted that checks.register keeps
being used as a function, called from AppConfig.ready(), and not as a
decorator; but it is defined as a decorator, so it looks a little funny:

checks.register('models')(check_generic_foreign_keys)

(from the contenttypes AppConfig, for example).

Registering checks only in ready(), rather than at import time, is now the way
to do things, so register() should typically not be used as a decorator; I
think we should change its definition accordingly, to

def register(self, check, *tags)

Thoughts?

[1] https://github.com/django/django/pull/2192

Russell Keith-Magee

unread,
Jan 22, 2014, 7:37:03 PM1/22/14
to Django Developers
That's a fair point. The decorator mode of registration has effectively been deprecated by the move to using ready() (since there's almost certainly no way to use it in practice. Altering the prototype to reflect this makes sense to me.

Russ %-)

Marc Tamlyn

unread,
Jan 23, 2014, 3:32:56 AM1/23/14
to django-d...@googlegroups.com
Assuming my change to ready() does happen, I think we should also document using it in the checks documentation.

Marc


--
You received this message because you are subscribed to the Google Groups "Django developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-develop...@googlegroups.com.
To post to this group, send email to django-d...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-developers.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/CAJxq84-xRN7KSvTq3S7UAZaSBNerCHr6T6_OF6V0JqhPXMs-dg%40mail.gmail.com.

For more options, visit https://groups.google.com/groups/opt_out.

Reply all
Reply to author
Forward
0 new messages