Skip to content

Commit

Permalink
Merge branch 'master' into 262-improve-helper-imports
Browse files Browse the repository at this point in the history
Conflicts:
	ckan/lib/search/query.py

    import fixes
  • Loading branch information
tobes committed Mar 12, 2013
2 parents eaff7b9 + c8d788f commit 2ee72da
Show file tree
Hide file tree
Showing 234 changed files with 2,035 additions and 2,848 deletions.
32 changes: 7 additions & 25 deletions .travis.yml
Expand Up @@ -2,33 +2,15 @@ language: python
python:
- "2.6"
- "2.7"
before_install:
- sudo apt-get update -qq
- sudo apt-get install -qq solr-jetty
install:
- "pip install -r pip-requirements.txt --use-mirrors"
- "pip install -r pip-requirements-test.txt --use-mirrors"
before_script:
- psql -c 'CREATE DATABASE ckantest;' -U postgres
- psql -c 'CREATE DATABASE datastore;' -U postgres
- psql -c 'CREATE USER readonlyuser;' -U postgres
- python setup.py develop
- paster make-config ckan development.ini --no-interactive
- sed -i -e 's/.*solr_url.*/solr_url = http:\/\/127.0.0.1:8983\/solr/' development.ini
- sed -i -e 's/.*ckan\.site_id.*/ckan.site_id = travis_ci/' development.ini
- sed -i -e 's/^sqlalchemy.url.*/sqlalchemy.url = postgresql:\/\/postgres@localhost\/ckantest/' development.ini
- sed -i -e 's/.*datastore.write_url.*/ckan.datastore.write_url = postgresql:\/\/postgres@localhost\/datastore/' development.ini
- sed -i -e 's/.*datastore.read_url.*/ckan.datastore.read_url = postgresql:\/\/readonlyuser@localhost\/datastore/' development.ini
- cat development.ini
- echo -e "NO_START=0\nJETTY_HOST=127.0.0.1\nJETTY_PORT=8983\nJAVA_HOME=$JAVA_HOME" | sudo tee /etc/default/jetty
- sudo cp ckan/config/solr/schema-2.0.xml /etc/solr/conf/schema.xml
- sudo service jetty restart
- paster --plugin=ckan db init
- paster datastore set-permissions postgres
script: "nosetests --ckan --with-pylons=test-core.ini --nologcapture ckan ckanext"
env:
- PGVERSION=9.1
- PGVERSION=8.4
script: ./bin/travis-build
notifications:
irc:
channels:
- "irc.freenode.org#ckan"
on_success: never
on_failure: change
template:
- "%{repository} (%{branch} - %{commit}) [%{build_url}] %{author}: %{message}"
- "%{repository} %{branch} %{commit} %{build_url} %{author}: %{message}"
55 changes: 55 additions & 0 deletions bin/travis-build
@@ -0,0 +1,55 @@
#!/bin/sh

# Drop Travis' postgres cluster if we're building using a different pg version
TRAVIS_PGVERSION='9.1'
if [ $PGVERSION != $TRAVIS_PGVERSION ]
then
sudo -u postgres pg_dropcluster --stop $TRAVIS_PGVERSION main
# Make psql use $PGVERSION
export PGCLUSTER=$PGVERSION/main
fi

# Install postgres and solr
# We need this ppa so we can install postgres-8.4
sudo add-apt-repository -yy ppa:pitti/postgresql
sudo apt-get update -qq
sudo apt-get install solr-jetty postgresql-$PGVERSION

# Don't require a password to access DB
sudo sed -i -e 's/ident/trust/g' /etc/postgresql/$PGVERSION/main/pg_hba.conf

sudo service postgresql reload

pip install -r pip-requirements.txt --use-mirrors
pip install -r pip-requirements-test.txt --use-mirrors

psql -c 'CREATE DATABASE ckantest;' -U postgres
psql -c 'CREATE DATABASE datastore;' -U postgres

python setup.py develop

# Configure CKAN's configuration file
paster make-config ckan development.ini --no-interactive
sed -i -e 's/.*solr_url.*/solr_url = http:\/\/127.0.0.1:8983\/solr/' development.ini
sed -i -e 's/.*ckan\.site_id.*/ckan.site_id = travis_ci/' development.ini
sed -i -e 's/^sqlalchemy.url.*/sqlalchemy.url = postgresql:\/\/postgres@\/ckantest/' development.ini
sed -i -e 's/.*datastore.write_url.*/ckan.datastore.write_url = postgresql:\/\/postgres@\/datastore/' development.ini

