Is there a reason why you want to do it file by file, as opposed to by folder?
Would something like this work for you:
class bDirectory(Directory):
def __init__(self):
self.my_statics = StaticDirectory($(file system path to here}+'/static',
list_directory=True,
cache_time=${http cache time, in seconds},
follow_links=True)
def get_exports(self):
yield("static", "my_statics", None, None)
def index[html](self):
def render[html]():
"""
Static file here!
"""
Note that this way you could put as many files as you want under b/static/. You
may even symbolically link to any other folder elsewhere on your file system --
this could be very useful if your static files are managed separately, e.g. a
third party javascript package.
mario
Quoting Ernesto Adorio :
> Instead of putting all static files inside a static directory in the main
> directory of a QP site module, and making declarations in the slash.qpy, I
> am intterested in declaring and accessing static files inside a submodule as
> I used to in Quixote.
>
> a
> a/slash.qpy
> a/static
> b
> b/b.qpy <-- declare and reference static file here
> b/static
> b/static/myfile.doc <-- Static file here!
>
> I am interested in declaring a static file myfile.doc whose complete path
> name is "/home/toto/a/b/static/myfile.doc" inside b.qpy. How do I do it and
> how do I reference it inside b.qpy?
> In Quixote I was able the use the follow_symlinks = 1 but it is now gone in
> QP. I did, in summary form,
>
>
> #file b.qpy
> from qp.fill import StaticFile
> from qp.fill.directory import Directory
>
> import qp.sites.a as a
> home = a.__path__[0]
>
> class bDirectory(Directory):
> def __init__(self):
> self.myfile_doc = StaticFile("%s/b/static/myfile.doc" % home)
> def get_exports(self):
> yield("myfile.doc", "myfile_doc", None, None)
>
> def index[html](self):
> def render[html]():
> """
> Static file here!
> """
>
> But this does not work as when I click on the "myfile.doc" link on the
> displayed b.qpy page.I always get "That page is not here." or something
> like "---- is a directory" errror message.
>
> Thanks in advance,
>
> Ernie