The first version protects from the case m_list is empty so IMHO it is
better. I don't think that is what you are experiencing with the local
vs remote web server observation.

On Oct 20, 3:00 am, annet <annet.verm...@gmail.com> wrote:
> When I expose this function in controller locatormail:
>
> def send_mail():
>     m_list=db(...) .select(...)
>     for item in m_list:
>         context=dict(item=item)
>         message=response.render('locatormail/send_mail.html',context)
>         recipient=item.contactpersoon.email
>         boolean=mail.send(to=[recipient],subject='...
> ',message=[None,message])
>         if boolean:
>             db.mailingstats.insert(...)
>         else:
>             db.adminstats.insert(...)
>     return True
>
> Mails are sent without problems both locally and remotely. When I
> expose this function in controller adminmail:
>
> def send_mail():
>     item=db(...).select(...)
>     context=dict(item=item[0])
>     message=response.render('adminmail/send_mail.html',context)
>     recipient=item[0].email
>
> boolean=mail.send(to=[recipient],subject='...',message=[None,message])
>     if boolean:
>         db.mailingstats.insert(...)
>     else:
>         db.adminstats.insert(...)
>     return True
>
> I locally get the following error:
>
> Error traceback
> Traceback (most recent call last):
>   File "/Library/Python/2.5/site-packages/web2py_1.87.3/gluon/
> rocket.py", line 876, in run
>     self.run_app(conn)
>   File "/Library/Python/2.5/site-packages/web2py_1.87.3/gluon/
> rocket.py", line 1286, in run_app
>     self.environ = environ = self.build_environ(sock_file, conn)
>   File "/Library/Python/2.5/site-packages/web2py_1.87.3/gluon/
> rocket.py", line 1119, in build_environ
>     request = self.read_request_line(sock_file)
>   File "/Library/Python/2.5/site-packages/web2py_1.87.3/gluon/
> rocket.py", line 947, in read_request_line
>     raise SocketClosed('Client closed socket.')
> SocketClosed: Client closed socket.
> Error snapshot
> Detailed traceback description
> Exception: <class 'gluon.rocket.SocketClosed'>(Client closed socket.)
> Python 2.5.1: /System/Library/Frameworks/Python.framework/Versions/2.5/
> Resources/Python.app/Contents/MacOS/Python
> File /Library/Python/2.5/site-packages/web2py_1.87.3/gluon/rocket.py
> in run at line 876
> [ code | arguments | variables ]
> File /Library/Python/2.5/site-packages/web2py_1.87.3/gluon/rocket.py
> in run_app at line 1286
> [ code | arguments | variables ]
> File /Library/Python/2.5/site-packages/web2py_1.87.3/gluon/rocket.py
> in build_environ at line 1119
> [ code | arguments | variables ]
> File /Library/Python/2.5/site-packages/web2py_1.87.3/gluon/rocket.py
> in read_request_line at line 947
> [ code | arguments | variables ]
> Function argument list: (self=<WSGIWorker(Thread-13, started daemon)>,
> sock_file=<socket._fileobject object at 0x5d12170>)
>         except socket.timeout:
>             raise SocketTimeout("Socket timed out before request.")
>         if d.strip() == '':
>             self.err_log.debug('Client did not send a recognizable
> request.')
>             raise SocketClosed('Client closed socket.')
>         try:
>             self.request_line = d.strip()
>             method, uri, proto = self.request_line.split(' ')
> global SocketClosed: <class 'gluon.rocket.SocketClosed'>
>
> Whereas, remotely (Apache with mod_wsgi) the function sends mails
> without problems. To me the functions are almost the same, so I don't
> understand why they behave differently. I hope one of you does.
>
> Regards,
>
> Annet.

Reply via email to