Django

Code

Ticket #7249 (closed: invalid)

Opened 2 months ago

Last modified 2 months ago

Better code for 7535 fix

Reported by: leotr Assigned to: nobody
Milestone: Component: Admin interface
Version: SVN Keywords:
Cc: Triage Stage: Design decision needed
Has patch: 1 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

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.diff (1.2 kB) - added by leotr on 05/16/08 06:41:29.

Change History

05/16/08 06:41:29 changed by leotr

  • attachment 1.diff added.

05/16/08 06:45:23 changed by leotr

  • needs_better_patch changed.
  • needs_tests changed.
  • needs_docs changed.

05/19/08 01:11:08 changed by leotr

  • stage changed from Unreviewed to Design 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.

05/19/08 01:24:30 changed by leotr

  • status changed from new to closed.
  • resolution set to invalid.

Invalid after changeset 7536


Add/Change #7249 (Better code for 7535 fix)




Change Properties
Action