Skip to content

Commit

Permalink
Merge branch 'master' into clean-models
Browse files Browse the repository at this point in the history
Conflicts:
	ckan/model/__init__.py
	ckan/model/group.py
	ckan/model/license.py
	ckan/model/package.py
  • Loading branch information
tobes committed Apr 20, 2012
2 parents 9de3cb8 + 8b31ea1 commit 8dfa64e
Show file tree
Hide file tree
Showing 133 changed files with 5,887 additions and 3,504 deletions.
26 changes: 0 additions & 26 deletions MIGRATE.txt

This file was deleted.

15 changes: 0 additions & 15 deletions RELEASE.txt

This file was deleted.

33 changes: 33 additions & 0 deletions ckan/config/deployment.ini_tmpl
Expand Up @@ -165,6 +165,39 @@ ckan.locale_default = en
ckan.locale_order = en de fr it es pl ru nl sv no cs_CZ hu pt_BR fi bg ca sq sr sr_Latn
ckan.locales_filtered_out = el ro lt sl

## Atom Feeds
#
# Settings for customising the metadata provided in
# atom feeds.
#
# These settings are used to generate the <id> tags for both feeds
# and entries. The unique <id>s are created following the method
# outlined in http://www.taguri.org/ ie - they generate tagURIs, as specified
# in http://tools.ietf.org/html/rfc4151#section-2.1 :
#
# <id>tag:thedatahub.org,2012:/feeds/group/933f3857-79fd-4beb-a835-c0349e31ce76</id>
#
# Each component has the corresponding settings:
#
# "thedatahub.org" is ckan.feeds.authority_name
# "2012" is ckan.feeds.date
#

# Leave blank to use the ckan.site_url config value, otherwise set to a
# domain or email address that you own. e.g. thedatahub.org or
# admin@thedatahub.org
ckan.feeds.authority_name =

# Pick a date of the form "yyyy[-mm[-dd]]" during which the above domain was
# owned by you.
ckan.feeds.date = 2012

# If not set, then the value in `ckan.site_id` is used.
ckan.feeds.author_name =

# If not set, then the value in `ckan.site_url` is used.
ckan.feeds.author_link =

## Webstore
## Uncommment to enable datastore
# ckan.datastore.enabled = 1
Expand Down
99 changes: 65 additions & 34 deletions ckan/config/environment.py
@@ -1,30 +1,67 @@
"""Pylons environment configuration"""
import os
from urlparse import urlparse
import logging
import warnings

from paste.deploy.converters import asbool

# Suppress benign warning 'Unbuilt egg for setuptools'
warnings.simplefilter('ignore', UserWarning)

from urlparse import urlparse

import pylons
from paste.deploy.converters import asbool
import sqlalchemy

from pylons import config
from pylons.i18n.translation import ugettext
from genshi.template import TemplateLoader
from genshi.filters.i18n import Translator
from paste.deploy.converters import asbool

import ckan.lib.app_globals as app_globals
import ckan.config.routing as routing
import ckan.model as model
import ckan.plugins as p
import ckan.lib.helpers as h
from ckan.config.routing import make_map
from ckan import model
from ckan import plugins
import ckan.lib.search as search
import ckan.lib.app_globals as app_globals


# Suppress benign warning 'Unbuilt egg for setuptools'
warnings.simplefilter('ignore', UserWarning)

class _Helpers(object):
''' Helper object giving access to template helpers stopping
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):
functions = {}
allowed = helpers.__allowed_functions__

for helper in dir(helpers):
if restrict and (helper not in allowed):
continue
functions[helper] = getattr(helpers, helper)
self.functions = functions

# extend helper functions with ones supplied by plugins
extra_helpers = []
for plugin in p.PluginImplementations(p.ITemplateHelpers):
helpers = plugin.get_helpers()
for helper in helpers:
if helper in extra_helpers:
raise Exception('overwritting extra helper %s' % helper)
extra_helpers.append(helper)
functions[helper] = helpers[helper]

@classmethod
def null_function(cls, *args, **kw):
''' This function is returned if no helper is found. The idea is
to try to allow templates to be rendered even if helpers are
missing. Returning the empty string seems to work well.'''
return ''

def __getattr__(self, name):
''' return the function/object requested '''
if name in self.functions:
return self.functions[name]
else:
log = logging.getLogger('ckan.helpers')
log.critical('Helper function `%s` could not be found (missing extension?)' % name)
return self.null_function


def load_environment(global_conf, app_conf):
Expand Down Expand Up @@ -65,12 +102,9 @@ def find_controller(self, controller):
config.init_app(global_conf, app_conf, package='ckan', paths=paths)

# load all CKAN plugins
plugins.load_all(config)

from ckan.plugins import PluginImplementations
from ckan.plugins.interfaces import IConfigurer
p.load_all(config)

for plugin in PluginImplementations(IConfigurer):
for plugin in p.PluginImplementations(p.IConfigurer):
# must do update in place as this does not work:
# config = plugin.update_config(config)
plugin.update_config(config)
Expand All @@ -90,19 +124,19 @@ def find_controller(self, controller):
config['ckan.site_id'] = ckan_host

# Init SOLR settings and check if the schema is compatible
from ckan.lib.search import SolrSettings, check_solr_schema_version
SolrSettings.init(config.get('solr_url'),
config.get('solr_user'),
config.get('solr_password'))
check_solr_schema_version()
#from ckan.lib.search import SolrSettings, check_solr_schema_version
search.SolrSettings.init(config.get('solr_url'),
config.get('solr_user'),
config.get('solr_password'))
search.check_solr_schema_version()

config['routes.map'] = make_map()
config['routes.map'] = routing.make_map()
config['pylons.app_globals'] = app_globals.Globals()
if asbool(config.get('ckan.restrict_template_vars', 'false')):
import ckan.lib.helpers_clean
config['pylons.h'] = ckan.lib.helpers_clean
else:
config['pylons.h'] = h

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

## redo template setup to use genshi.search_path (so remove std template setup)
template_paths = [paths['templates'][0]]
Expand Down Expand Up @@ -144,9 +178,6 @@ def template_loaded(template):
if not model.meta.engine:
model.init_model(engine)

from ckan.plugins import PluginImplementations
from ckan.plugins.interfaces import IConfigurable

for plugin in PluginImplementations(IConfigurable):
for plugin in p.PluginImplementations(p.IConfigurable):
plugin.configure(config)

8 changes: 8 additions & 0 deletions ckan/config/routing.py
Expand Up @@ -239,6 +239,7 @@ def make_map():
m.connect('/user/reset/{id:.*}', action='perform_reset')
m.connect('/user/register', action='register')
m.connect('/user/login', action='login')
m.connect('/user/_logout', action='logout')
m.connect('/user/logged_in', action='logged_in')
m.connect('/user/logged_out', action='logged_out')
m.connect('/user/logged_out_redirect', action='logged_out_page')
Expand All @@ -255,6 +256,13 @@ def make_map():
m.connect('/revision/list', action='list')
m.connect('/revision/{id}', action='read')

# feeds
with SubMapper(map, controller='feed') as m:
m.connect('/feeds/group/{id}.atom', action='group')
m.connect('/feeds/tag/{id}.atom', action='tag')
m.connect('/feeds/dataset.atom', action='general')
m.connect('/feeds/custom.atom', action='custom')

map.connect('ckanadmin_index', '/ckan-admin', controller='admin', action='index')
map.connect('ckanadmin', '/ckan-admin/{action}', controller='admin')

Expand Down

0 comments on commit 8dfa64e

Please sign in to comment.