Re: how to save response 's render file to server or email using httpresponse

2012-07-04 Thread Nikolas Stevenson-Molnar
I stand corrected ;)

_Nik

On 7/4/2012 8:37 AM, Melvyn Sopacua wrote:
> On 3-7-2012 20:32, Nikolas Stevenson-Molnar wrote:
>> Oh, and HttpResponse is intended to send data back to a web browser. I
>> can't think of any reason you would use an HttpResponse when sending an
>> email.
> To mail yourself (parts of) the response object from middleware as part
> of auditing and/or tracing down elusive errors.
>


-- 
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: how to save response 's render file to server or email using httpresponse

2012-07-04 Thread Melvyn Sopacua
On 3-7-2012 20:32, Nikolas Stevenson-Molnar wrote:
> Oh, and HttpResponse is intended to send data back to a web browser. I
> can't think of any reason you would use an HttpResponse when sending an
> email.

To mail yourself (parts of) the response object from middleware as part
of auditing and/or tracing down elusive errors.

-- 
Melvyn Sopacua


-- 
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: how to save response 's render file to server or email using httpresponse

2012-07-03 Thread Min Hong Tan
\(^o^)/

On Tue, Jul 3, 2012 at 4:53 PM, Nikolas Stevenson-Molnar <
nik.mol...@consbio.org> wrote:

>  You are welcome. Glad you got it working :)
>
> _Nik
>
>
> On 7/3/2012 3:33 PM, Min Hong Tan wrote:
>
> Thx nik,
>
>  I'm confused , your words has aroused me  from the word.
> "You won't use HttpResponse at all, just EmailMessage (using
> message.attach). "
>
>  problem solved by using below:
>
>
>
>  from io import BytesIO
>
>
>
>  buffer = BytesIO()
> book.save(buffer)
> excel = buffer.getvalue()
> buffer.close()
>
>  and just
>
>
> mail.attach(filename="testing.xls",content=excel,mimetype="application/ms-excel")
>
>  mail.send()
>
>  and mission accomplished!!
>
>
>
>
> On Tue, Jul 3, 2012 at 2:59 PM, Nikolas Stevenson-Molnar <
> nik.mol...@consbio.org> wrote:
>
>>  You'll need to use EmailMessage:
>> https://docs.djangoproject.com/en/dev/topics/email/?from=olddocs/#django.core.mail.EmailMessage
>>
>> You won't use HttpResponse at all, just EmailMessage (using
>> message.attach).
>>
>> _Nik
>>
>>
>> On 7/3/2012 1:34 PM, Min Hong Tan wrote:
>>
>> sorry all, maybe i'm not type why i need the httpresponse to be attach.
>>
>>  response = HttpResponse(mimetype='application/pdf')
>> response['Content-Disposition'] = 'attaachment; filename=report.pdf'
>>
>>  i'm generating the pdf file in response. and normally i will return
>> response and it should be perfect with the pdf file download.
>>
>>  but, how if i want to attach it and send out the mail?
>>
>> On Tue, Jul 3, 2012 at 12:32 PM, Nikolas Stevenson-Molnar <
>> nik.mol...@consbio.org> wrote:
>>
>>> Oh, and HttpResponse is intended to send data back to a web browser. I
>>> can't think of any reason you would use an HttpResponse when sending an
>>> email.
>>>
>>> _Nik
>>>
>>> On 7/3/2012 11:20 AM, Min Hong Tan wrote:
>>>  > hi,
>>> >
>>> > I have a problem to send mail using Emailmessage,
>>> > i wan to attach the file that render using httpresponse and send, but
>>> > always show me "int" does not have method "lower".
>>> > therefore, I think to save the file in the server and then attach
>>> > using emailmessage.  but how do i get the httpresonse to save
>>> > in server /tmp/file  ?
>>> >
>>> > Regards,
>>> > MH
>>>   > --
>>> > 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.
>>>
>>>
>>> --
>>> 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.
>>>
>>>
>>  --
>> 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.
>>
>>
>>
>>--
>> 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.
>>
>
>  --
> 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.
>
>
>
>  --
> 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.
>

-- 
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: how to save response 's render file to server or email using httpresponse

2012-07-03 Thread Nikolas Stevenson-Molnar
You are welcome. Glad you got it working :)

_Nik

