Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
tools.staticdir
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  5 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Vincent Le Goff  
View profile  
 More options Oct 29 2012, 11:31 am
From: Vincent Le Goff <vincent.legoff....@gmail.com>
Date: Mon, 29 Oct 2012 16:29:59 +0100
Local: Mon, Oct 29 2012 11:29 am
Subject: tools.staticdir
Hi everyone,

I'm trying to get the tools.staticdir working, but it keeps on failing.

I created a directory C:\static and a file test.txt inside it.  I would
like the directory content be served through the /static requests.

Here's my configuration:

        conf = {
            '/': {
                'request.dispatch': self.dispatcher,
                'tools.staticdir.root': 'C:',
            },
            '/static': {
                'tools.staticdir.on': True,
                'tools.staticdir.dir': 'static',
            }
        }
        cherrypy.tree.mount(root=None, config=conf)

But when I send a request to:
myserver/static/test.txt

I get a 404 error.

As you can see, I'm not using the default dispatcher.  Is it failing
because of that?  Should I include some code in my own dispatcher
to call the hooks directly?  I don't think so, but I don't know where
this problem comes from.

Thanks for your help,

Vincent


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Walter Woods  
View profile  
 More options Oct 29 2012, 12:47 pm
From: Walter Woods <woodswal...@gmail.com>
Date: Mon, 29 Oct 2012 09:47:24 -0700
Local: Mon, Oct 29 2012 12:47 pm
Subject: Re: [cherrypy-users] tools.staticdir

Hi Vincent,

I'm not used to using a different dispatcher (the object-based one is kind
of awesome), but this is the class I always use for tools.staticdir, maybe
it will help:

class StaticServer(object):
    """For testing - serves static files out of a given root.
    """

    def __init__(self, rootDir):
        self.rootDir = rootDir
        if not os.path.isabs(self.rootDir):
            self.rootDir = os.path.abspath(rootDir)

    @cherrypy.expose
    def default(self, *args):
        file = os.path.join(self.rootDir, *args)
        return cherrypy.lib.static.serve_file(file)

Usage:
class Root(object):
    static = StaticServer(r'C:\static')

On Mon, Oct 29, 2012 at 8:29 AM, Vincent Le Goff <


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Vincent Le Goff  
View profile  
 More options Oct 29 2012, 1:24 pm
From: Vincent Le Goff <vincent.legoff....@gmail.com>
Date: Mon, 29 Oct 2012 18:24:05 +0100
Local: Mon, Oct 29 2012 1:24 pm
Subject: Re: [cherrypy-users] tools.staticdir
Hi,

I think I could serve static content without using the tools.staticdir
(as you did with your class, I guess).  I will check that out.

Thanks,

Vincent

2012/10/29, Walter Woods <woodswal...@gmail.com>:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Walter Woods  
View profile  
 More options Oct 29 2012, 1:34 pm
From: Walter Woods <woodswal...@gmail.com>
Date: Mon, 29 Oct 2012 10:34:01 -0700
Local: Mon, Oct 29 2012 1:34 pm
Subject: Re: [cherrypy-users] tools.staticdir

Yeah tools.staticdir works kinda weird... the little wrapper class makes it
much nicer
On Oct 29, 2012 10:24 AM, "Vincent Le Goff" <vincent.legoff....@gmail.com>
wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Vincent Le Goff  
View profile  
 More options Oct 30 2012, 11:34 am
From: Vincent Le Goff <vincent.legoff....@gmail.com>
Date: Tue, 30 Oct 2012 16:34:15 +0100
Local: Tues, Oct 30 2012 11:34 am
Subject: Re: [cherrypy-users] tools.staticdir
Hi,

Thanks a lot, it's working just fine.

Vincent

2012/10/29, Walter Woods <woodswal...@gmail.com>:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic