Opened 16 years ago

Closed 16 years ago

#7249 closed (invalid)

Better code for 7535 fix

Reported by: leotr Owned by: nobody
Component: contrib.admin Version: dev
Severity: Keywords:
Cc: Triage Stage: Design decision needed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

-                    users = list(User.objects.filter(email=username))
-                    if len(users) == 1:
-                        user = users[0]
-                    else:
-                        # Either we cannot find the user, or if more than 1
-                        # we cannot guess which user is the correct one.
-                        raise User.DoesNotExist()

I think that mine is more elegant. Just add AssertionError to exception list.

Attachments (1)

1.diff (1.2 KB ) - added by leotr 16 years ago.

Download all attachments as: .zip

Change History (4)

by leotr, 16 years ago

Attachment: 1.diff added

comment:2 by leotr, 16 years ago

Triage Stage: UnreviewedDesign decision needed

In other words i don't see a reason to evaluate a query and then check the length of list. The AssertionError is raised when more than 1 object exist.

comment:3 by leotr, 16 years ago

Resolution: invalid
Status: newclosed

Invalid after changeset 7536

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