Skip to content

Commit

Permalink
Merge branch 'master' into 2955-update-recline
Browse files Browse the repository at this point in the history
  • Loading branch information
domoritz committed Oct 13, 2012
2 parents 9e6c801 + c113ef8 commit c9afe33
Show file tree
Hide file tree
Showing 34 changed files with 2,691 additions and 2,577 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.txt
@@ -1,6 +1,16 @@
CKAN CHANGELOG
++++++++++++++

v2.0
====

* [#2257] Removed restrict_template_vars config setting.
* [#2257] Removed deprecated facet_title() template helper function, use
get_facet_title() instead.
* [#2257] Removed deprecated am_authorized() template helper function, use
check_access() instead.
* [#2257] Removed deprecated datetime_to_datestr() template helper function.

v1.8
====

Expand Down
16 changes: 10 additions & 6 deletions ckan/config/deployment.ini_tmpl
Expand Up @@ -4,7 +4,16 @@
# The %(here)s variable will be replaced with the parent directory of this file
#
[DEFAULT]
debug = true

# Change debug to true when doing CKAN development, it enables Pylons'
# interactive debugging tool, makes Fanstatic serve unminified JS and CSS
# files, and enables CKAN templates' debugging features.
#
# WARNING: *THIS SETTING MUST BE SET TO FALSE ON A PRODUCTION ENVIRONMENT*
# Debug mode will enable the interactive debugging tool, allowing ANYONE to
# execute malicious code after an exception is raised.
debug = false

email_to = you@yourdomain.com
smtp_server = localhost
error_email_from = paste@localhost
Expand Down Expand Up @@ -32,11 +41,6 @@ ckan.plugins = stats
#beaker.cache.data_dir = %(here)s/data/cache
#beaker.session.data_dir = %(here)s/data/sessions

# WARNING: *THE LINE BELOW MUST BE UNCOMMENTED ON A PRODUCTION ENVIRONMENT*
# Debug mode will enable the interactive debugging tool, allowing ANYONE to
# execute malicious code after an exception is raised.
set debug = false

# Specify the database for SQLAlchemy to use:
# * Postgres is currently required for a production CKAN deployment
# * Sqlite (memory or file) can be used as a quick alternative for testing
Expand Down
15 changes: 5 additions & 10 deletions ckan/config/environment.py
Expand Up @@ -32,7 +32,7 @@ class _Helpers(object):
missing functions from causing template exceptions. Useful if
templates have helper functions provided by extensions that have
not been enabled. '''
def __init__(self, helpers, restrict=True):
def __init__(self, helpers):
functions = {}
allowed = helpers.__allowed_functions__[:]
# list of functions due to be deprecated
Expand All @@ -41,8 +41,7 @@ def __init__(self, helpers, restrict=True):
for helper in dir(helpers):
if helper not in allowed:
self.deprecated.append(helper)
if restrict:
continue
continue
functions[helper] = getattr(helpers, helper)
if helper in allowed:
allowed.remove(helper)
Expand Down Expand Up @@ -80,10 +79,8 @@ def __getattr__(self, name):
return self.functions[name]
else:
if name in self.deprecated:
msg = 'Template helper function `%s` is not available ' \
'as it has been deprecated.\nYou can enable it ' \
'by setting ckan.restrict_template_vars = true ' \
'in your .ini file.' % name
msg = ('Template helper function `{0}` is not available '
'because it has been deprecated.'.format(name))
self.log.critical(msg)
else:
msg = 'Helper function `%s` could not be found\n ' \
Expand Down Expand Up @@ -181,9 +178,7 @@ def find_controller(self, controller):
config['pylons.app_globals']._init()

# add helper functions
restrict_helpers = asbool(
config.get('ckan.restrict_template_vars', 'true'))
helpers = _Helpers(h, restrict_helpers)
helpers = _Helpers(h)
config['pylons.h'] = helpers

## redo template setup to use genshi.search_path
Expand Down
42 changes: 21 additions & 21 deletions ckan/config/middleware.py
Expand Up @@ -26,6 +26,7 @@
from ckan.config.environment import load_environment
import ckan.lib.app_globals as app_globals


def make_app(global_conf, full_stack=True, static_files=True, **app_conf):
"""Create a Pylons WSGI application and return it
Expand Down Expand Up @@ -64,30 +65,29 @@ def make_app(global_conf, full_stack=True, static_files=True, **app_conf):
app = RoutesMiddleware(app, config['routes.map'])
app = SessionMiddleware(app, config)
app = CacheMiddleware(app, config)

# CUSTOM MIDDLEWARE HERE (filtered by error handling middlewares)
#app = QueueLogMiddleware(app)

# Fanstatic
if asbool(config.get('debug', False)):
fanstatic_config = {
'versioning' : True,
'recompute_hashes' : True,
'minified' : False,
'bottom' : True,
'bundle' : False,
'versioning': True,
'recompute_hashes': True,
'minified': False,
'bottom': True,
'bundle': False,
}
else:
fanstatic_config = {
'versioning' : True,
'recompute_hashes' : False,
'minified' : True,
'bottom' : True,
'bundle' : True,
'versioning': True,
'recompute_hashes': False,
'minified': True,
'bottom': True,
'bundle': True,
}
app = Fanstatic(app, **fanstatic_config)


if asbool(full_stack):
# Handle Python exceptions
app = ErrorHandler(app, global_conf, **config['pylons.errorware'])
Expand All @@ -98,15 +98,15 @@ def make_app(global_conf, full_stack=True, static_files=True, **app_conf):
app = StatusCodeRedirect(app, [400, 404])
else:
app = StatusCodeRedirect(app, [400, 404, 500])

# Initialize repoze.who
who_parser = WhoConfig(global_conf['here'])
who_parser.parse(open(app_conf['who.config_file']))

if asbool(config.get('openid_enabled', 'true')):
from repoze.who.plugins.openid.identification import OpenIdIdentificationPlugin
# Monkey patches for repoze.who.openid
# Fixes #1659 - enable log-out when CKAN mounted at non-root URL
# Fixes #1659 - enable log-out when CKAN mounted at non-root URL
from ckan.lib import repoze_patch
OpenIdIdentificationPlugin.identify = repoze_patch.identify
OpenIdIdentificationPlugin.redirect_to_logged_in = repoze_patch.redirect_to_logged_in
Expand All @@ -117,7 +117,7 @@ def make_app(global_conf, full_stack=True, static_files=True, **app_conf):
not isinstance(i, OpenIdIdentificationPlugin)]
who_parser.challengers = [i for i in who_parser.challengers if \
not isinstance(i, OpenIdIdentificationPlugin)]

app = PluggableAuthenticationMiddleware(app,
who_parser.identifiers,
who_parser.authenticators,
Expand All @@ -126,10 +126,10 @@ def make_app(global_conf, full_stack=True, static_files=True, **app_conf):
who_parser.request_classifier,
who_parser.challenge_decider,
logging.getLogger('repoze.who'),
logging.WARN, # ignored
logging.WARN, # ignored
who_parser.remote_user_key,
)

# Establish the Registry for this application
app = RegistryManager(app)

Expand All @@ -152,7 +152,7 @@ def make_app(global_conf, full_stack=True, static_files=True, **app_conf):
StaticURLParser(public_path.strip(),
cache_max_age=static_max_age)
)
app = Cascade(extra_static_parsers+static_parsers)
app = Cascade(extra_static_parsers + static_parsers)

# Page cache
if asbool(config.get('ckan.page_cache_enabled')):
Expand All @@ -164,6 +164,7 @@ def make_app(global_conf, full_stack=True, static_files=True, **app_conf):

return app


class I18nMiddleware(object):
"""I18n Middleware selects the language based on the url
eg /fr/home is French"""
Expand Down Expand Up @@ -198,7 +199,7 @@ def __call__(self, environ, start_response):
# Current application url
path_info = environ['PATH_INFO']
# sort out weird encodings
path_info = '/'.join(urllib.quote(pce,'') for pce in path_info.split('/'))
path_info = '/'.join(urllib.quote(pce, '') for pce in path_info.split('/'))

qs = environ.get('QUERY_STRING')

Expand Down Expand Up @@ -317,7 +318,6 @@ def __init__(self, app, config):
self.app = app
self.engine = sa.create_engine(config.get('sqlalchemy.url'))


def __call__(self, environ, start_response):
path = environ['PATH_INFO']
if path == '/_tracking':
Expand Down
5 changes: 3 additions & 2 deletions ckan/controllers/storage.py
Expand Up @@ -262,8 +262,9 @@ def get_metadata(self, label):
if storage_backend in ['google', 's3']:
if not label.startswith("/"):
label = "/" + label
url = "https://%s/%s%s" % (self.ofs.conn.server_name(),
bucket, label)
url = "https://%s%s" % (
self.ofs.conn.calling_format.build_host(
self.ofs.conn.server_name(), bucket), label)
else:
url = h.url_for('storage_file',
label=label,
Expand Down

0 comments on commit c9afe33

Please sign in to comment.