>>> import tarfile >>> tarfile.is_tarfile("web2py.plugin.tagging.w2p") True >>> tarfile.is_tarfile("cookbook2.pdf") False >>> :) File "<stdin>", line 1 :) ^ SyntaxError: invalid syntax >>>
Now this needs to integrate with SQLFORM on_validation. Should I also open the tar archive, and verify its contents are actually, python code, html, images (such as verifying each of them individually or just their filenames?) -Thadeus On Mon, Nov 23, 2009 at 7:49 PM, Richard <richar...@gmail.com> wrote: > > could a new validator be added to check the mime type from the POSTed > content-type? > IS_MIME_TYPE('png') > > Django has something like this: > > http://docs.djangoproject.com/en/dev/topics/http/file-uploads/?from=olddocs#uploadedfile-objects > > Richard > > > On Nov 23, 2:50 pm, Thadeus Burgess <thade...@thadeusb.com> wrote: > > This is for uploaded plug-ins (for plugincentral). > > > > I want to make sure they are actually tarred archives with python code in > > them. I need to check the actual file contents instead of just the > filename > > (which gets checked first, to make sure it is "web2py.plugin.*.w2p" > > > > -Thadeus > > > > On Sun, Nov 22, 2009 at 9:46 PM, mdipierro <mdipie...@cs.depaul.edu> > wrote: > > > > > There a IS_IMAGE that can check for BMP, GIF, JPEG, and PNG. > > > You can copy and modify it to check for other formats. > > > What formats are you thinking about? > > > > > On Nov 22, 9:41 pm, Thadeus Burgess <thade...@thadeusb.com> wrote: > > > > Is there a way, through SQLFORM to open a file, and make sure it is > the > > > kind > > > > of file you are expecting. > > > > > > I would like to check to see if the files users are uploading, are > indeed > > > > w2p tarred files with only .py files with a naming scheme in them. > > > > > > I know I could use SQLFORM.factory and then open the file after it is > > > saved > > > > to the server, then delete it if it was no good, I was just wondering > if > > > > there was a way to "hook" into the validation. > > > > > > -Thadeus > > > > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "web2py-users" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~----------~----~----~----~------~----~------~--~---