#8765: mod_python handler requires explicit str() cast for
HttpResponse(mimetype=...)
------------------------------------+---------------------------------------
          Reporter:  semenov        |         Owner:  nobody                    
      
            Status:  new            |     Milestone:                            
      
         Component:  HTTP handling  |       Version:  SVN                       
      
        Resolution:                 |      Keywords:  mod_python content-type 
mimetype
             Stage:  Unreviewed     |     Has_patch:  1                         
      
        Needs_docs:  0              |   Needs_tests:  0                         
      
Needs_better_patch:  0              |  
------------------------------------+---------------------------------------
Comment (by semenov):

 Yes it '''does''' describe the course of events.

 Let me paste it again:
 {{{
 #!python
 att = Attachment.objects.get()
 return HttpResponse(content=att.file, mimetype=att.content_type)
 }}}

 I think that is ''perfectly normal'' piece of code. In my project, I have
 the concept of attachments, and access to particular attachments depends
 on the user logged in. Therefore, I need to proxy the download requests
 via my custom view. In the model, I need to store the original
 content_type to help the browser properly recognize it when downloading
 (e.g., distinguish a text file from a HTML file).

 For your reference, below is my model. As you can see, content_type is a
 CharField, which is represented as a unicode object when accessed.

 {{{
 #!python
 class Attachment(models.Model):
         comment = models.ForeignKey(Comment)
         file = models.FileField(upload_to='attachments')
         filename = models.CharField(max_length=255)
         content_type = models.CharField(max_length=255)
         content_length = models.IntegerField()
 }}}

-- 
Ticket URL: <http://code.djangoproject.com/ticket/8765#comment:2>
Django Code <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 [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to