No, I think Pyramid is handling everything correctly. Here's what I
do: I have one application which may be installed multiple times with
different configurations. These configurations are implemented as
packages which are included using config.include(). The application
provides defaults for favicon.ico, styles.css, etc, and my first
thought was to simply let the config package override these assets:

config.add_static_view('static', 'mypackage:static')

and in the includeme of the config package:

config.add_static_view('config_static', 'myconfigpackage:static')
config.override_asset(to_override='mypackage:static/favicon.ico',
override_with='myconfigpackage:static/favicon.ico')

In the site template I use

request.static_url('mypackage:static/favicon.ico')

which will create a URL like

/static/favicon.ico

but pyramid will resolve the override and serve the favicon of the
config package.

Now for production deployment I want to bypass Pyramid and serve the
static assets of both, the application and the config package directly
from nginx.
But config like

location /static {
    alias /path/to/mypackage/static;
}

will not work because this will serve the default favicon.ico. So I
switched to a more restrictive model letting config packages only
register particular assets which I then lookup from the registry in
the site template.
But I would like to disable override_assset, before a config package
is included to prevent mistakes which will be hard to test for.


On Wed, Dec 14, 2011 at 1:45 PM, Chris McDonough <chr...@plope.com> wrote:
> On Wed, 2011-12-14 at 04:15 -0800, Robert Forkel wrote:
>> Hi all,
>> i was trying to abuse the 'add_directive' method of a Configurator to
>> disable built-in directives, but failed, because add_directive will
>> only add new ones. Now this may be totally unreasonable in the first
>> place, but what I wanted to accomplish is the following:
>> I'd like to have static assets served directly by nginx via an alias.
>> But this fails when override_asset is used (e.g. by an included config
>> package to change the favicon, etc.). So I was looking for a way to
>> disable override_asset.
>> Am I totally off?
>
> Before getting in to what it will take to use add_directive to override
> existing directives, do you know about using a URL prefix as the "name"
> argument to add_static_view?  Eg.
>
> config.add_static_view('http://some.site/', 'mypackage:static')
>
> Instead of
>
> config.add_static_view('static', 'mypackage:static')
>
> And then:
>
> request.static_url('mypackage:static/css/foo.css')
>
> If so, are you saying that somehow asset overrides fool Pyramid here
> when generating the URL?
>
> - C
>
>
>> regards
>> robert
>>
>
>
> --
> You received this message because you are subscribed to the Google Groups 
> "pylons-discuss" group.
> To post to this group, send email to pylons-discuss@googlegroups.com.
> To unsubscribe from this group, send email to 
> pylons-discuss+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/pylons-discuss?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To post to this group, send email to pylons-discuss@googlegroups.com.
To unsubscribe from this group, send email to 
pylons-discuss+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en.

Reply via email to