I have no objection in taking the code out in a function.
But if one overrides it (and this is your intention) web2py will not
be able to identify which table refers to the uploaded file and thus
determine permission to download.

Massimo

On Jun 4, 12:48 am, Trollkarlen <robbelibob...@gmail.com> wrote:
> Strange because i did break out the filename building to a function.
> And both the appadmin and the app download works jut fine.
>
> def __db_filename(tablename, fieldname, filename):
>     import re, uuid, base64
>     re_extension = re.compile('\.\w{1,5}$')
>     m = re_extension.search(filename)
>     e = m and m.group()[1:] or 'txt'
>     uuid_key = str(uuid.uuid4()).replace('-', '')[-16:]
>     encoded_filename = base64.b16encode(filename).lower()
>     newfilename = '%s.%s.%s.%s' % \
>             (tablename, fieldname, uuid_key,
>              encoded_filename)
>     # for backward compatibility since upload field if 128bytes
>     #newfilename = newfilename[:122]+'.'+e
>     newfilename = newfilename + '.' + e
>     return newfilename
>
> /R
>
> On Jun 3, 7:19 pm, mdipierro <mdipie...@cs.depaul.edu> wrote:
>
> > Cannot be done because it would break the download method. There are
> > lots of tricks involved in making this work fast and smoothly.
>
> > Mossimo
>
> > On Jun 3, 11:57 am, Robert Marklund <robbelibob...@gmail.com> wrote:
>
> > > Maybe you should expose the filename making as a method:
>
> > >                    uuid_key = str(uuid.uuid4()).replace('-', '')[-16:]
> > >                     encoded_filename = base64.b16encode(filename).lower()
> > >                     newfilename = '%s.%s.%s.%s' % \
> > >                         (self.table._tablename, fieldname, uuid_key,
> > >                          encoded_filename)
> > >                     # for backward compatibility since upload field if
> > > 128bytes
> > >                     newfilename = newfilename[:122]+'.'+e
> > >                     self.vars['%s_newfilename' % fieldname] = newfilename
> > >                     fields[fieldname] = newfilename
>
> > > So that people with there own fileuploads can make use of the appadmin .
>
> > > /Robert
>
> > > --
> > > ______________________________________________
> > > Robert Marklund
>
> > > Phone: +46 (0)46 19 36 82
> > > Mobile: +46 (0)70 213 22 76
> > > E-mail: robbelibob...@gmail.com
> > > ______________________________________________
>
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" 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
-~----------~----~----~----~------~----~------~--~---

Reply via email to