Opened 18 years ago
Closed 18 years ago
#3448 closed (fixed)
python help() parsing problem for django.core.mail
Reported by: | Owned by: | Jacob | |
---|---|---|---|
Component: | Documentation | Version: | dev |
Severity: | Keywords: | django.core.mail, help, docs | |
Cc: | poj+django@… | 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
Error when accessing django.core.mail through python help()
EnvironmentError: Environment variable DJANGO_SETTINGS_MODULE is undefined
In python help(), if I do:
help> django.core.mail
I get:
problem in django.core.mail - EnvironmentError: Environment variable DJANGO_SETTINGS_MODULE is undefined.
Other things in the django.core package display their docstrings and such.. It seems like something basic, but I didn't see anything obvious.
I'm on OS X 10.4.8, python 2.4.4, installed the source from the svn repository, e.g. 'python setup.py install'
Attachments (2)
Change History (9)
comment:1 by , 18 years ago
Triage Stage: | Unreviewed → Design decision needed |
---|
comment:2 by , 18 years ago
Triage Stage: | Design decision needed → Accepted |
---|
The change suggested by SmileyChris is indeed the correct fix. We should never refer to settings.*
in default arguments because it removes the ability to manually configure the settings (via settings.configure()
), as well as causing problems as in this bug. Use None
for the default argument (which is read at import time) and inside the function do test for None and replace it with the settings.XYZ
value; we require settings to have already be configured in some fashion before actually executing any functions, so this is safe.
by , 18 years ago
Attachment: | core_mail_help.diff added |
---|
comment:4 by , 18 years ago
Cc: | added |
---|---|
Has patch: | set |
I've written a patch that implements the suggestions in this ticket.
comment:5 by , 18 years ago
Triage Stage: | Accepted → Ready for checkin |
---|
by , 18 years ago
Attachment: | core_mail_help-v2.diff added |
---|
comment:6 by , 18 years ago
Realised when reading another ticket that the original patch didn't update the documentation in docs/email.txt
The new version fixes that problem.
I'd guess it's due to the following lines:
It could be fixed rather easily by setting those default arguments inside of the functions if they're
None
. Alternately, you could just set the environment variable or usemanage.py shell
.Marked as decision needed since it's pretty trivial. If someone who cared was to write up a patch, it may convince a committer to patch rather than close ;)