Hello i have write this:
def crea_link_azioni_file(musica_obj):
from elementtree.ElementTree import Element
span=Element("span")
link1 =Element('a', href='/scarica_file?ID=%d' %musica_obj.id)
link1.text='Scarica'
span.append(link1)
link2=Element('a', href='/index')
link2.text='|Indice'
span.append(link2)
return span
and than:
@expose()
def scarica_file(self, ID):
from cherrypy.lib.cptools import serve_file
import os
dir_corrente = os.getcwd()
b= Musica.get(ID)
nome = b.nome_file
nome_band = b.band
return serve_file('/static/'+nome_band+'/'+nome,"application/x-
download", "attachment")
and i get this error:
age handler: <bound method Root.scarica_file of <tg.controllers.Root
object at 0xa8d666c>>
Traceback (most recent call last):
File "/home/luca72/webapps/tg/lib/python2.5/CherryPy-2.3.0-py2.5.egg/
cherrypy/_cphttptools.py", line 121, in _run
self.main()
File "/home/luca72/webapps/tg/lib/python2.5/CherryPy-2.3.0-py2.5.egg/
cherrypy/_cphttptools.py", line 264, in main
body = page_handler(*virtual_path, **self.params)
File "<string>", line 3, in scarica_file
File "/home/luca72/webapps/tg/lib/python2.5/TurboGears-1.0.4.4-
py2.5.egg/turbogears/controllers.py", line 365, in expose
*args, **kw)
File "<string>", line 5, in run_with_transaction
File "/home/luca72/webapps/tg/lib/python2.5/TurboGears-1.0.4.4-
py2.5.egg/turbogears/database.py", line 356, in so_rwt
retval = func(*args, **kw)
File "<string>", line 5, in _expose
File "/home/luca72/webapps/tg/lib/python2.5/TurboGears-1.0.4.4-
py2.5.egg/turbogears/controllers.py", line 380, in <lambda>
mapping, fragment, args, kw)))
File "/home/luca72/webapps/tg/lib/python2.5/TurboGears-1.0.4.4-
py2.5.egg/turbogears/controllers.py", line 408, in _execute_func
output = errorhandling.try_call(func, *args, **kw)
File "/home/luca72/webapps/tg/lib/python2.5/TurboGears-1.0.4.4-
py2.5.egg/turbogears/errorhandling.py", line 72, in try_call
return func(self, *args, **kw)
File "/home/luca72/webapps/tg/tg/controllers.py", line 349, in
scarica_file
return serve_file('/static/'+nome_band+'/'+nome,"application/x-
download", "attachment")
File "/home/luca72/webapps/tg/lib/python2.5/CherryPy-2.3.0-py2.5.egg/
cherrypy/lib/cptools.py", line 206, in serveFile
raise cherrypy.NotFound()
NotFound: (404, "The path '/scarica_file' was not found.")
If for example i change de def scarica_file in
@expose(template="tg.templates.welcome_one")
def scarica_file(self):
import time
return dict(now=time.ctime())
and i change this :
link1 =Element('a', href='/scarica_file')
all work, so is not true that he never find the path scarica_file but
i have make others mistake, can you help me?
thanks Luca
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---