Re: [QP] Static files in subdirectories.

2007-07-23 Thread Mario Ruggier
Quoting Ernesto Adorio <[EMAIL PROTECTED]>:

> On 7/23/07, Mario Ruggier <[EMAIL PROTECTED]> wrote:
> >
> > Is there a reason why you want to do it file by file, as opposed to by
> > folder?
> >
>
>
>
> Thanks, Mario.
>
> I don't know why I really choose StaticFile over StaticDirectory. Maybe just
> because it is there :) as in the examples or it was done when I used Quixote
> for my initial project? I used both StaticFile and StaticDirectory in the
> project.   OT: Maybe StaticFile should be deprecated then? Since its
> capabilities can be subsumed by StaticDirectory?


Sometimes it is very handy to be able to explicitly expose a single static file
-- i think the qp demo sites use that for the site's favicon.ico export.

Besides, StaticDirectory uses StaticFile for each file it serves.

In any case, while both are extremely handy, in a high-traffic site you will
anyway want to expose statics more efficiently...

OT: One of QP's most attractive features is the short, clear, concise and 100%
comprehensive documentation [*] that, it seems, you have not yet read ;-!!

I suggest you print it out, and read thru it... over a few breakfasts, lunches,
or any other preferred context.

[*] The source code ;)

___
QP mailing list
[email protected]
http://mail.mems-exchange.org/mailman/listinfo/qp


Re: [QP] Static files in subdirectories.

2007-07-23 Thread Mario Ruggier
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 <[EMAIL PROTECTED]>:

> 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
___
QP mailing list
[email protected]
http://mail.mems-exchange.org/mailman/listinfo/qp