On Mon, 2008-02-18 at 00:21 +0800, Eric Abrahamsen wrote:
> On Feb 18, 2008, at 12:10 AM, Malcolm Tredinnick wrote:
> >>
> > How are you doing your image saving? In the normal course of things,  
> > the
> > image data is saved to disk *before* the corresponding object is saved
> > to the database. So that would mean it wasn't visible before saving  
> > was
> > complete.

[...]
>      def save(self):
>          if not self.id:
>              from PIL import Image, ImageOps
>              img = Image.open(self.get_picFile_filename())
>              size = (120,90)
>              extrasize = (600,450)
>              info = img._getexif()
>              if info[0x0112] == 8:
>                  img = img.rotate(90)
>                  size = (90,120)
>                  extrasize = (450,600)
>              if self.stream:
>                  fileName = self.picFile.split('/')[-1]
>                  extra = img.copy()
>                  extra = ImageOps.fit(extra,extrasize, Image.ANTIALIAS, 
> 0,(0.5,0.5))
>                  extra.save(MEDIA_ROOT+"img/pics/big/"+fileName)
>              img = ImageOps.fit(img,size,Image.ANTIALIAS,0,(0.5,0.5))
>              img.save(self.get_picFile_filename())

At this moment, the image is fully saved to disk.

>          super(Pic, self).save()

And only here is the current model's data sent to the database. So it's
not a case of the data being in the database before the image.

So it seems like there's something else going wrong. Does the same error
occur if you try to pull an image from the database that is guaranteed
not to exist (so there's no question of it being a race condition)? If
so, that just means your error handling for missing items needs
improvement.

If not, you need to get some more information about what the response is
that is being sent back. For example, if you could connect directly,
without the proxy server in the way, you might see something. Also, if
your Django process is raising an uncaught exception, it should be being
logged somewhere (the server's error log, for example), although that
isn't universally true -- it depends on the server that's involved (what
are you using to serve this app?).

If nothing else works, I'd start putting logging statements in the view
that returns the response that is causing the problem. Try to work out
exactly what it is returning. At the moment, all you've got to work on
is a chronological correlation ("this happens just after that") and an
error message that says the response was so bad it couldn't be
interpreted at all. That's means something bad is going on under the
covers, but you have to gather more information before you'll be able to
work out what.

Regards,
Malcolm

-- 
The sooner you fall behind, the more time you'll have to catch up. 
http://www.pointy-stick.com/blog/


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

Reply via email to