I am thinking in write a custom validator for files that are upload to my server return to the user a error if He upload a file whit a different codec of the specified by the administrator in a control panel. It's validator is for a Product that I am making, In this moment I do not have anything. But I think that I have a clue about how to do this.
In my validator I did:
from ZPublisher.HTTPRequest import FileUpload
class test:
__implements__ = IValidator
def __init__(self,
name,
title='Evil validator',
description='You will fail'):
self.name = name
self.title = title or name
self.description = description
def __call__(self, value, *args, **kwargs):
instance = kwargs.get('instance', None)
field = kwargs.get('field', None)
import pdb; pdb.set_trace()
and I calling it from my archetype after registed,
In the moment that I upload a file, the python debugger make the job and then I can use the python interactive console
doing something like this:
(Pdb) value.filename
'myfile.ogg'
I can get the name of the file but I am not sure if in this moment my file are in the server or still in the user side. My questions are
How could I get the physical path of a file that are being upload if the file is in the server in that moment?
the file is in my Hard Drive or in ZODB at that moment?
Where can I found good documentation about the use of ZPublisher.HTTPRequestl? because this is very old or not specific
http://api.plone.org/Plone/2.1.1/public/ZPublisher.HTTPRequest.FileUpload-class.htm
really, I want do something like:
import os
os.system('ffmpeg -i ' + Path_to_File_in_the_Server_site )
and then get from the return the specific audio and video codec of my file to compare against the configurations.
Since now, Thanks for any help that you could give me.