Hello and many thanks for your help:
I have also solve in this way but i'm sure that your are better:
dir_corrente = os.getcwd()
b= Musica.get(ID)
nome = b.nome_file
nome_band = b.band
return serve_file(dir_corrente + '/static/'+nome_band
+'/'+nome,"application/x-download", "attachment")
thanks
Luca
On 25 Set, 19:59, Christopher Arndt <[EMAIL PROTECTED]> wrote:
> Christopher Arndt schrieb:
>
> > You can get the path of your "static" directory like this:
>
> > from os.path import join, normpath
> > import pkg_resources
>
> > static_dir = pkg_resources.resource_file('mypkg', 'static')
>
> > filename = join(normpath(static_dir), nome_band, nome)
>
> Correction: actually it is better to get the path of the static dir from
> the configuration, in case it was changed from the default. See the wiki
> for an (updated) explanation:
>
> http://docs.turbogears.org/1.0/StaticFiles#using-the-serve-file-function
>
> NB: In your use case it might actually be better to just generate a URL
> to the files in the static directory and let CherryPy serve the files
> through the normal static filter mechanism or, even better, let them be
> served by Apache or another web server via a RewriteRule or sth similar.
>
> def crea_link_azioni_file(musica_obj):
> from elementtree.ElementTree import Element
> span = Element("span")
> link1 = Element('a', href='/static/%s/%s' %
> (musica_obj.nome_band, musica_obj.nome_file))
> ...
> return span
>
> Chris
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---