#13641: The location of the get_connection() function does not correspond with 
the
documentation
------------------------------------+---------------------------------------
          Reporter:  caumons        |         Owner:  nobody                    
                       
            Status:  closed         |     Milestone:                            
                       
         Component:  Documentation  |       Version:  1.1                       
                       
        Resolution:  invalid        |      Keywords:  email, connection, 
get_connection, SMTPConnection
             Stage:  Unreviewed     |     Has_patch:  0                         
                       
        Needs_docs:  0              |   Needs_tests:  0                         
                       
Needs_better_patch:  0              |  
------------------------------------+---------------------------------------
Changes (by kmtracey):

  * status:  new => closed
  * needs_better_patch:  => 0
  * needs_tests:  => 0
  * needs_docs:  => 0
  * resolution:  => invalid

Old description:

> If we try to import the get_connection() function from django.core.mail
> as specified in the documentation we get the following ImportError in
> Django 1.1.1:
>
> Python 2.6.4 (r264:75706, Dec  7 2009, 18:43:55)
> [GCC 4.4.1] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
> (InteractiveConsole)
> >>> from django.core.mail import get_connection
> Traceback (most recent call last):
>   File "<console>", line 1, in <module>
> ImportError: cannot import name get_connection
>
> Looking at the source code of the module situated at
> /usr/local/lib/python2.6/dist-packages/django/core/mail.py we can check
> that no get_connection() is declared in the module.
> If we want to create a connection to send emails, we have to instantiate
> the SMTPConnection class and then call its methods. For example:
>
> mailConnection = SMTPConnection()
> mailConnection.open()
> mailConnection.send_messages([email1, email2])
> mailConnection.close()
>
> get_connection(self, fail_silently=False) is a method inside the
> EmailMessage class situated in line 228 and used in line 266, not a
> function.
>
> The solution I see is to update the documentation referring to emails
> section.

New description:

 If we try to import the get_connection() function from django.core.mail as
 specified in the documentation we get the following ImportError in Django
 1.1.1:
 {{{
 Python 2.6.4 (r264:75706, Dec  7 2009, 18:43:55)
 [GCC 4.4.1] on linux2
 Type "help", "copyright", "credits" or "license" for more information.
 (InteractiveConsole)
 >>> from django.core.mail import get_connection
 Traceback (most recent call last):
   File "<console>", line 1, in <module>
 ImportError: cannot import name get_connection
 }}}
 Looking at the source code of the module situated at
 /usr/local/lib/python2.6/dist-packages/django/core/mail.py we can check
 that no get_connection() is declared in the module.
 If we want to create a connection to send emails, we have to instantiate
 the SMTPConnection class and then call its methods. For example:
 {{{
 mailConnection = SMTPConnection()
 mailConnection.open()
 mailConnection.send_messages([email1, email2])
 mailConnection.close()
 }}}
 get_connection(self, fail_silently=False) is a method inside the
 EmailMessage class situated in line 228 and used in line 266, not a
 function.

 The solution I see is to update the documentation referring to emails
 section.

Comment:

 Fixed formatting; please use preview.

 You seem to be looking at the doc for Django 1.2 (or current trunk) while
 using Django 1.1.1. `get_connection` is mentioned under the doc for email
 backends, which is flagged as new in 1.2:
 http://docs.djangoproject.com/en/dev/topics/email/#e-mail-backends. This
 function does exist in Django 1.2:

 {{{
 #!python
 >>> import django
 >>> django.get_version()
 '1.2.1'
 >>> from django.core.mail import get_connection
 >>>
 }}}

 `django.core.mail.get_connection` did not exist in 1.1 and is not
 mentioned in the 1.1 version of the doc
 (http://docs.djangoproject.com/en/1.1/topics/email/).

-- 
Ticket URL: <http://code.djangoproject.com/ticket/13641#comment:1>
Django <http://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-upda...@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.

Reply via email to