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

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

Add to code to allow the OAI editor to be used with the new openid
based security system. Add the policy file and secured ini file +
adjust handling of users - enforcing page access via URL content

  • basically either by provider ID or via 'admin=1' parameter for

admin users. For the latter, provider security_redirector module to
allow admin users to use same point of entry as normal users.

  • 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
46        session[const.POP_UP_MESSAGE_SESSION_KEY] = outMessage
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.