Ignore:
Timestamp:
25/06/07 17:07:54 (13 years ago)
Author:
lawrence
Message:

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • TI05-delivery/ows_framework/trunk/ows_server/ows_server/controllers/trackback.py

    r2643 r2646  
    11from ows_server.lib.base import * 
     2from ows_server.lib.mailer import mailHandler 
    23class TrackbackController(BaseController): 
    34    ''' Provides the pylons controller for recieving trackbacks to NDG documents ''' 
    4     def index(self): 
     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         
    511        # need to receive a trackback, and mail someone ... 
    6         return Response('not yet implemented') 
     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 TracChangeset for help on using the changeset viewer.