[ckan-changes] [okfn/ckan] ed5329: [2316] make sure celery tables are made

GitHub noreply at github.com
Tue Apr 24 16:35:56 UTC 2012


  Branch: refs/heads/master
  Home:   https://github.com/okfn/ckan
  Commit: ed5329e5db2e3efae78ee92e96a9a7d139fa9048
      https://github.com/okfn/ckan/commit/ed5329e5db2e3efae78ee92e96a9a7d139fa9048
  Author: kindly <kindly at gmail.com>
  Date:   2012-04-24 (Tue, 24 Apr 2012)

  Changed paths:
    M ckan/model/__init__.py

  Log Message:
  -----------
  [2316] make sure celery tables are made


diff --git a/ckan/model/__init__.py b/ckan/model/__init__.py
index f254318..4c3731e 100644
--- a/ckan/model/__init__.py
+++ b/ckan/model/__init__.py
@@ -81,14 +81,15 @@ def init_db(self):
                 self.upgrade_db()
                 ## make sure celery tables are made as celery only makes them after
                 ## adding a task
-                try:
-                    import ckan.lib.celery_app as celery_app
-                    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.
-                    celery_result_session = backend.ResultSession()
-                except ImportError:
-                    pass
+                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)
+
                 self.init_configuration_data()
                 self.tables_created_and_initialised = True
 


================================================================



More information about the ckan-changes mailing list