Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ee0c50f

Browse files
author
David Read
authored
Merge branch 'master' into 4061-recapture-v1-ending
2 parents 8d96301 + c5c9250 commit ee0c50f

38 files changed

Lines changed: 6385 additions & 2755 deletions

File tree

CHANGELOG.rst

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,11 @@ Note: This version requires re-running the 'datastore set-permissions' command
2121
CKAN developers should also re-run set-permissions on the test database:
2222
:ref:`datastore-test-set-permissions`
2323

24-
Minor changes:
25-
* `ckan.recaptcha.version` config option removed, since v2 is the only valid
24+
Changes and deprecations:
25+
* The old Celery based background jobs have been removed in CKAN 2.8 in favour of the new RQ based
26+
jobs (http://docs.ckan.org/en/latest/maintaining/background-tasks.html). Extensions can still
27+
of course use Celery but they will need to handle the management themselves.
28+
* `ckan.recaptcha.version` config option is removed, since v2 is the only valid
2629
version now (#4061)
2730

2831
v2.7.2 2017-09-28

ckan/config/celery-supervisor.conf

Lines changed: 0 additions & 31 deletions
This file was deleted.

ckan/lib/celery_app.py

Lines changed: 0 additions & 77 deletions
This file was deleted.

ckan/lib/cli.py

Lines changed: 0 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -1039,88 +1039,6 @@ def purge(self, dataset_ref):
10391039
print('%s purged' % name)
10401040

10411041

1042-
class Celery(CkanCommand):
1043-
'''Celery daemon [DEPRECATED]
1044-
1045-
This command is DEPRECATED, use `paster jobs` instead.
1046-
1047-
Usage:
1048-
celeryd <run> - run the celery daemon
1049-
celeryd run concurrency - run the celery daemon with
1050-
argument 'concurrency'
1051-
celeryd view - view all tasks in the queue
1052-
celeryd clean - delete all tasks in the queue
1053-
'''
1054-
min_args = 0
1055-
max_args = 2
1056-
summary = __doc__.split('\n')[0]
1057-
usage = __doc__
1058-
1059-
def command(self):
1060-
if not self.args:
1061-
self.run_()
1062-
else:
1063-
cmd = self.args[0]
1064-
if cmd == 'run':
1065-
self.run_()
1066-
elif cmd == 'view':
1067-
self.view()
1068-
elif cmd == 'clean':
1069-
self.clean()
1070-
else:
1071-
error('Command %s not recognized' % cmd)
1072-
1073-
def run_(self):
1074-
deprecation_warning(u'Use `paster jobs worker` instead.')
1075-
default_ini = os.path.join(os.getcwd(), 'development.ini')
1076-
1077-
if self.options.config:
1078-
os.environ['CKAN_CONFIG'] = os.path.abspath(self.options.config)
1079-
elif os.path.isfile(default_ini):
1080-
os.environ['CKAN_CONFIG'] = default_ini
1081-
else:
1082-
error('No .ini specified and none was found in current directory')
1083-
1084-
from ckan.lib.celery_app import celery
1085-
celery_args = []
1086-
if len(self.args) == 2 and self.args[1] == 'concurrency':
1087-
celery_args.append('--concurrency=1')
1088-
celery.worker_main(argv=['celeryd', '--loglevel=INFO'] + celery_args)
1089-
1090-
def view(self):
1091-
deprecation_warning(u'Use `paster jobs list` instead.')
1092-
self._load_config()
1093-
import ckan.model as model
1094-
from kombu.transport.sqlalchemy.models import Message
1095-
q = model.Session.query(Message)
1096-
q_visible = q.filter_by(visible=True)
1097-
print('%i messages (total)' % q.count())
1098-
print('%i visible messages' % q_visible.count())
1099-
for message in q:
1100-
if message.visible:
1101-
print('%i: Visible' % (message.id))
1102-
else:
1103-
print('%i: Invisible Sent:%s' % (message.id, message.sent_at))
1104-
1105-
def clean(self):
1106-
deprecation_warning(u'Use `paster jobs clear` instead.')
1107-
self._load_config()
1108-
import ckan.model as model
1109-
query = model.Session.execute("select * from kombu_message")
1110-
tasks_initially = query.rowcount
1111-
if not tasks_initially:
1112-
print('No tasks to delete')
1113-
sys.exit(0)
1114-
query = model.Session.execute("delete from kombu_message")
1115-
query = model.Session.execute("select * from kombu_message")
1116-
tasks_afterwards = query.rowcount
1117-
print('%i of %i tasks deleted' % (tasks_initially - tasks_afterwards,
1118-
tasks_initially))
1119-
if tasks_afterwards:
1120-
error('Failed to delete all tasks')
1121-
model.repo.commit_and_remove()
1122-
1123-
11241042
class Ratings(CkanCommand):
11251043
'''Manage the ratings stored in the db
11261044

ckan/lib/search/query.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,12 @@ def get_index(self,reference):
266266
'wt': 'json',
267267
'fq': 'site_id:"%s"' % config.get('ckan.site_id')}
268268

269+
try:
270+
if query['q'].startswith('{!'):
271+
raise SearchError('Local parameters are not supported.')
272+
except KeyError:
273+
pass
274+
269275
conn = make_connection(decode_dates=False)
270276
log.debug('Package query: %r' % query)
271277
try:
@@ -354,6 +360,12 @@ def run(self, query, permission_labels=None, **kwargs):
354360
query['mm'] = query.get('mm', '2<-1 5<80%')
355361
query['qf'] = query.get('qf', QUERY_FIELDS)
356362

363+
try:
364+
if query['q'].startswith('{!'):
365+
raise SearchError('Local parameters are not supported.')
366+
except KeyError:
367+
pass
368+
357369
conn = make_connection(decode_dates=False)
358370
log.debug('Package query: %r' % query)
359371
try:

ckan/logic/action/get.py

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1147,46 +1147,6 @@ def resource_view_list(context, data_dict):
11471147
return model_dictize.resource_view_list_dictize(resource_views, context)
11481148

11491149

1150-
def resource_status_show(context, data_dict):
1151-
'''Return the statuses of a resource's tasks.
1152-
1153-
This function is DEPRECATED.
1154-
1155-
:param id: the id of the resource
1156-
:type id: string
1157-
1158-
:rtype: list of (status, date_done, traceback, task_status) dictionaries
1159-
1160-
'''
1161-
1162-
_check_access('resource_status_show', context, data_dict)
1163-
1164-
try:
1165-
import ckan.lib.celery_app as celery_app
1166-
except ImportError:
1167-
return {'message': 'queue is not installed on this instance'}
1168-
1169-
model = context['model']
1170-
id = _get_or_bust(data_dict, 'id')
1171-
1172-
# needs to be text query as celery tables are not in our model
1173-
q = _text("""
1174-
select status, date_done, traceback, task_status.*
1175-
from task_status left join celery_taskmeta
1176-
on task_status.value = celery_taskmeta.task_id
1177-
and key = 'celery_task_id'
1178-
where entity_id = :entity_id
1179-
""")
1180-
try:
1181-
result = model.Session.connection().execute(q, entity_id=id)
1182-
except sqlalchemy.exc.ProgrammingError:
1183-
# celery tables (celery_taskmeta) may not be created even with celery
1184-
# installed, causing ProgrammingError exception.
1185-
return {'message': 'queue tables not installed on this instance'}
1186-
result_list = [_table_dictize(row, context) for row in result]
1187-
return result_list
1188-
1189-
11901150
@logic.auth_audit_exempt
11911151
def revision_show(context, data_dict):
11921152
'''Return the details of a revision.

ckan/logic/auth/get.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -211,10 +211,8 @@ def user_autocomplete(context, data_dict):
211211
def format_autocomplete(context, data_dict):
212212
return {'success': True}
213213

214-
def task_status_show(context, data_dict):
215-
return {'success': True}
216214

217-
def resource_status_show(context, data_dict):
215+
def task_status_show(context, data_dict):
218216
return {'success': True}
219217

220218

ckan/model/__init__.py

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -186,25 +186,6 @@ def init_db(self):
186186
else:
187187
if not self.tables_created_and_initialised:
188188
self.upgrade_db()
189-
## make sure celery tables are made as celery only makes
190-
## them after adding a task
191-
try:
192-
import ckan.lib.celery_app as celery_app
193-
import celery.db.session as celery_session
194-
import celery.backends.database
195-
## This creates the database tables (if using that backend)
196-
## It is a slight hack to celery
197-
backend = celery_app.celery.backend
198-
if isinstance(backend,
199-
celery.backends.database.DatabaseBackend):
200-
celery_result_session = backend.ResultSession()
201-
engine = celery_result_session.bind
202-
celery_session.ResultModelBase.metadata.\
203-
create_all(engine)
204-
except ImportError:
205-
# use of celery is optional
206-
pass
207-
208189
self.tables_created_and_initialised = True
209190
log.info('Database initialised')
210191

0 commit comments

Comments
 (0)