From: robk-tahoe Date: Wed, 23 Jan 2008 00:44:58 +0000 (-0700) Subject: tweak webish to use resource_filename to find css and html files X-Git-Url: https://git.rkrishnan.org/somewhere?a=commitdiff_plain;h=6ef4606534a031a4133eeb8be62e34f2140d7992;p=tahoe-lafs%2Ftahoe-lafs.git tweak webish to use resource_filename to find css and html files using sibpath to find web template files relative to source code is functional when running from source environments, but not especially flexible when running from bundled built environments. the more 'orthodox' mechanism, pkg_resources, in theory at least, knows how to find resource files in various environments. this makes the 'web' directory in allmydata into an actual allmydata.web module (since pkg_resources looks for files relative to a named module, and that module must be importable) and uses pkg_resources.resource_filename to find the files therein. --- diff --git a/src/allmydata/web/__init__.py b/src/allmydata/web/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/src/allmydata/webish.py b/src/allmydata/webish.py index f9e4aa7d..93f534b4 100644 --- a/src/allmydata/webish.py +++ b/src/allmydata/webish.py @@ -8,7 +8,7 @@ from twisted.internet import defer from twisted.internet.interfaces import IConsumer from nevow import inevow, rend, loaders, appserver, url, tags as T from nevow.static import File as nevow_File # TODO: merge with static.File? -from allmydata.util import fileutil, sibpath +from allmydata.util import fileutil import simplejson from allmydata.interfaces import IDownloadTarget, IDirectoryNode, IFileNode, \ IMutableFileNode @@ -20,8 +20,10 @@ from zope.interface import implements, Interface import urllib from formless import webform +from nevow.util import resource_filename + def getxmlfile(name): - return loaders.xmlfile(sibpath.sibpath(__file__, "web/%s" % name)) + return loaders.xmlfile(resource_filename('allmydata.web', '%s' % name)) class IClient(Interface): pass @@ -1302,7 +1304,7 @@ class Root(rend.Page): return rend.Page.locateChild(self, ctx, segments) child_webform_css = webform.defaultCSS - child_tahoe_css = nevow_File(sibpath.sibpath(__file__, "web/tahoe.css")) + child_tahoe_css = nevow_File(resource_filename('allmydata.web', 'tahoe.css')) child_provisioning = provisioning.ProvisioningTool()