# Configure Solr
echo "NO_START=0\nJETTY_HOST=127.0.0.1\nJETTY_PORT=8983\nJAVA_HOME=$JAVA_HOME" | sudo tee /etc/default/jetty
sudo cp ckan/config/solr/schema-2.0.xml /etc/solr/conf/schema.xml
sudo service jetty restart

paster --plugin=ckan db init

# If Postgres >= 9.0, we don't need to use datastore's legacy mode.
if [ $PGVERSION != '8.4' ]
then
psql -c 'CREATE USER readonlyuser;' -U postgres
sed -i -e 's/.*datastore.read_url.*/ckan.datastore.read_url = postgresql:\/\/readonlyuser@\/datastore/' development.ini
paster datastore set-permissions postgres
fi


# And finally, run the tests
nosetests --ckan --with-pylons=test-core.ini --nologcapture ckan ckanext
26 changes: 19 additions & 7 deletions ckan/config/routing.py
Expand Up @@ -284,12 +284,15 @@ def make_map():
'follow',
'unfollow',
'admins',
'about',
'activity',
]))
)
m.connect('group_activity', '/group/activity/{id}/{offset}', action='activity'),
m.connect('group_read', '/group/{id}', action='read')
m.connect('group_about', '/group/about/{id}', action='about',
ckan_icon='info-sign'),
m.connect('group_activity', '/group/activity/{id}/{offset}',
action='activity', ckan_icon='time'),
m.connect('group_read', '/group/{id}', action='read',
ckan_icon='sitemap')

# organizations these basically end up being the same as groups
with SubMapper(map, controller='organization') as m:
Expand All @@ -298,17 +301,26 @@ def make_map():
m.connect('/organization/new', action='new')
m.connect('/organization/{action}/{id}',
requirements=dict(action='|'.join([
'edit',
'delete',
'admins',
'members',
'member_new',
'member_delete',
'history',
'about'
'history'
]))
)
m.connect('organization_activity', '/organization/activity/{id}',
action='activity', ckan_icon='time')
m.connect('organization_read', '/organization/{id}', action='read')
m.connect('organization_about', '/organization/about/{id}',
action='about', ckan_icon='info-sign')
m.connect('organization_read', '/organization/{id}', action='read',
ckan_icon='sitemap')
m.connect('organization_edit', '/organization/edit/{id}',
action='edit', ckan_icon='edit')
m.connect('organization_members', '/organization/members/{id}',
action='members', ckan_icon='group')
m.connect('organization_bulk_process', '/organization/bulk_process/{id}',
action='bulk_process', ckan_icon='sitemap')
register_package_plugins(map)
register_group_plugins(map)

Expand Down
7 changes: 5 additions & 2 deletions ckan/controllers/api.py
Expand Up @@ -832,8 +832,11 @@ def make_unicode(entity):
raise ValueError(msg)
cls.log.debug('Retrieved request body: %r' % request.body)
if not request_data:
msg = "No request body data"
raise ValueError(msg)
if not try_url_params:
msg = "No request body data"
raise ValueError(msg)
else:
request_data = {}
if request_data:
try:
request_data = h.json.loads(request_data, encoding='utf8')
Expand Down
11 changes: 8 additions & 3 deletions ckan/controllers/feed.py
Expand Up @@ -24,6 +24,7 @@

import webhelpers.feedgenerator
from pylons import config
from pylons.i18n import _
from urllib import urlencode

from ckan import model
Expand Down Expand Up @@ -172,7 +173,7 @@ def group(self, id):
'user': c.user or c.author}
group_dict = get_action('group_show')(context, {'id': id})
except NotFound:
abort(404, 'Group not found')
abort(404, _('Group not found'))

data_dict, params = self._parse_url_params()
data_dict['fq'] = 'groups:"%s"' % id
Expand Down Expand Up @@ -282,7 +283,9 @@ def custom(self):
try:
page = int(request.params.get('page', 1))
except ValueError:
abort(400, ('"page" parameter must be an integer'))
abort(400, _('"page" parameter must be a positive integer'))
if page < 0:
abort(400, _('"page" parameter must be a positive integer'))

limit = ITEMS_LIMIT
data_dict = {
Expand Down Expand Up @@ -434,7 +437,9 @@ def _parse_url_params(self):
try:
page = int(request.params.get('page', 1)) or 1
except ValueError:
abort(400, ('"page" parameter must be an integer'))
abort(400, _('"page" parameter must be a positive integer'))
if page < 0:
abort(400, _('"page" parameter must be a positive integer'))

limit = ITEMS_LIMIT
data_dict = {
Expand Down

0 comments on commit 2ee72da

Please sign in to comment.