2

I am generating static files on the fly but cannot get the URL function to work: NB: here filename is a key-value returned by the controller

{{=P(A('Download ', filename,_href=URL('static', filename)))}}

generates an error:

type 'exceptions.SyntaxError'> when calling URL, function or function name required

However if I replace the filename variable with a string (as follows) the link is generated OK

{{=P(A('Download ', filename,_href=URL('static', 'abcis_data_42Data_.NO2.__.zip')))}}

Any ideas?


OK solved. filename is of type unicode and using str(filename) solves the problem.

4

1 回答 1

0

我认为您可能需要做的是沿着 MVC 层次结构向下移动,因此您的代码可能如下所示:

{{=P(A('Download',filename,_href=URL(r=request,c='static',f=filename)))}}
于 2012-07-30T19:16:41.997 回答