source: TI05-delivery/ows_framework/trunk/ows_server/ows_server/controllers/trackback.py @ 2646

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/TI05-delivery/ows_framework/trunk/ows_server/ows_server/controllers/trackback.py@2646
Revision 2646, 1.8 KB checked in by lawrence, 13 years ago (diff)

Interim check in for citation trackback support and
metadata correction from logged in ndg users.

Line 
1from ows_server.lib.base import *
2from ows_server.lib.mailer import mailHandler
3class TrackbackController(BaseController):
4    ''' Provides the pylons controller for recieving trackbacks to NDG documents '''
5    def index(self,uri):
6        ''' This is the default trackback receipt method. Note we haven't implemented
7        whitelisting yet '''
8       
9        err=0
10       
11        # need to receive a trackback, and mail someone ...
12       
13        incoming=request.environ['querystring']
14        keys=incoming.keys()
15        payload='<trackback><uri>%s</uri>'
16       
17        #make sure we have both url and title
18        if 'url' not in keys and 'title' not in keys:
19            err='Incomplete trackback, need both url and title at the every least'
20        for key in keys:
21            payload.append('<%s>%s</%s>'%(key,incoming[key],key))
22       
23        #now get server and trackback recipient.
24        self.cf=request.environ['ndgConfig']
25       
26        server=self.cf.get('DEFAULT','mailserver',None)
27        if server is None:
28            err='Server not configured for trackback (no mail server)'
29       
30        recipient=self.cf.get('DEFAULT','tbrecipient',None)
31        if recipient is None:
32            err='Server not configured for trackback (no recipient)'
33       
34        body='Citation Trackback for %s'%uri
35        name='CitationTrackbackFor_%s.xml'uri
36       
37       
38           
39        if err!=0:
40            c.message=err
41            c.err=1
42        else: 
43            status,message=mailHandler([recipient,],body,body,xmlAttachments=[(payload,name),],
44                server=server)
45            if status:
46                c.err=0
47            else:
48                c.err=1
49                c.message=message
50       
51        return render_response(trackback)
Note: See TracBrowser for help on using the repository browser.