Hi Chris,

Thanks for your reply. The question is not how to convert relative asset 
spec to absolute one but how to get package_name attribute of the topmost 
configurator given configurator passed to includeme(config) of third party 
library.

- Alex K

On Tuesday, September 18, 2012 12:21:39 PM UTC-4, Chris McDonough wrote:
>
> On Tue, 2012-09-18 at 06:57 -0700, askel wrote: 
> > I'm developing renderer library for Pyramid framework. It's just kind 
> > of adapter to use existing template engine in Pyramid applications. 
> > The library is using asset specs for template names. And I'd like it 
> > to use application package name in case asset spec is missing package 
> > part. Originally, I used caller_package 
> > 
> >     from pyramid.path import caller_package, AssetResolver 
> > 
> >     def includeme(config): 
> >         package = caller_package(3) 
> >         resolver = AssetResolver(package) 
> > 
> > While that worked for "imperative" configuration method (by calling 
> > config.include('my.library.package')), it did not work for 
> > "declarative" one (via pyramid.includes in INI file). 
> > 
> > I changed it to the following: 
> > 
> >     def includeme(config): 
> >         package = config.registry.__name__ 
> >         resolver = AssetResolver(package) 
> > 
> > And this way it works for both configuration methods. But I'm afraid 
> > that I'm using undocumented implementation details and that could stop 
> > working in the future. 
> > 
> > Is there any "official" way to determine application package name? 
>
> You probably want to use 
>
> http://docs.pylonsproject.org/projects/pyramid/en/1.4-branch/api/config.html#pyramid.config.Configurator.absolute_asset_spec
>  
>
> - C 
>
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/pylons-discuss/-/K7HCyURHZ6wJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en.

Reply via email to