NameError: global name 'web' is not defined in utils using sendmail

984 views
Skip to first unread message

paul jobs

unread,
Mar 30, 2008, 4:10:10 PM3/30/08
to we...@googlegroups.com
import web
web.config.smtp_server='localhost'
 web.sendmail('webjogger@gmail.com','webjogger@gmail.com','Hi there', '<img src="http://www.google.com/intl/en_ALL/images/logo.gif">',headers={'Content-Type': 'text/html'} )
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "web/utils.py", line 830, in sendmail
    smtpserver = smtplib.SMTP(web.config.smtp_server)
NameError: global name 'web' is not defined


thanks for any pointers on how to fix this

Hermann Kaser

unread,
Mar 30, 2008, 4:12:39 PM3/30/08
to we...@googlegroups.com
On Sun, Mar 30, 2008 at 9:10 PM, paul jobs <webj...@gmail.com> wrote:
> import web
> web.config.smtp_server='localhost'
> web.sendmail('webj...@gmail.com','webj...@gmail.com','Hi there', '<img

> src="http://www.google.com/intl/en_ALL/images/logo.gif">',headers={'Content-Type':
> 'text/html'} )
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> File "web/utils.py", line 830, in sendmail
> smtpserver = smtplib.SMTP(web.config.smtp_server)
> NameError: global name 'web' is not defined


Have you installed web.py?
Is it accesible to whatever you are running it from in the $PATH?

--
Hermann Käser
http://theragingche.com/
http://semicir.cl/user/hermzz

Paul Jobs

unread,
Mar 30, 2008, 4:20:34 PM3/30/08
to we...@googlegroups.com
Thanks Hermann


Yes
webpy folder is accessible in the directory

Proj
code.py
static/
templates/
web/

if you see utils.py you can see that if we set web.config.smtp_server

web is an undefined global name

paul jobs

unread,
Mar 30, 2008, 5:56:13 PM3/30/08
to we...@googlegroups.com
In solaris this is the error on running web.sendmail

/web/utils.py", line 823, in sendmail

    from_address = email.Utils.parseaddr(from_address)[1]
AttributeError: 'module' object has no attribute 'Utils'

Aaron Swartz

unread,
Mar 31, 2008, 12:35:24 AM3/31/08
to we...@googlegroups.com

Are you running an old version of Python?

Aaron Swartz

unread,
Mar 31, 2008, 12:35:46 AM3/31/08
to we...@googlegroups.com
> thanks for any pointers on how to fix this

What version of web.py are you running?

Paul Jobs

unread,
Mar 31, 2008, 4:41:53 AM3/31/08
to we...@googlegroups.com
Yes Aaron Joyent Solaris runs
python
Python 2.4.4 (#1, Nov  8 2007, 16:21:05)
[GCC 3.4.3 (csl-sol210-3_4-20050802)] on sunos5

Paul Jobs

unread,
Mar 31, 2008, 4:42:36 AM3/31/08
to we...@googlegroups.com

"""web.py: makes web apps (http://webpy.org)"""
__version__ = "0.22"
__revision__ = "$Rev: 188 $"
__author__ = "Aaron Swartz <m...@aaronsw.com>"

Anand Chitipothu

unread,
Mar 31, 2008, 8:24:19 AM3/31/08
to we...@googlegroups.com
On Mon, Mar 31, 2008 at 2:12 PM, Paul Jobs <webj...@gmail.com> wrote:
>
>
> """web.py: makes web apps (http://webpy.org)"""
> __version__ = "0.22"
> __revision__ = "$Rev: 188 $"
> __author__ = "Aaron Swartz <m...@aaronsw.com>"


I think you are using old web.py 0.23 development branch. Try using web.py 0.23.
This error was around for some time, but it is fixed now.

Reply all
Reply to author
Forward
0 new messages