[Django] #24946: Implement register_lookups

7 views
Skip to first unread message

Django

unread,
Jun 6, 2015, 4:34:33 PM6/6/15
to django-...@googlegroups.com
#24946: Implement register_lookups
----------------------------------------------+--------------------
Reporter: coldmind | Owner: nobody
Type: New feature | Status: new
Component: Database layer (models, ORM) | Version: master
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
----------------------------------------------+--------------------
I think it will be good to implement `register_lookups` method to more DRY
and prevent something like
{{{
SomeModel.register_lookup(L1)
SomeModel.register_lookup(L2)
SomeModel.register_lookup(L2)
}}}

So we will have
{{{
SomeModel.register_lookups([L1, L2, L3])
}}}

I think django code will become somewhat clearer.

--
Ticket URL: <https://code.djangoproject.com/ticket/24946>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Jun 6, 2015, 4:35:38 PM6/6/15
to django-...@googlegroups.com
#24946: Implement register_lookups
-------------------------------------+-------------------------------------

Reporter: coldmind | Owner: nobody
Type: New feature | Status: new
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by coldmind):

* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0


Comment:

If it is good to go, I will implement this

--
Ticket URL: <https://code.djangoproject.com/ticket/24946#comment:1>

Django

unread,
Jun 7, 2015, 3:40:53 PM6/7/15
to django-...@googlegroups.com
#24946: Implement register_lookups
-------------------------------------+-------------------------------------

Reporter: coldmind | Owner: nobody
Type: New feature | Status: new
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by coldmind):

* has_patch: 0 => 1


Comment:

Ticket is not accepted/declined yet. but anyway there is a PoC PR -
https://github.com/django/django/pull/4829

--
Ticket URL: <https://code.djangoproject.com/ticket/24946#comment:2>

Django

unread,
Jun 8, 2015, 1:49:05 AM6/8/15
to django-...@googlegroups.com
#24946: Implement register_lookups
-------------------------------------+-------------------------------------
Reporter: coldmind | Owner: nobody
Type: New feature | Status: closed

Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution: wontfix
Keywords: | Triage Stage:
| Unreviewed

Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by akaariai):

* status: new => closed
* resolution: => wontfix


Comment:

I'm not convinced we need this. Creating new lookups and transforms should
be somewhat rare, so just writing the couple extra characters to register
the lookup shouldn't be a problem when creating lookups/transforms.

I'm going to close this as wontfix. I don't feel too strongly about this,
so if some other core dev does see this as an useful addition, I'm not
going to object reopening this.

--
Ticket URL: <https://code.djangoproject.com/ticket/24946#comment:3>

Django

unread,
Jun 8, 2015, 1:52:07 AM6/8/15
to django-...@googlegroups.com
#24946: Implement register_lookups
-------------------------------------+-------------------------------------
Reporter: coldmind | Owner: nobody

Type: New feature | Status: closed
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution: wontfix
Keywords: | Triage Stage:
| Unreviewed

Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by carljm):

FWIW, I agree that this is not needed.

--
Ticket URL: <https://code.djangoproject.com/ticket/24946#comment:4>

Django

unread,
Jun 8, 2015, 6:26:31 AM6/8/15
to django-...@googlegroups.com
#24946: Implement register_lookups
-------------------------------------+-------------------------------------
Reporter: coldmind | Owner: nobody

Type: New feature | Status: closed
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution: wontfix
Keywords: | Triage Stage:
| Unreviewed

Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by coldmind):

> Creating new lookups and transforms should be somewhat rare

Well, will be it rare or not, there will more and more lookups and
transforms, so there will be more similar lines which is not DRY.

--
Ticket URL: <https://code.djangoproject.com/ticket/24946#comment:5>

Django

unread,
Jun 8, 2015, 10:47:13 AM6/8/15
to django-...@googlegroups.com
#24946: Implement register_lookups
-------------------------------------+-------------------------------------
Reporter: coldmind | Owner: nobody

Type: New feature | Status: closed
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution: wontfix
Keywords: | Triage Stage:
| Unreviewed

Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by carljm):

Replying to [comment:5 coldmind]:


> > Creating new lookups and transforms should be somewhat rare
> Well, will be it rare or not, there will more and more lookups and
transforms, so there will be more similar lines which is not DRY.

For what it's worth, IMO this is a mis-use of the concept of DRY. DRY
means that each piece of knowledge has one and only one authoritative
representation in the system. That is, it means that any given change to
the system should need to be made in one location, not simultaneously in
multiple different locations.

Registering multiple lookups with successive calls to `register_lookup` is
not a violation of DRY, because each piece of information (the fact that
lookup X is registered with the field, and the fact that lookup Y is
registered with the field, etc.) is captured in exactly one place (the
call to `register_lookup`). If that piece of information changes (lookup Y
should no longer be registered with the field) that change needs to be
made in one and only one place.

"A violation of DRY" is not the same thing as "I had to type more
characters than I would have preferred to type." It's not even the same
thing as "I had to type the same sequence of characters several times."

Conciseness is also of value in API design, but it's not the same issue as
DRY. Its value depends a great deal on frequency of use, and it has to be
weighed against other concerns, such as overall API size, confusing
similarity of one method with another (leading to indecision about which
method is the appropriate one to use), etc.

--
Ticket URL: <https://code.djangoproject.com/ticket/24946#comment:6>

Reply all
Reply to author
Forward
0 new messages