On 7/3/2012 3:33 PM, Min Hong Tan wrote:
> Thx nik,
>
> I'm confused , your words has aroused me  from the word.
> "You won't use HttpResponse at all, just EmailMessage (using
> message.attach). "
>
> problem solved by using below:
>
>
>
> from io import BytesIO
>
>
>
> buffer = BytesIO()
> book.save(buffer) 
> excel = buffer.getvalue()
> buffer.close()
>
> and just 
>
> mail.attach(filename="testing.xls",content=excel,mimetype="application/ms-excel")
>
> mail.send()
>
> and mission accomplished!!
>
>
>
>
> On Tue, Jul 3, 2012 at 2:59 PM, Nikolas Stevenson-Molnar
> > wrote:
>
> You'll need to use EmailMessage:
> 
> https://docs.djangoproject.com/en/dev/topics/email/?from=olddocs/#django.core.mail.EmailMessage
>
> You won't use HttpResponse at all, just EmailMessage (using
> message.attach).
>
> _Nik
>
>
> On 7/3/2012 1:34 PM, Min Hong Tan wrote:
>> sorry all, maybe i'm not type why i need the httpresponse to be
>> attach.
>>
>> response = HttpResponse(mimetype='application/pdf')
>> response['Content-Disposition'] = 'attaachment; filename=report.pdf'
>>
>> i'm generating the pdf file in response. and normally i will
>> return response and it should be perfect with the pdf file download.
>>
>> but, how if i want to attach it and send out the mail?
>>
>> On Tue, Jul 3, 2012 at 12:32 PM, Nikolas Stevenson-Molnar
>> > wrote:
>>
>> Oh, and HttpResponse is intended to send data back to a web
>> browser. I
>> can't think of any reason you would use an HttpResponse when
>> sending an
>> email.
>>
>> _Nik
>>
>> On 7/3/2012 11:20 AM, Min Hong Tan wrote:
>> > hi,
>> >
>> > I have a problem to send mail using Emailmessage,
>> > i wan to attach the file that render using httpresponse and
>> send, but
>> > always show me "int" does not have method "lower".
>> > therefore, I think to save the file in the server and then
>> attach
>> > using emailmessage.  but how do i get the httpresonse to save
>> > in server /tmp/file  ?
>> >
>> > Regards,
>> > MH
>> > --
>> > 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.
>>
>>
>> --
>> 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.
>>
>>
>> -- 
>> 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.
>
>
> -- 
> 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.
>
>
> -- 
> 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.


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to 

Re: how to save response 's render file to server or email using httpresponse

2012-07-03 Thread Min Hong Tan
Thx nik,

I'm confused , your words has aroused me  from the word.
"You won't use HttpResponse at all, just EmailMessage (using
message.attach). "

problem solved by using below:



from io import BytesIO



buffer = BytesIO()
book.save(buffer)
excel = buffer.getvalue()
buffer.close()

and just

mail.attach(filename="testing.xls",content=excel,mimetype="application/ms-excel")

mail.send()

and mission accomplished!!




On Tue, Jul 3, 2012 at 2:59 PM, Nikolas Stevenson-Molnar <
nik.mol...@consbio.org> wrote:

>  You'll need to use EmailMessage:
> https://docs.djangoproject.com/en/dev/topics/email/?from=olddocs/#django.core.mail.EmailMessage
>
> You won't use HttpResponse at all, just EmailMessage (using
> message.attach).
>
> _Nik
>
>
> On 7/3/2012 1:34 PM, Min Hong Tan wrote:
>
> sorry all, maybe i'm not type why i need the httpresponse to be attach.
>
>  response = HttpResponse(mimetype='application/pdf')
> response['Content-Disposition'] = 'attaachment; filename=report.pdf'
>
>  i'm generating the pdf file in response. and normally i will return
> response and it should be perfect with the pdf file download.
>
>  but, how if i want to attach it and send out the mail?
>
> On Tue, Jul 3, 2012 at 12:32 PM, Nikolas Stevenson-Molnar <
> nik.mol...@consbio.org> wrote:
>
>> Oh, and HttpResponse is intended to send data back to a web browser. I
>> can't think of any reason you would use an HttpResponse when sending an
>> email.
>>
>> _Nik
>>
>> On 7/3/2012 11:20 AM, Min Hong Tan wrote:
>>  > hi,
>> >
>> > I have a problem to send mail using Emailmessage,
>> > i wan to attach the file that render using httpresponse and send, but
>> > always show me "int" does not have method "lower".
>> > therefore, I think to save the file in the server and then attach
>> > using emailmessage.  but how do i get the httpresonse to save
>> > in server /tmp/file  ?
>> >
>> > Regards,
>> > MH
>>   > --
>> > 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.
>>
>>
>> --
>> 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.
>>
>>
>  --
> 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.
>
>
>
>  --
> 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.
>

-- 
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: how to save response 's render file to server or email using httpresponse

2012-07-03 Thread Nikolas Stevenson-Molnar
You'll need to use EmailMessage:
https://docs.djangoproject.com/en/dev/topics/email/?from=olddocs/#django.core.mail.EmailMessage

You won't use HttpResponse at all, just EmailMessage (using message.attach).

_Nik

