On Tue, Aug 27, 2013 at 5:22 PM, Adi <adnan.smajlo...@gmail.com> wrote:


> Used the Python Imaging Library (with JPEG decoder) to create set of
> thumbnails. For the images with jpeg extension, the error pops up that the
> properties can't be retrieved, while for the non-image extensions,
> everything displays fine.
>
>


> Traceback (most recent call last):
>
>  File "/Users/adnan/web2py26/gluon/restricted.py", line 217, in restricted
>     exec ccode in environment
>   File "/Users/adnan/web2py26/applications/nammu/controllers/default.py",line
> 2983, in <module>
>
>   File "/Users/adnan/web2py26/gluon/globals.py", line 361, in <lambda>
>     self._caller = lambda f: f()
>   File "/Users/adnan/web2py26/applications/nammu/controllers/default.py",line
> 2105, in download
>     return response.download(request, db)
>   File "/Users/adnan/web2py26/gluon/globals.py", line 574, in download
>     (filename, stream) = field.retrieve(name,nameonly=True)
>   File "/Users/adnan/web2py26/gluon/dal.py", line 9558, in retrieve
>     file_properties = self.retrieve_file_properties(name,path)
>   File "/Users/adnan/web2py26/gluon/dal.py", line 9583, 
> inretrieve_file_properties
>     raise TypeError('Can\'t retrieve %s file properties' % name)
> TypeError: Can't retrieve
> product.image.85d32040405f61e9.626c61636b2d6e616d6d752e6a7067.180x160.jpeg
> file properties
>
>
>
It's a filename regex issue.
The regex above (REGEX_UPLOAD_PATTERN) is what is used in dal.py


import re

# this is ok. Has a _180x160 instead of .180x160
name =
'product.image.85d32040405f61e9.626c61636b2d6e616d6d752e6a7067_180x160.jpeg'

# this one fails
name =
'product.image.85d32040405f61e9.626c61636b2d6e616d6d752e6a7067.180x160.jpeg'

REGEX_UPLOAD_PATTERN =
re.compile('(?P<table>[\w\-]+)\.(?P<field>[\w\-]+)\.(?P<uuidkey>[\w\-]+)(\.(?P<name>\w+))?\.\w+$')

m = REGEX_UPLOAD_PATTERN.match(name)
assert(m is not None)
print m.groupdict()

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to