There is no problem with the directory. I tracked a little bit about
the error, and discover the following. I did a class to generate
thumbnails and I generate them on the fly if the image doesn't exist,
otherwise I just stream the existing image.
And this error is occurring during the call to this class, and the
image is not shown on the website.
This doesn't happen always, only sometimes. I really don't know how to
fix it. I will paste the code here, so maybe someone can advise me.

Here is the error message (attention to the first and last line):

+++
127.0.0.1:43387 - - [04/Feb/2011 23:00:19] "HTTP/1.1 GET /thumb/
100x100/static/post_img/debian.png" - 200 OK
Traceback (most recent call last):
  File "/usr/lib/pymodules/python2.5/web/application.py", line 240, in
process
    return p(lambda: process(processors))
  File "/usr/lib/pymodules/python2.5/web/session.py", line 56, in
_processor
    self._load()
  File "/usr/lib/pymodules/python2.5/web/session.py", line 75, in
_load
    d = self.store[self.session_id]
  File "/usr/lib/pymodules/python2.5/web/session.py", line 211, in
__getitem__
    return self.decode(pickled)
  File "/usr/lib/pymodules/python2.5/web/session.py", line 173, in
decode
    return pickle.loads(pickled)
EOFError

127.0.0.1:43388 - - [04/Feb/2011 23:00:19] "HTTP/1.1 GET /thumb/
100x100/static/post_img/gnome-terminal.png" - 500 Internal Server
Error
++++

So, when the website look for /thumb/100x100/static/post_img/gnome-
terminal.png the image is not shown. Observe that on the first line of
the message above, other thumbnail image was loaded succesfully.

Now I will show the code. Here is the url mapper:

'/thumb/(\d+)x(\d+)/(.+)', 'public.Thumb'

and here is the Thumb class.

class Thumb:
    """Check if the thumbnail of the file already exists, if not
create it,
    then stream it.

    The path variable is relative to the site root path.

    """

    def GET(self, w, h, path):
        full_path = os.path.join(config.root, path)
        if not os.path.exists(full_path):
            raise web.notfound()
        ext = os.path.splitext(full_path)[1].lstrip('.')
        thumbname = '%i_%s_%s.%s' % (os.stat(full_path).st_ino, w, h,
ext)
        thumbpath = os.path.join(config.root, config.thumb_dir,
thumbname)
        if not os.path.exists(thumbpath):
            thumb.thumbnail(full_path, thumbpath, (int(w),int(h)),
ext)
        web.header("Content-Type", "image/%s" % ext)
        for buff in open(thumbpath, buffering=8*1024):
            yield buff

Just to be clear, I am getting the file inode number to generate
thumbnails, it is this line
thumbname = '%i_%s_%s.%s' % (os.stat(full_path).st_ino, w, h, ext)
If this file doesn't already exists, then I create a thumbnail using
other function. In the end I stream the file. Maybe the error is in
the way I'm streamming it, I don't know ... any suggestions are
welcome.

-- 
You received this message because you are subscribed to the Google Groups 
"web.py" 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/webpy?hl=en.

Reply via email to