Skip to content

Commit

Permalink
Merge pull request #1276 from okfn/1267-fix-urlfor-paster
Browse files Browse the repository at this point in the history
Make url_for work in paster commands
  • Loading branch information
joetsoi committed Nov 4, 2013
2 parents 5fd8b7a + fc10977 commit cba4e6c
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions ckan/lib/cli.py
Expand Up @@ -10,6 +10,8 @@
import ckan.include.rcssmin as rcssmin
import ckan.lib.fanstatic_resources as fanstatic_resources
import sqlalchemy as sa
import urlparse
import routes

import paste.script
from paste.registry import Registry
Expand Down Expand Up @@ -99,6 +101,12 @@ def _load_config(self):
self.translator_obj = MockTranslator()
self.registry.register(pylons.translator, self.translator_obj)

## give routes enough information to run url_for
parsed = urlparse.urlparse(conf.get('ckan.site_url', 'http://0.0.0.0'))
request_config = routes.request_config()
request_config.host = parsed.netloc + parsed.path
request_config.protocol = parsed.scheme

def _setup_app(self):
cmd = paste.script.appinstall.SetupCommand('setup-app')
cmd.run([self.filename])
Expand Down

0 comments on commit cba4e6c

Please sign in to comment.