def bcawIndexAsynchronously():
    """ This is the Celery worker task which is run in parallel with the
        bcaw app. When user chooses to generate Lucene indexes for the disk
        images, the mail app (bcaw) calls this worker thread which in turn,
        invokes the indexing routine.
        This task is invoked by the following command:
        $ celery -A bcaw_celery_task.celery  worker --loglevel=INFO
    """

    """ Background task to index the files """
    with app.app_context():
        # print "Calling bcawIndexAllFiles..."
        # print "Current app: ", current_app.name
        bcaw.image_browse.bcawIndexAllFiles()
def bcawIndexAsynchronously(self):
    """ The Celery worker task. Run in parallel with the bcaw app. When Lucene 
        indexes for disk images are generated, the main app (bcaw) calls this 
        worker thread which in turn, invokes the indexing routine.
        Invoked by the following command:
        $ celery -A bcaw_celery_task.celery  worker --loglevel=INFO
    """

    """ Background task to index the files """
    # print "[D]: Task_id: ", self.request.id
    with app.app_context():
        # print "Calling bcawIndexAllFiles..."
        # print "Current app: ", current_app.name
        bcaw.image_browse.bcawIndexAllFiles(self.request.id)
def bcawBuildAllTablesAsynchronously():
    """ Background task to build image and dfxml table """
    with app.app_context():
        # print "Calling dbBuildDb for DFXML..."
        # print "Current app: ", current_app.name
        bcaw.bcaw_db.dbBuildDb(bld_imgdb=True, bld_dfxmldb=True)
def bcawBuildDfxmlTableAsynchronously(self):
    """ Background task to build dfxml table """
    with app.app_context():
        # print "Calling dbBuildDb for DFXML..."
        # print "Current app: ", current_app.name
        bcaw.bcaw_db.dbBuildDb(self.request.id, bld_imgdb = False, bld_dfxmldb = True)