Re: 'unicode' object has no attribute 'user' when sending e-mail

2009-07-07 Thread alecs

Shit! Great thanks, Tracey! You are absolutely right! I've made a
stupid mistake even for a beginner!
I redifined send_mail in my app :((
Thanks!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: 'unicode' object has no attribute 'user' when sending e-mail

2009-07-07 Thread Karen Tracey
On Tue, Jul 7, 2009 at 9:02 AM, alecs  wrote:

>
> Environment:
>
> Request Method: POST
> Request URL: http://172.16.23.33/alex/urlsend/
> Django Version: 1.0.2 final
> Python Version: 2.6.2
> Installed Applications:
> ['django.contrib.auth',
>  'django.contrib.contenttypes',
>  'django.contrib.sessions',
>  'django.contrib.sites',
>  'filez.filezupload']
> Installed Middleware:
> ('firepy.django.middleware.FirePHPMiddleware',
>  'django.middleware.common.CommonMiddleware',
>  'django.contrib.sessions.middleware.SessionMiddleware',
>  'django.contrib.auth.middleware.AuthenticationMiddleware')
>
>
> Traceback:
> File "/usr/lib/pymodules/python2.6/django/core/handlers/base.py" in
> get_response
>  86. response = callback(request, *callback_args,
> **callback_kwargs)
> File "/usr/lib/pymodules/python2.6/django/contrib/auth/decorators.py"
> in __call__
>  67. return self.view_func(request, *args, **kwargs)
> File "/var/www/filez/filezupload/views.py" in urlsend
>  186. auth_user = 'u...@exmpl.com', auth_password =
> 'gfhjkm_')
> File "/usr/lib/pymodules/python2.6/django/contrib/auth/decorators.py"
> in __call__
>  66. if self.test_func(request.user):
>
> Exception Type: AttributeError at /alex/urlsend/
> Exception Value: 'unicode' object has no attribute 'user'
>
> If comment out send_mail everythin works ok.
>

So your call to send_mail is jumping into one of the auth decorators.  Do
you perhaps have your own send_mail function that you have decorated with
@login_required or something?  You are not actually calling the send_mail
function in django.core.mail, and the reason why lies somewhere in the parts
of your file containing this code that you have not shown.

Karen

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



Re: 'unicode' object has no attribute 'user' when sending e-mail

2009-07-07 Thread alecs

Environment:

Request Method: POST
Request URL: http://172.16.23.33/alex/urlsend/
Django Version: 1.0.2 final
Python Version: 2.6.2
Installed Applications:
['django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'filez.filezupload']
Installed Middleware:
('firepy.django.middleware.FirePHPMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware')


Traceback:
File "/usr/lib/pymodules/python2.6/django/core/handlers/base.py" in
get_response
  86. response = callback(request, *callback_args,
**callback_kwargs)
File "/usr/lib/pymodules/python2.6/django/contrib/auth/decorators.py"
in __call__
  67. return self.view_func(request, *args, **kwargs)
File "/var/www/filez/filezupload/views.py" in urlsend
  186. auth_user = 'u...@exmpl.com', auth_password =
'gfhjkm_')
File "/usr/lib/pymodules/python2.6/django/contrib/auth/decorators.py"
in __call__
  66. if self.test_func(request.user):

Exception Type: AttributeError at /alex/urlsend/
Exception Value: 'unicode' object has no attribute 'user'

If comment out send_mail everythin works ok.

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



Re: 'unicode' object has no attribute 'user' when sending e-mail

2009-07-07 Thread Karen Tracey
On Tue, Jul 7, 2009 at 2:45 AM, alecs  wrote:

>
> I'm trying to send a e-mail, but getting this error. Don't know what
> to do... Any ideas?
> Thanks in advance.
>
> def urlsend(request, username):
>if request.method == 'POST':
>form = SendMailForm(request.POST)
>if form.is_valid():
>subject = form.cleaned_data['subject']
>message = form.cleaned_data['message']
>to_email = form.cleaned_data['to_email']
>try:
>send_mail(subject, message, 'u...@exmpl.com',
> to_email, fail_silently = False,
>auth_user = 'u...@exmpl.com', auth_password =
> 'pass')
>except Exception, e:
>raise ValueError,e


Why are you doing this with catching an Exception and raising a ValueError
instead?  In doing so you lose in the traceback the information about where
the error really originated, since the traceback ends at your "raise
ValueError, e", instead of ending at whatever code is actually trying to
access the 'user' attribute of a unicode object.  Get rid of this
try/except/raise and the traceback will actually reflect where the problem
is.

Also, when you post tracebacks, please click the 'Switch to copy-and-paste
view' link before copying the data.  The full page is useful when seen in a
broswer but the loss of formatting when pasted makes it virtually unusable.

Karen

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



Re: 'unicode' object has no attribute 'user' when sending e-mail

2009-07-07 Thread alecs

I've found a response for a similar problem:
"Seems that the session middleware not active. It should append the
user object
to the request object."
But can't understand how to solve the problem...
Actually I'm getting to a page from which I'm sending a e-mail via
GET:
http://172.16.23.33/alex/send_mail/?fileurl=http://172.16.23.33/file/88165c9e3683b65c594dce33b4c3b2f48096ccaa7f65f68cc67cbb5a
Maybe it's an important moment ?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: 'unicode' object has no attribute 'user' when sending e-mail

2009-07-07 Thread alecs

Tried to embrace in [] - no effect ...
http://pastebin.com/m6437076d
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: 'unicode' object has no attribute 'user' when sending e-mail

2009-07-07 Thread Daniel Roseman

On Jul 7, 7:45 am, alecs  wrote:
> I'm trying to send a e-mail, but getting this error. Don't know what
> to do... Any ideas?
> Thanks in advance.
>
> def urlsend(request, username):
>     if request.method == 'POST':
>         form = SendMailForm(request.POST)
>         if form.is_valid():
>             subject = form.cleaned_data['subject']
>             message = form.cleaned_data['message']
>             to_email = form.cleaned_data['to_email']
>             try:
>                 send_mail(subject, message, 'u...@exmpl.com',
> to_email, fail_silently = False,
>                     auth_user = 'u...@exmpl.com', auth_password =
> 'pass')
>             except Exception, e:
>                 raise ValueError,e
>             return HttpResponseRedirect('/'+username+'/')
>         else:
>             sendMail = SendMailForm(request.POST)
>             variables = RequestContext(request, {
>                 'username': username,
>                 'form' : form,
>             })
>             return render_to_response('send_mail.html', variables)
>         return HttpResponseRedirect('/'+username+'/')
>     else:
>         return HttpResponseRedirect('/'+username+'/')

This is clearly not the code that is producing that error, as you're
not using the attribute 'user' anywhere. Please can you post the
actual traceback, including the lines of code that are triggering the
error.

One issue that I can see is that to_email should be a list, not a
string. If you've only got one destination address, wrap it in a list
like this:
[to_email]
--
DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



'unicode' object has no attribute 'user' when sending e-mail

2009-07-06 Thread alecs

I'm trying to send a e-mail, but getting this error. Don't know what
to do... Any ideas?
Thanks in advance.

def urlsend(request, username):
if request.method == 'POST':
form = SendMailForm(request.POST)
if form.is_valid():
subject = form.cleaned_data['subject']
message = form.cleaned_data['message']
to_email = form.cleaned_data['to_email']
try:
send_mail(subject, message, 'u...@exmpl.com',
to_email, fail_silently = False,
auth_user = 'u...@exmpl.com', auth_password =
'pass')
except Exception, e:
raise ValueError,e
return HttpResponseRedirect('/'+username+'/')
else:
sendMail = SendMailForm(request.POST)
variables = RequestContext(request, {
'username': username,
'form' : form,
})
return render_to_response('send_mail.html', variables)
return HttpResponseRedirect('/'+username+'/')
else:
return HttpResponseRedirect('/'+username+'/')
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: 'unicode' object has no attribute 'user'

2008-09-18 Thread Jens Diemer

Seems that the session middleware not active. It should append the user object 
to the request object.

laspal schrieb:
> I am trying to send mail using sendmail. Getting the error 'unicode'
> object has no attribute 'user'
...
> request.user.message_set.create(message="Mail was send
> successfully.")


-- 
Mfg.

Jens Diemer



http://www.jensdiemer.de


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



'unicode' object has no attribute 'user'

2008-09-18 Thread laspal

Hi,
I am trying to send mail using sendmail. Getting the error 'unicode'
object has no attribute 'user'

My view function:

def send_mail(request):
_user = request.user
sender = _user.email
mailing_list = []

if request.method != 'POST':
emailform = EmailForm()
return render_to_response('email.html', locals())

if request.method == 'POST':
emailform = EmailForm(request.POST)
if emailform.is_valid():
to = emailform.clean_data['to']
subject = emailform.clean_data['subject']
message = emailform.clean_data['message']
try:
send_mail(subject, message, sender, to)
request.user.message_set.create(message="Mail was send
successfully.")
return HttpResponseRedirect('../')

except Exception, e:
raise ValueError,e
return render_to_response( 'email.html', locals() )

Form:
class EmailForm(forms.Form):
to = forms.EmailField()
subject = forms.CharField(max_length=200)
message = forms.CharField(widget=forms.Textarea({'class':'meeting-
detail-textarea'}))

Can someone help me out in this case.

Thanks
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---