On Fri, 2010-04-30 at 19:13 +0100, Chris Withers wrote: > Hi All, > > Because I need to use the Twisted WSGI server for my app and so can't > use Paste,
While it's obviously useful to not require PasteDeploy, this itself is not true. You can use something like: from repoze.bfg.paster import get_app app = get_app('some_config_file.ini', 'myapp') Where "myapp" refers to: [pipeline:myapp] pipeline = foo bar baz http://docs.repoze.org/bfg/1.3/api/paster.html#repoze.bfg.paster.get_app Then use whatever twisted has for serving up WSGI apps: serve(app) > I'm running into some issues. Here's my run.py, adapted from > the routes alchemy template: > > """ > from repoze.bfg.configuration import Configurator > from repoze.tm import make_tm > from twisted.web.wsgi import WSGIResource > from twisted.web.server import Site > from twisted.internet import reactor > > def app(global_config, **settings): > import demo > config = Configurator(settings=settings) > config.begin() > config.scan(demo) > config.add_static_view('static','demo:templates/static') > config.end() > return config.make_wsgi_app() > > def main(): > > wsgi = WSGIResource(reactor, reactor.getThreadPool(), > # wsgi middlewear > make_tm( > app(None, > # from settings.ini > reload_templates = True, > debug_authorization = False, > debug_notfound = False, > ), > None), > ) > factory = Site(wsgi, 'server.log') > reactor.listenTCP(8080, factory) > reactor.run() > > if __name__=='__main__': > main() > """ > > The first bug is that when run with "python -m demo.run", config.scan() > guesses the wrong package by default. I'm guessing that's a bug, but as > you can see, easy to work around. > The second bug is with add_static_view which seems to suffer from the > same problem. Unless I put the "demo:" in front, it guesses the wrong > package again and I get the following when I try to access the static view: > > File > "bfgenv/lib/python2.5/site-packages/repoze.tm2-1.0a5-py2.5.egg/repoze/tm/__init__.py", > > line 23, in __call__ > result = self.application(environ, save_status_and_headers) > File > "bfgenv/lib/python2.5/site-packages/repoze.bfg-1.2-py2.5.egg/repoze/bfg/router.py", > > line 130, in __call__ > response = view_callable(context, request) > File > "bfgenv/lib/python2.5/site-packages/repoze.bfg-1.2-py2.5.egg/repoze/bfg/view.py", > > line 227, in __call__ > return request_copy.get_response(self.app) > File "build/bdist.linux-x86_64/egg/webob/request.py", line 919, in > get_response > > File "build/bdist.linux-x86_64/egg/webob/request.py", line 887, in > call_application > > File > "bfgenv/lib/python2.5/site-packages/repoze.bfg-1.2-py2.5.egg/repoze/bfg/static.py", > > line 35, in __call__ > if not pkg_resources.resource_exists(self.package_name, resource): > File > "bfgenv/lib/python2.5/site-packages/setuptools-0.6c11-py2.5.egg/pkg_resources.py", > > line 871, in resource_exists > > File > "bfgenv/lib/python2.5/site-packages/setuptools-0.6c11-py2.5.egg/pkg_resources.py", > > line 1170, in has_resource > > File > "bfgenv/lib/python2.5/site-packages/setuptools-0.6c11-py2.5.egg/pkg_resources.py", > > line 1218, in _has > > exceptions.NotImplementedError: Can't perform this operation for > unregistered loader type > > Why does BFG guess wrong here and how can I correct BFG's notion of what > the current package is? config = Configurator(package=some.package, ...) ... might be the right solution, depending on how you're calling it. http://docs.repoze.org/bfg/1.3/api/configuration.html#repoze.bfg.configuration.Configurator - C _______________________________________________ Repoze-dev mailing list Repoze-dev@lists.repoze.org http://lists.repoze.org/listinfo/repoze-dev