config.py broken for projects in namespaces

0 views
Skip to first unread message

James

unread,
Jan 22, 2009, 8:41:57 PM1/22/09
to TurboGears
As a result of re-factoring work described here:
http://groups.google.com/group/turbogears/browse_frm/thread/3f5343f102949b86

The layout of my package has changed; the module is one layer deeper
than it was before, because of the new namespace directory.

I noticed static content serving wasn't working, and narrowed it down
to these lines from config.py (TG v1.0.8):
lastdot = modulename.rfind('.')
firstdot = modulename.find('.')
packagename = modulename[:lastdot]
top_level_package = modulename[:firstdot]
...
top_level_dir = os.path.normpath
(pkg_resources.resource_filename(
top_level_package, ''))

If modulename is of the form 'module.config', it all works. If
modulename is of the form 'namespace.module.config', top_level_dir is
set to a completely wrong value based off the namespace, not the whole
package.

I think changing the last line to:
top_level_dir = os.path.normpath
(pkg_resources.resource_filename(
packagename, ''))

Should handle namespaced and non-namespaced packages alike - should I
raise a ticket?

Christoph Zwerschke

unread,
Jan 23, 2009, 7:15:25 AM1/23/09
to turbo...@googlegroups.com
James schrieb:

> I think changing the last line to:
> top_level_dir = os.path.normpath
> (pkg_resources.resource_filename(
> packagename, ''))
>
> Should handle namespaced and non-namespaced packages alike - should I
> raise a ticket?

That does not look like the right fix. If any, we should change the
app.cfg template to say "%(package_dir)s/static" instead of
"%(top_level_dir)s/static" or add a note as a comment there in the
config. Better create a ticket so we won't forget looking into this.

-- Christoph

James

unread,
Jan 23, 2009, 7:29:20 AM1/23/09
to TurboGears
Ah, this might well be a dupe of http://trac.turbogears.org/ticket/12
- the oldest open ticket :)

It's a more specific problem, and easier to fix than the general case
of serving static content from an arbitrary directory, but still... It
seems too close to deserve a separate ticket.

Christoph Zwerschke

unread,
Jan 23, 2009, 7:59:51 AM1/23/09
to turbo...@googlegroups.com
James schrieb:

> Ah, this might well be a dupe of http://trac.turbogears.org/ticket/12
> - the oldest open ticket :)

Yes, seems it was never handled because the issue was unclear. I've
clarified this in a comment now.

-- Christoph

Reply all
Reply to author
Forward
0 new messages