#12776 closed (fixed)
get_profile() may throw AttributeError instead of SiteProfileNotAvailable
Reported by: | master | Owned by: | nobody |
---|---|---|---|
Component: | contrib.auth | Version: | 1.1 |
Severity: | Keywords: | profile | |
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
I didn't find a case to fire:
except (ImportError, ImproperlyConfigured)
But some others cases :
In AUTH_PROFILE_MODULE, if:
- you don't provide a '.': 'accountsUserProfile'
==> ValueError
- you mispell or forget the app_label part or the model_name part: 'accounts.', 'accXXXounts.UserProfile'
No exception is raised and the variable 'model' is returned as None.
==> AttributeError on following line: 'NoneType' object has no attribute '_default_manager'
I needed something similar for my own code, that I wrote as:
try: ... model = ... if not model: raise SiteProfileNotAvailable ... except ValueError: raise SiteProfileNotAvailable
Attachments (1)
Change History (6)
comment:1 by , 15 years ago
milestone: | → 1.2 |
---|---|
Triage Stage: | Unreviewed → Accepted |
by , 15 years ago
Attachment: | 12776.patch added |
---|
comment:2 by , 15 years ago
Added a patch with tests. The patch adds some more human-friendly errors as well, to be reviewed by a native English speaker.
comment:3 by , 15 years ago
Triage Stage: | Accepted → Ready for checkin |
---|
Note:
See TracTickets
for help on using tickets.
Throws more SiteProfileNotAvailable, adds some verbosity