Correct way of detecting application package in third party package
69 views
Skip to first unread message
askel
unread,
Sep 18, 2012, 9:57:16 AM9/18/12
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to pylons-discuss
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
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).
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?
- Alex K
Chris McDonough
unread,
Sep 18, 2012, 12:21:35 PM9/18/12
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to pylons-...@googlegroups.com
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
Robert Forkel
unread,
Jul 23, 2013, 4:30:53 AM7/23/13
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to pylons-...@googlegroups.com
Hi all, I just came across the same problem as OP: How do I determine the "application" package from an includeme function. I found the two attributes "package" and "package_name" of the Configurator object and think this is what I want. But since these are not documented as public API, is it safe to access them? Or may this change with any new pyramid version? best robert
Chris McDonough
unread,
Jul 23, 2013, 4:50:17 AM7/23/13
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to pylons-...@googlegroups.com
It's undefined. I'd suggest setting something in registry.settings and
using it if it exists.
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to pylons-...@googlegroups.com
Robert,
Package and package_name of configurator passed to includeme reference includeme's package and not the application package.
- Alex K
Robert Forkel
unread,
Jul 24, 2013, 6:32:20 AM7/24/13
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to pylons-discuss
Hi Alex,
I noticed this, and was a bit confused at first, because I had inspected config.package in a different function where config was passed in. So I ended up not using the "includeme" mechanism, which is not a big deal, because I'm only using imperative configuration anyway.