source: TI01-discovery/trunk/OAIInfoEditor/oai_info_editor/controllers/harvest.py @ 5470

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/TI01-discovery/trunk/OAIInfoEditor/oai_info_editor/controllers/harvest.py@5470
Revision 5470, 2.2 KB checked in by cbyrom, 10 years ago (diff)

Update documentation, adding a section on how to set up the security
+ tidy up the codebase, moving configuration files to the top level
and deleting any app specific data + fix a few links to properly
include the admin parameter + fix an issue with the admin redirection.

  • Property svn:executable set to *
Line 
1'''
2 Class representing pylons controller for the harvesting of provider info
3 
4 @author: C Byrom, Tessella Apr 2009
5'''
6import logging, urllib
7from oai_info_editor.lib.base import *
8from oai_info_editor.controllers.master import MasterController
9import oai_info_editor.lib.constants as const
10
11class HarvestController(MasterController):
12
13    def harvestProviderInfo(self, repositoryName, providerName):
14        '''
15        Harvest the repository info associated with the input name and provider
16        @param repositoryName: name of repository whose info should be displayed
17        @param providerName: name of provider whose info should be displayed
18        '''
19        repositoryName = urllib.unquote(repositoryName)
20        providerName = urllib.unquote(providerName)
21        self._setUpController(providerName = providerName)
22        logging.info("Setting up page to display info for provider, '%s'" %providerName)
23
24        pi = g.dao.getProviderInfo(providerName)
25        ri = g.dao.getRepositoryInfo(providerName, repositoryName)
26        if not ri:
27            raise ValueError("Could not find repository, '%s' for provider, '%s'" \
28                             %(repositoryName, providerName))
29
30        try:
31            status, result = g.harvester.runHarvestAndIngest(providerName, ri,
32                                                             ingestAsynch = True,
33                                                             userEmail = pi.email)
34        except Exception, e:
35            c.errors = {'System error': e}
36            return render('genshi', 'error')
37
38        outMessage = "Repository data, %s, for provider with name, %s, successfully harvested. (Details: %s)" \
39            %(repositoryName, providerName, result)
40        if not status:
41            outMessage = "A problem occurred whilst harvesting the data - please retry later."
42            c.errors = {'Harvest/ingest error': result}
43            return render('genshi', 'error')
44
45        # now return to the home page - and display pop up (nb, remove apostrophes or the pop up won't display)
46        session[const.POP_UP_MESSAGE_SESSION_KEY] = outMessage.replace('\'', '')
47        session.save()
48
49        # now, return to the view page
50        h.redirect_to('home')
Note: See TracBrowser for help on using the repository browser.