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
static content serving
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
  9 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
 
Diez B. Roggisch  
View profile  
 More options Jul 9 2008, 10:32 am
From: "Diez B. Roggisch" <de...@web.de>
Date: Wed, 9 Jul 2008 16:32:31 +0200
Local: Wed, Jul 9 2008 10:32 am
Subject: static content serving
Hi,

can somebody give me a hint on how static content is served? I need to "embed"
the TG2-app into an existing wsgi-app below a certain path - and obviously
serving e.g. the CSS fails miserably. There was the old way of using tg.url
and server.webpath (or such) - any such facility available?

Diez


 
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.
Mark Ramm  
View profile  
 More options Jul 9 2008, 11:50 am
From: "Mark Ramm" <mark.mchristen...@gmail.com>
Date: Wed, 9 Jul 2008 11:50:43 -0400
Local: Wed, Jul 9 2008 11:50 am
Subject: Re: [tg-trunk] static content serving
We're using the cascade app from paste:

http://pythonpaste.org/modules/cascade.html

Along with the paste StaticURLParser and StaticJavascripts (from pylons)

It's configured like this.

So configuring this should be as simple as setting up the proper info
in the ini file.

        javascripts_app = StaticJavascripts()
        static_app = StaticURLParser(config['pylons.paths']['static_files'])
        app = Cascade([static_app, javascripts_app, app])

Let me know if we need to expose some more configuration information
to the user app, all of this was changed sort-of-recently when we
cleaned up middleware.py.

On Wed, Jul 9, 2008 at 10:32 AM, Diez B. Roggisch <de...@web.de> wrote:

> Hi,

> can somebody give me a hint on how static content is served? I need to "embed"
> the TG2-app into an existing wsgi-app below a certain path - and obviously
> serving e.g. the CSS fails miserably. There was the old way of using tg.url
> and server.webpath (or such) - any such facility available?

> Diez

--
Mark Ramm-Christensen
email: mark at compoundthinking dot com
blog: www.compoundthinking.com/blog

 
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.
aspineux  
View profile  
 More options Jul 9 2008, 2:58 pm
From: aspineux <aspin...@gmail.com>
Date: Wed, 9 Jul 2008 11:58:42 -0700 (PDT)
Local: Wed, Jul 9 2008 2:58 pm
Subject: Re: static content serving

On Jul 9, 4:32 pm, "Diez B. Roggisch" <de...@web.de> wrote:

> Hi,

> can somebody give me a hint on how static content is served? I need to "embed"
> the TG2-app into an existing wsgi-app below a certain path - and obviously
> serving e.g. the CSS fails miserably. There was the old way of using tg.url
> and server.webpath (or such) - any such facility available?

It looks about the same as tg1, looks in controllers.py for tg.url

def url(tgpath, tgparams=None, **kw):
    """
    url() re-implementation from TG1
    """

    if not isinstance(tgpath, basestring):
        tgpath = "/".join(list(tgpath))
    if tgpath.startswith("/"):
        app_root =
pylons.request.application_url[len(pylons.request.host_url):]
        tgpath = app_root + tgpath
        tgpath = pylons.config.get("server.webpath", "") + tgpath
        result = tgpath
    else:
        result = tgpath
....


 
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.
Diez B. Roggisch  
View profile  
 More options Jul 10 2008, 5:31 am
From: "Diez B. Roggisch" <de...@web.de>
Date: Thu, 10 Jul 2008 11:31:21 +0200
Local: Thurs, Jul 10 2008 5:31 am
Subject: Re: [tg-trunk] Re: static content serving
On Wednesday 09 July 2008 17:50:43 Mark Ramm wrote:

Ahh! That's interesting - and explains some stuff I've seen while
source-level-debugging. The Cascade is interersting for me...

And of course the current implementation is a bit warty::

        # Static files (If running in production, and Apache or another web
        # server is handling this static content, remove the following 3
lines)
        javascripts_app = StaticJavascripts()
        static_app = StaticURLParser(config['pylons.paths']['static_files'])
        app = Cascade([static_app, javascripts_app, app])
        return app

Obviously we want that configurable.

I will open a ticket & try and install TG2 from SVN, so that I can propose a
solution for this. I guess the best solution would be to have the above code
in <myapplication>/controllers/__init__.py or some such location - or the
config/middleware.py, that might even be better.

Diez


 
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.
Diez B. Roggisch  
View profile  
 More options Jul 10 2008, 5:40 am
