durusmail: qp: Static files in subdirectories.
Static files in subdirectories.
2007-07-23
2007-07-23
2007-07-23
2007-07-23
Static files in subdirectories.
Ernesto Adorio
2007-07-23
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
reply