Skip to content

Commit

Permalink
Merge branch 'master' into override-feed-class
Browse files Browse the repository at this point in the history
  • Loading branch information
martinburchell committed Sep 21, 2016
2 parents 06237be + 23a6baa commit 73bded7
Show file tree
Hide file tree
Showing 405 changed files with 34,256 additions and 14,029 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.rst
Expand Up @@ -7,6 +7,15 @@
Changelog
---------

v2.6.0 TBA
=================
API changes and deprecations:
* Replace `c.__version__` with new helper `h.ckan_version()` (#3103)

Major:
* Private datasets are now included in the default dataset search results (#3191)
* package_search API action now has an include_private parameter (#3191)

v2.5.2 2016-03-31
=================

Expand Down
2 changes: 2 additions & 0 deletions bin/running_stats.py
@@ -1,3 +1,5 @@
# encoding: utf-8

'''Tool for a script to keep track changes performed on a large number
of objects.
Expand Down
7 changes: 5 additions & 2 deletions circle.yml
Expand Up @@ -15,15 +15,16 @@ machine:
version: 0.10.33

dependencies:

pre:
- "[ -e ~/.local/bin/circleci-matrix ]
|| mkdir -p ~/.local/bin
&& curl -fsSL https://raw.githubusercontent.com/michaelcontento/circleci-matrix/master/src/circleci-matrix.sh -o ~/.local/bin/circleci-matrix
&& chmod +x ~/.local/bin/circleci-matrix"

override:
- pip install -r requirements.txt --allow-all-external
- pip install -r dev-requirements.txt --allow-all-external
- pip install -r requirements.txt
- pip install -r dev-requirements.txt
- python setup.py develop

post:
Expand All @@ -38,6 +39,7 @@ dependencies:
- ~/nvm/v0.10.33/bin/phantomjs

database:

post:
- sudo -E -u postgres ./bin/postgres_init/1_create_ckan_db.sh
- sudo -E -u postgres ./bin/postgres_init/2_create_ckan_datastore_db.sh
Expand All @@ -53,6 +55,7 @@ database:
- paster db init -c test-core.ini

test:

override:
- circleci-matrix:
parallel: true
Expand Down
2 changes: 1 addition & 1 deletion ckan/__init__.py
@@ -1,6 +1,6 @@
# encoding: utf-8

__version__ = '2.6.0a'
__version__ = '2.7.0a'

__description__ = 'CKAN Software'
__long_description__ = \
Expand Down
2 changes: 1 addition & 1 deletion ckan/authz.py
Expand Up @@ -4,7 +4,7 @@
import re
from logging import getLogger

from pylons import config
from ckan.common import config
from paste.deploy.converters import asbool

import ckan.plugins as p
Expand Down
2 changes: 1 addition & 1 deletion ckan/ckan_nose_plugin.py
Expand Up @@ -8,7 +8,7 @@
import re
import pkg_resources
from paste.deploy import loadapp
from pylons import config
from ckan.common import config
import unittest
import time

Expand Down
97 changes: 97 additions & 0 deletions ckan/common.py
Expand Up @@ -8,6 +8,12 @@
# NOTE: This file is specificaly created for
# from ckan.common import x, y, z to be allowed

from collections import MutableMapping

import flask
import pylons

from werkzeug.local import Local

from pylons.i18n import _, ungettext
from pylons import g, c, request, session, response
Expand All @@ -17,3 +23,94 @@
from collections import OrderedDict # from python 2.7
except ImportError:
from sqlalchemy.util import OrderedDict


def is_flask_request():
u'''
A centralized way to determine whether we are in the context of a
request being served by Flask or Pylons
'''
try:
pylons.request.environ
pylons_request_available = True
except TypeError:
pylons_request_available = False

return (flask.request and
(flask.request.environ.get(u'ckan.app') == u'flask_app' or
not pylons_request_available))


class CKANConfig(MutableMapping):
u'''Main CKAN configuration object
This is a dict-like object that also proxies any changes to the
Flask and Pylons configuration objects.
The actual `config` instance in this module is initialized in the
`load_environment` method with the values of the ini file or env vars.
'''

def __init__(self, *args, **kwargs):
self.store = dict()
self.update(dict(*args, **kwargs))

def __getitem__(self, key):
return self.store[key]

def __iter__(self):
return iter(self.store)

def __len__(self):
return len(self.store)

def __repr__(self):
return self.store.__repr__()

def copy(self):
return self.store.copy()

def clear(self):
self.store.clear()

try:
flask.current_app.config.clear()
except RuntimeError:
pass
try:
pylons.config.clear()
# Pylons set this default itself
pylons.config[u'lang'] = None
except TypeError:
pass

def __setitem__(self, key, value):
self.store[key] = value
try:
flask.current_app.config[key] = value
except RuntimeError:
pass
try:
pylons.config[key] = value
except TypeError:
pass

def __delitem__(self, key):
del self.store[key]
try:
del flask.current_app.config[key]
except RuntimeError:
pass
try:
del pylons.config[key]
except TypeError:
pass

local = Local()

# This a proxy to the bounded config object
local(u'config')

# Thread-local safe objects
config = local.config = CKANConfig()
12 changes: 8 additions & 4 deletions ckan/config/deployment.ini_tmpl
Expand Up @@ -78,7 +78,11 @@ ckan.auth.roles_that_cascade_to_sub_groups = admin
ckan.site_id = default
#solr_url = http://127.0.0.1:8983/solr

#ckan.simple_search = 1

## Redis Settings

# URL to your Redis instance, including the database to be used.
#ckan.redis.url = redis://localhost:6379/0


## CORS Settings
Expand Down Expand Up @@ -166,11 +170,11 @@ ckan.hide_activity_from_users = %(ckan.site_id)s

## Email settings

#email_to = you@yourdomain.com
#error_email_from = paste@localhost
#email_to = errors@example.com
#error_email_from = ckan-errors@example.com
#smtp.server = localhost
#smtp.starttls = False
#smtp.user = your_username@gmail.com
#smtp.user = username@example.com
#smtp.password = your_password
#smtp.mail_from =

Expand Down
31 changes: 24 additions & 7 deletions ckan/config/environment.py
@@ -1,28 +1,29 @@
# encoding: utf-8

"""Pylons environment configuration"""
'''CKAN environment configuration'''
import os
import logging
import warnings
from urlparse import urlparse
import pytz

import sqlalchemy
from pylons import config
from pylons import config as pylons_config
import formencode

import ckan.config.routing as routing
import ckan.model as model
import ckan.plugins as p
import ckan.lib.helpers as helpers
import ckan.lib.app_globals as app_globals
from ckan.lib.redis import is_redis_available
import ckan.lib.render as render
import ckan.lib.search as search
import ckan.logic as logic
import ckan.authz as authz
import ckan.lib.jinja_extensions as jinja_extensions

from ckan.common import _, ungettext
from ckan.common import _, ungettext, config
from ckan.exceptions import CkanConfigurationException

log = logging.getLogger(__name__)
Expand Down Expand Up @@ -72,8 +73,17 @@ def find_controller(self, controller):
static_files=os.path.join(root, 'public'),
templates=[])

# Initialize config with the basic options
config.init_app(global_conf, app_conf, package='ckan', paths=paths)
# Initialize main CKAN config object
config.update(global_conf)
config.update(app_conf)

# Initialize Pylons own config object
pylons_config.init_app(global_conf, app_conf, package='ckan', paths=paths)

# Update the main CKAN config object with the Pylons specific stuff, as it
# quite hard to keep them separated. This should be removed once Pylons
# support is dropped
config.update(pylons_config)

# Setup the SQLAlchemy database engine
# Suppress a couple of sqlalchemy warnings
Expand All @@ -84,9 +94,14 @@ def find_controller(self, controller):
for msg in msgs:
warnings.filterwarnings('ignore', msg, sqlalchemy.exc.SAWarning)

# Check Redis availability
if not is_redis_available():
log.critical('Could not connect to Redis.')

# load all CKAN plugins
p.load_all(config)
p.load_all()

app_globals.reset()

# A mapping of config settings that can be overridden by env vars.
# Note: Do not remove the following lines, they are used in the docs
Expand All @@ -95,6 +110,7 @@ def find_controller(self, controller):
'sqlalchemy.url': 'CKAN_SQLALCHEMY_URL',
'ckan.datastore.write_url': 'CKAN_DATASTORE_WRITE_URL',
'ckan.datastore.read_url': 'CKAN_DATASTORE_READ_URL',
'ckan.redis.url': 'CKAN_REDIS_URL',
'solr_url': 'CKAN_SOLR_URL',
'ckan.site_id': 'CKAN_SITE_ID',
'ckan.site_url': 'CKAN_SITE_URL',
Expand Down Expand Up @@ -184,10 +200,11 @@ def update_config():
# The RoutesMiddleware needs its mapper updating if it exists
if 'routes.middleware' in config:
config['routes.middleware'].mapper = routes_map
# routes.named_routes is a CKAN thing
config['routes.named_routes'] = routing.named_routes
config['pylons.app_globals'] = app_globals.app_globals
# initialise the globals
config['pylons.app_globals']._init()
app_globals.app_globals._init()

helpers.load_plugin_helpers()
config['pylons.h'] = helpers.helper_functions
Expand Down

0 comments on commit 73bded7

Please sign in to comment.