Opened 10 years ago

Closed 10 years ago

#23627 closed Cleanup/optimization (fixed)

Add a decorator for lookup registration.

Reported by: Marc Tamlyn Owned by: nobody
Component: Database layer (models, ORM) Version: 1.7
Severity: Normal Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Instead of:

class MyLookup(Lookup):
    lookup_name = 'foo'
    ...

MyField.register_lookup(MyLookup)

Allow:

@MyField.register_lookup
class MyLookup(Lookup):
    lookup_name = 'foo'
    ...

I guess we should be able to convert the existing function to work properly for both. We need to then use this functionality everywhere we do lookup registration.

Proposed by Aymeric and +1 from Anssi in https://github.com/django/django/pull/3219

Change History (3)

comment:1 by Marc Tamlyn, 10 years ago

Has patch: set

comment:2 by Tim Graham, 10 years ago

Triage Stage: AcceptedReady for checkin

comment:3 by Marc Tamlyn <marc.tamlyn@…>, 10 years ago

Resolution: fixed
Status: newclosed

In 92a17eaae081a213171b044858d6fc29df2df733:

Fixed #23627 -- Allowed register_lookup to work as a decorator.

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