Skip to content

Commit

Permalink
[1.7] remove celery as dependancy
Browse files Browse the repository at this point in the history
This is a cherry-pick of c7cfe88.
Including celery as a dependency breaks the package install.
  • Loading branch information
Ian Murray committed May 10, 2012
1 parent 2c745cd commit e64ca16
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 10 deletions.
5 changes: 5 additions & 0 deletions ckan/logic/action/get.py
Expand Up @@ -484,6 +484,11 @@ def resource_show(context, data_dict):

def resource_status_show(context, data_dict):

try:
import ckan.lib.celery_app as celery_app
except ImportError:
return {'message': 'queue is not installed on this instance'}

model = context['model']
id = get_or_bust(data_dict, 'id')

Expand Down
18 changes: 10 additions & 8 deletions ckan/model/__init__.py
Expand Up @@ -83,14 +83,16 @@ def init_db(self):
self.upgrade_db()
## make sure celery tables are made as celery only makes them after
## adding a task
import ckan.lib.celery_app as celery_app
import celery.db.session as celery_session

##This creates the database tables it is a slight hack to celery.
backend = celery_app.celery.backend
celery_result_session = backend.ResultSession()
engine = celery_result_session.bind
celery_session.ResultModelBase.metadata.create_all(engine)
try:
import ckan.lib.celery_app as celery_app
import celery.db.session as celery_session
##This creates the database tables it is a slight hack to celery.
backend = celery_app.celery.backend
celery_result_session = backend.ResultSession()
engine = celery_result_session.bind
celery_session.ResultModelBase.metadata.create_all(engine)
except ImportError:
pass

self.init_configuration_data()
self.tables_created_and_initialised = True
Expand Down
7 changes: 6 additions & 1 deletion ckan/tests/logic/test_action.py
Expand Up @@ -2,6 +2,7 @@
import json
from pprint import pprint
from nose.tools import assert_equal, assert_raises
from nose.plugins.skip import SkipTest
from pylons import config

import ckan
Expand Down Expand Up @@ -1014,7 +1015,11 @@ def test_38_user_role_bulk_update(self):

def test_40_task_resource_status(self):

import ckan.lib.celery_app as celery_app
try:
import ckan.lib.celery_app as celery_app
except ImportError:
raise SkipTest('celery not installed')

backend = celery_app.celery.backend
##This creates the database tables as a side effect, can not see another way
##to make tables unless you actually create a task.
Expand Down
1 change: 0 additions & 1 deletion requires/lucid_missing.txt
Expand Up @@ -20,4 +20,3 @@ ofs==0.4.1
apachemiddleware==0.1.1
# markupsafe is required by webhelpers==1.2 required by formalchemy with SQLAlchemy 0.6
markupsafe==0.9.2
celery==2.5.3

0 comments on commit e64ca16

Please sign in to comment.