Hi,

it turns out that I have several mod_python scripts to handle local file
uploading needs.  After many hours of digging in, I have confirmed that
file uploading is not implemented under the simplified Invenio
SimulatedModPythonRequest.  Is that right?

Several hours later, I understood that the recommended way to do file
upload is using ckeditor:

 http://invenio-demo.cern.ch/help/hacking/ckeditor#3.2

I've tried to find a simple example for this functionality in Invenio's
codebase, and the best I've found is:

 
http://invenio-software.org/repo/invenio/tree/modules/webcomment/lib/webcomment_templates.py?h=maint-1.1#n1219

However, it is far from simple.  I've come out with my own
simplification based on the above code, that it looks like that:

    CFG_WEBCOMMENT_MAX_ATTACHED_FILES = 2
    CFG_WEBCOMMENT_MAX_ATTACHMENT_SIZE = 10000
    simple_attach_file_interface = '''
 <form action="./%(script)s/upload" enctype="application/x-www-form-urlencoded">
 <div id="uploadcommentattachmentsinterface">
  <small>%(attach_msg)s:
   <em>(%(nb_files_limit_msg)s. %(file_size_limit_msg)s)</em>
  </small>
  <br />
  <input class="multi max-%(CFG_WEBCOMMENT_MAX_ATTACHED_FILES)s" type="file" 
name="f" />
  <br />
  <noscript>
   <input type="file" name="f" />
   <br />
  </noscript>
 <input type="submit" value="Upload file" onclick="return true;" />
 </div>
 </form>
''' % {
        'script': script,
        'attach_msg': 'File to upload',
        'CFG_WEBCOMMENT_MAX_ATTACHED_FILES': CFG_WEBCOMMENT_MAX_ATTACHED_FILES,
        'nb_files_limit_msg': 'Max %s files' % 
(CFG_WEBCOMMENT_MAX_ATTACHED_FILES),
        'file_size_limit_msg': CFG_WEBCOMMENT_MAX_ATTACHMENT_SIZE,
        }

And then, the upload funcion, is somethink like that:

 def upload(req, f):
    return f

And I do really get the submitted filename on screen.  So far, so good.
But I after many hours of reading Invenio modules, I cannot find now to
read the file contents.  It seems to me that the generic ckeditor
examples found out in Internet, are not suitable under Invenio.

Any pointer on how to implement this upload function will be welcome.
Unfortunately, this is critical to DDD, as the file upload workflow is
home made, the old mod_python method has disappeared and I really need
to make it work.

Thanks,

Ferran

Reply via email to