On Jun 17, 6:18 pm, Swell <swel...@googlemail.com> wrote:
> thx yarko for your detailed answer.
> I have not written code so far, I have been using the administrative
> interface provided by web2py to manage the records in the DB.
> I am going to generate another test showing this kind of behaviour
> with a more regular filename.

Thanks for your update - if you REALLY got this error only using the
admin interface
(without manually setting fields) - then we REALLY want to see what
you did,
so we can reproduce and make the underlying admin code a little more
robust.

Thanks,

- Yarko
>
> On Jun 17, 11:51 pm, Yarko Tymciurak <resultsinsoftw...@gmail.com>
> wrote:
>
>
>
> > On Jun 17, 4:59 pm, Swell <swel...@googlemail.com> wrote:
>
> > > There is nothing suspicious here about the filename ( it was an
> > > example here, but it has the same effect with a file containing the
> > > description oof the paper + all the authors ). I am almost sure that
> > > it is related to size of the path + filename that is not correctly
> > > handled . But i can't spot where is it in the source code .
>
> > OK - let's go back to your error report:
>
> > /---------
> > File "C:\Users\M\Desktop\web2py_src\web2py\gluon\sql.py", line 2699,
> > in store
> >     dest_file = open(pathfilename, 'wb')
> > IOError: [Errno 2] No such file or directory: 'C:\\Users\\M\\Desktop\
> > \web2py_src\\web2py\\applications\\Library/databases\\..\\uploads\
> > \books.file.acf7b28c26fb29c3.6161616161616161616161616161616161616161616161
> > 616161616161616161616161616161616161616161616161616161616161616161616161616
> > 161616161616161616161616161616161616161616161616161.pdf'
> > \----------
>
> > To begin with - this is a REALLY suspicious filename;   61 repeated is
> > not what I would expect from the store() code (below).
> > In fact, have a look atwww.asciitable.com: 61 is the character code
> > for "=";  I suspect you have a bug in your controller.
>
> > Why that would generate this filename is yet another question.
>
> > Now let's look at it in the context of the code the error quotes:
>
> > /------
> >    def store(self, file, filename=None, path=None):
>
> >        #  have you defined a custom_store?
> >        #  -- if you have, then you are doing this!
> >        if hasattr(self,'custom_store'):
> >             return self.custom_store(file,filename,path)
> >         if not filename:
> >             filename = file.name
>
> >         #  the fact that your path has NOT had these replaced, I think
> >         #   you must NOT be traversing this code:
> >         filename = os.path.basename(filename.replace('/', os.sep)\
> >                                         .replace('\\', os.sep))
>
> >         ....
> >        #  the pertinent naming stuff is here:  the filename is encoded
>
> >        uuid_key = web2py_uuid().replace('-', '')[-16:]
>
> >        # this just obfuscates the name (and makes it longer - can make
> > it considerably longer).
> >        # for example, if your passed in filename is 235 characters,
> > the
> >        # encoded_filename version is 940 characters long!!!
>
> >         encoded_filename = base64.b16encode(filename).lower()
>
> >         #  this makes the stored name composed of:
> >         #   table name, field name, key, and that really long encoded
> > name;
> >         newfilename = '%s.%s.%s.%s' % \
> >             (self._tablename, self.name, uuid_key, encoded_filename)
>
> >         #  this limits the filename length, in this case truncating
> >         #   the encoded_filename part:
> >         newfilename = newfilename[:200] + '.' + extension
> >         if self.uploadfield == True:
> >             if path:
> >                 pass
> >             elif self.uploadfolder:
> >                 path = self.uploadfolder
> >             else:
> >                 path = os.path.join(self._db._folder, '..', 'uploads')
> >             if self.uploadseparate:
> >                 path = os.path.join(path,"%s.%s" % (self._tablename,
> > self.name),uuid_key[:2])
> >             if not os.path.exists(path):
> >                 os.makedirs(path)
> >             pathfilename = os.path.join(path, newfilename)
>
> >             # because this is attempting to open a file for write/
> > binary,
> >             #  and since you are experiencing an uncaught exception
> >             #  which _could_ be triggered by filename size, other O/S
> > related things,
> >             #  this open() call should really be in a try / except -
> > to catch
> >             #  the error message from "normal users" --- but the only
> > reason
> >             #  a write open would fail:  permissions,  file path
> > errors (e.g. code)
> >             dest_file = open(pathfilename, 'wb')
> >             shutil.copyfileobj(file, dest_file)
> >             dest_file.close()
> >         return newfilename
> > \-----------
>
> > In sum, after working through this I suspect it is your code
> > (somewhere) which is causing your problems; I think you should debug
> > it, and give us enough information to help you without asking us to go
> > on a blind hunting expedition.
>
> > Regards,
> > - Yarko
>
> > > Am i the only one to see that issue? ( one thing also iis that i am
> > > running web2py on windows , but i dont think that it is the issue
> > > here )
>
> > > M

Reply via email to