From: "Diez B. Roggisch" <de...@web.de>
Date: Thu, 10 Jul 2008 11:40:37 +0200
Local: Thurs, Jul 10 2008 5:40 am
Subject: Re: [tg-trunk] Re: static content serving
On Thursday 10 July 2008 11:31:21 Diez B. Roggisch wrote:

I created a ticket:

http://trac.turbogears.org/ticket/1898#preview

Diez


 
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.
Diez B. Roggisch  
View profile  
 More options Jul 10 2008, 6:30 am
From: "Diez B. Roggisch" <de...@web.de>
Date: Thu, 10 Jul 2008 12:30:13 +0200
Local: Thurs, Jul 10 2008 6:30 am
Subject: Re: [tg-trunk] Re: static content serving
On Wednesday 09 July 2008 20:58:42 aspineux wrote:

The question is: where to set this? I tried

[server:main]

in development.ini, and it puked on me about an unknown argument.

I then stuffed into

[app:main]
server.webpath = /collaborate

also in development.ini - but the access above reading "server.webpath"
doesn't work for me then. The value appears as this:

pylons.config.app_conf.get('server.webpath')

So... where is that supposed to be, and is this a bug?

Diez


 
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.
aspineux  
View profile  
 More options Jul 10 2008, 7:18 am
From: aspineux <aspin...@gmail.com>
Date: Thu, 10 Jul 2008 04:18:50 -0700 (PDT)
Local: Thurs, Jul 10 2008 7:18 am
Subject: Re: static content serving

On 10 juil, 12:30, "Diez B. Roggisch" <de...@web.de> wrote:

Try them all :-)


 
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.
Diez B. Roggisch  
View profile  
 More options Jul 10 2008, 9:23 am
From: "Diez B. Roggisch" <de...@web.de>
Date: Thu, 10 Jul 2008 15:23:27 +0200
Local: Thurs, Jul 10 2008 9:23 am
Subject: Re: [tg-trunk] static content serving

> can somebody give me a hint on how static content is served? I need to
> "embed" the TG2-app into an existing wsgi-app below a certain path - and
> obviously serving e.g. the CSS fails miserably. There was the old way of
> using tg.url and server.webpath (or such) - any such facility available?

Ok, I created a patch for the ticket. It includes rewrites of tg.middleware an
middleware.py_tmpl (so that the app decides on the static rewriting), and
tg.url-enclosing of hopefully all relevant template-urls.

Before I attach that, I have some questions I need to have answered:

 - where does the sever.webpath config option actually go? Currently, I've put
it as this in my development.ini::

  [app:main]
  use = egg:AuthenticationTest
  full_stack = true
  #lang = ru
  cache_dir = %(here)s/data
  beaker.session.key = authenticationtest
  beaker.session.secret = somesecret
  server.webpath = /collaborate

It is accessed using

pylons.config['app_cfg']['sever.webpath']

 - how is server.webpath supposed to be used? The question arises because of
the following considerations:

   1) if the TG2-app is one of possibly several below a WSGI-app "mounted" to
server.webpath, we need to rewrite the PATH_INFO prior to all requests to
remove the server.webpath. I've done that, and it makes additionally
adjustments to tg.ext.repoze.who necessary (done them also) because of the
generated /login and related urls. These need to be prepended with
server.webpath.

  2) if the TG2-app is below server.webpath in an Apache-environment, it
*might* be possible to use mod_rewrite to strip of the path-prefix for us,
thus only the generated urls must

I've done everything for 1). If 2) is an actual scenario we want to work with,
it might be necessary to introduce another config-variable called
server.strip_webpath or so, that controls the adjustment of PATH_INFO.

Diez


 
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.
Mark Ramm  
View profile  
 More options Aug 10 2008, 2:22 pm
From: "Mark Ramm" <mark.mchristen...@gmail.com>
Date: Sun, 10 Aug 2008 14:22:45 -0400
Local: Sun, Aug 10 2008 2:22 pm
Subject: Re: [tg-trunk] Re: static content serving
Hmm, sorry I missed this earlier.

I think that we should be relying on SCRIPT_NAME in the environ being
set properly, and it looks like I need to patch tg.url to make that
work right.

When serving behing apache or another server that does the right
thing, the SCRIPT_NAME should automatically be set correctly.   When
it's not we'll need to use some little middleware that sets it right
before we get into the tg2 app.

Inside a TG2 app, we can use request.application_url to get the URL
including the host name and SCRIPT_NAME but with no PATH_INFO or query
string.

On Thu, Jul 10, 2008 at 9:23 AM, Diez B. Roggisch <de...@web.de> wrote:

--
Mark Ramm-Christensen
email: mark at compoundthinking dot com
blog: www.compoundthinking.com/blog

 
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     Older topic »