On 7/3/2012 1:34 PM, Min Hong Tan wrote:
> sorry all, maybe i'm not type why i need the httpresponse to be attach.
>
> response = HttpResponse(mimetype='application/pdf')
> response['Content-Disposition'] = 'attaachment; filename=report.pdf'
>
> i'm generating the pdf file in response. and normally i will return
> response and it should be perfect with the pdf file download.
>
> but, how if i want to attach it and send out the mail?
>
> On Tue, Jul 3, 2012 at 12:32 PM, Nikolas Stevenson-Molnar
> > wrote:
>
> Oh, and HttpResponse is intended to send data back to a web browser. I
> can't think of any reason you would use an HttpResponse when
> sending an
> email.
>
> _Nik
>
> On 7/3/2012 11:20 AM, Min Hong Tan wrote:
> > hi,
> >
> > I have a problem to send mail using Emailmessage,
> > i wan to attach the file that render using httpresponse and
> send, but
> > always show me "int" does not have method "lower".
> > therefore, I think to save the file in the server and then attach
> > using emailmessage.  but how do i get the httpresonse to save
> > in server /tmp/file  ?
> >
> > Regards,
> > MH
> > --
> > 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.
>
>
> --
> 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.
>
>
> -- 
> 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.


-- 
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: how to save response 's render file to server or email using httpresponse

2012-07-03 Thread Min Hong Tan
sorry all, maybe i'm not type why i need the httpresponse to be attach.

response = HttpResponse(mimetype='application/pdf')
response['Content-Disposition'] = 'attaachment; filename=report.pdf'

i'm generating the pdf file in response. and normally i will return
response and it should be perfect with the pdf file download.

but, how if i want to attach it and send out the mail?

On Tue, Jul 3, 2012 at 12:32 PM, Nikolas Stevenson-Molnar <
nik.mol...@consbio.org> wrote:

> Oh, and HttpResponse is intended to send data back to a web browser. I
> can't think of any reason you would use an HttpResponse when sending an
> email.
>
> _Nik
>
> On 7/3/2012 11:20 AM, Min Hong Tan wrote:
> > hi,
> >
> > I have a problem to send mail using Emailmessage,
> > i wan to attach the file that render using httpresponse and send, but
> > always show me "int" does not have method "lower".
> > therefore, I think to save the file in the server and then attach
> > using emailmessage.  but how do i get the httpresonse to save
> > in server /tmp/file  ?
> >
> > Regards,
> > MH
> > --
> > 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.
>
>
> --
> 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.
>
>

-- 
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: how to save response 's render file to server or email using httpresponse

2012-07-03 Thread Nikolas Stevenson-Molnar
Oh, and HttpResponse is intended to send data back to a web browser. I
can't think of any reason you would use an HttpResponse when sending an
email.

_Nik

On 7/3/2012 11:20 AM, Min Hong Tan wrote:
> hi,
>
> I have a problem to send mail using Emailmessage,
> i wan to attach the file that render using httpresponse and send, but
> always show me "int" does not have method "lower".
> therefore, I think to save the file in the server and then attach
> using emailmessage.  but how do i get the httpresonse to save
> in server /tmp/file  ? 
>
> Regards,
> MH
> -- 
> 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.


-- 
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: how to save response 's render file to server or email using httpresponse

2012-07-03 Thread Nikolas Stevenson-Molnar
The content is already rendered when you pass it to your HttpResponse
object. Therefore, I would just write it out prior to creating/returning
the response object. E.g., if you're using a template:

t = get_template("foo.html")
c = Context({...})
content = t.render(c)
f = open('somefile.txt', 'w')
f.write(content)
f.close()
return HttpResponse(content)

However, from the error you mention, it sounds like your either a)
treating an integer like a string somewhere, or b) you are passing an
integer to a function which is expecting a string. Somewhere, something
like this is happening:

a = 5
a.lower() #<-- error

_Nik

On 7/3/2012 11:20 AM, Min Hong Tan wrote:
> hi,
>
> I have a problem to send mail using Emailmessage,
> i wan to attach the file that render using httpresponse and send, but
> always show me "int" does not have method "lower".
> therefore, I think to save the file in the server and then attach
> using emailmessage.  but how do i get the httpresonse to save
> in server /tmp/file  ? 
>
> Regards,
> MH
> -- 
> 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.


-- 
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.



how to save response 's render file to server or email using httpresponse

2012-07-03 Thread Min Hong Tan
hi,

I have a problem to send mail using Emailmessage,
i wan to attach the file that render using httpresponse and send, but
always show me "int" does not have method "lower".
therefore, I think to save the file in the server and then attach using
emailmessage.  but how do i get the httpresonse to save
in server /tmp/file  ?

Regards,
MH

-- 
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.