Re: [Tutor] Determine Filetype

2009-09-20 Thread ad...@gg-lab.net
Thankyou guys. The search feature of the web site is quite effective! :-) Alan, i know that every site has a search function, but they're not so simple to be used if you're looking for a very common word (in) and don't know other keys to find it. Regards, Giorgio

Re: [Tutor] Determine Filetype

2009-09-20 Thread Alan Gauld
ad...@gg-lab.net wrote: The search feature of the web site is quite effective! :-) simple to be used if you're looking for a very common word (in) and don't know other keys to find it. To be honest I was being a bit optimistic but I did just type in for the search and the first 5 or so hits

Re: [Tutor] Determine Filetype

2009-09-19 Thread Sander Sweers
On Fri, 2009-09-18 at 16:48 -0400, Kent Johnson wrote: So, the __init__.py file of the GAE evinronment's ctypes library is broken, as it's importing from a package that doesn't exist. Right? Probably ctypes is not supported in GAE, that would be a pretty big security hole. There is a pure

Re: [Tutor] Determine Filetype

2009-09-19 Thread ad...@gg-lab.net
Hi All, the solution was in the link i've posted before. If i use: type = imghdr.what('img.test', image.data) The imghdr modules ignore the filename (first argument) and takes the second as a data stream assumed to contain the filetype. The solution only works for images, but that's what i

Re: [Tutor] Determine Filetype

2009-09-19 Thread ad...@gg-lab.net
Ops, i have another question, it seems very simple. I want to check the extension of an uploaded file. So i've created a list with allowed extensions: enabled_ext = ['gif', 'jpeg', 'png', 'bmp', 'tiff'] How can i create a simple if that check if the file ext (file_ext) is in the list? I've

Re: [Tutor] Determine Filetype

2009-09-19 Thread ad...@gg-lab.net
if file_ext in enabled_ext Found an example some seconds ago in another mailing lists. I'm not able to find the python tutorial that describes this statement. Can you help me please? 2009/9/19 ad...@gg-lab.net ad...@gg-lab.net: Ops, i have another question, it seems very simple. I want to

Re: [Tutor] Determine Filetype

2009-09-19 Thread Sander Sweers
On Sat, 2009-09-19 at 17:20 +0200, ad...@gg-lab.net wrote: I want to check the extension of an uploaded file. So i've created a list with allowed extensions: enabled_ext = ['gif', 'jpeg', 'png', 'bmp', 'tiff'] If this does not change make it s tuple. It does not change what is written below.

Re: [Tutor] Determine Filetype

2009-09-19 Thread ad...@gg-lab.net
2009/9/19 Sander Sweers sander.swe...@gmail.com: On Sat, 2009-09-19 at 17:20 +0200, ad...@gg-lab.net wrote: I want to check the extension of an uploaded file. So i've created a list with allowed extensions: enabled_ext = ['gif', 'jpeg', 'png', 'bmp', 'tiff'] If this does not change make it

Re: [Tutor] Determine Filetype

2009-09-19 Thread Sander Sweers
On Sat, 2009-09-19 at 17:36 +0200, ad...@gg-lab.net wrote: if OBJECT in LIST: Well, but i'd like to read the page of the python tutorial regarding this. I'm not able to locate it. Can you help me? When in the python interpreter type help('in') and you should have all info you need about

Re: [Tutor] Determine Filetype

2009-09-19 Thread Alan Gauld
ad...@gg-lab.net wrote: if OBJECT in LIST: Well, but i'd like to read the page of the python tutorial regarding this. I'm not able to locate it. Can you help me? Not everything is covered in the odfficial tutorial, its only meant to be an introduction to the language. You should find it

[Tutor] Determine Filetype

2009-09-18 Thread ad...@gg-lab.net
Hi, i'm putting file in a DB as BLOB entries. To serve them, i need to take Content-Type headers. So, i'm looking for a function that returnes the filetype, given a data str. I've found many other topics like this in python mail-archive, but any of them contains the solution. Can you help me,

Re: [Tutor] Determine Filetype

2009-09-18 Thread Emile van Sebille
On 9/18/2009 10:05 AM ad...@gg-lab.net said... Hi, i'm putting file in a DB as BLOB entries. To serve them, i need to take Content-Type headers. So, i'm looking for a function that returnes the filetype, given a data str. I've found many other topics like this in python mail-archive, but any

Re: [Tutor] Determine Filetype

2009-09-18 Thread ad...@gg-lab.net
Hi Emile, that functions requires a filename/path. Just like this one (for images) http://docs.python.org/library/imghdr.html Ok, i don't have a filename. I get the file from a BLOB in a db. Any idea? Thankyou for your precious help. 2009/9/18 Emile van Sebille em...@fenx.com: On 9/18/2009

Re: [Tutor] Determine Filetype

2009-09-18 Thread Kent Johnson
On Fri, Sep 18, 2009 at 2:21 PM, ad...@gg-lab.net ad...@gg-lab.net wrote: Hi Emile, that functions requires a filename/path. Did you even look at the link? There is a from_buffer() method also. Kent 2009/9/18 Emile van Sebille em...@fenx.com: I'd take a look at python-magic at

Re: [Tutor] Determine Filetype

2009-09-18 Thread ad...@gg-lab.net
Oh, i'm sorry. I've read the README, but haven't noticed that m.from_buffer(open(testdata/test.pdf).read(1024)) was exactly what i was looking for. Ok, i'll try it and let you know :D 2009/9/18 Kent Johnson ken...@tds.net: On Fri, Sep 18, 2009 at 2:21 PM, ad...@gg-lab.net ad...@gg-lab.net

Re: [Tutor] Determine Filetype

2009-09-18 Thread ad...@gg-lab.net
Ok, a good news for me: i've modified my script, adding a: import magic line at the top of it. But I got this error: No module named magic Ok, so magic is not installed on GAE. I've then uploaded it and it loaded succesfully. New error: No module named _ctypes And, reading the full debug i

Re: [Tutor] Determine Filetype

2009-09-18 Thread Kent Johnson
On Fri, Sep 18, 2009 at 4:10 PM, ad...@gg-lab.net ad...@gg-lab.net wrote: Ok, so magic is not installed on GAE. I've then uploaded it and it loaded succesfully. New error: No module named _ctypes And, reading the full debug i got this: File