Ignore:
Timestamp:
16/02/09 17:11:08 (11 years ago)
Author:
cbyrom
Message:

Add a new feed for collecting corrections info submitted by users of
the atom editor + create new method on client to do this + add new
tests and tidy up some code.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • ndgCommon/trunk/ndg/common/src/clients/xmldb/eXist/feedclient.py

    r4976 r4983  
    2020        Exception.__init__(self, msg) 
    2121 
    22 class FeedClient: 
     22class FeedClient(object): 
    2323     
    2424    TOPLEVEL_ATOM_FEED_TITLE = 'Moles Atom Data' 
     
    2929    PROVIDERLEVEL_ATOM_FEED_TITLE = TOPLEVEL_ATOM_FEED_TITLE + PROVIDER_SUFFIX 
    3030    PROVIDERLEVEL_DIF_FEED_TITLE = TOPLEVEL_DIF_FEED_TITLE + PROVIDER_SUFFIX 
     31    CORRECTIONS_FEED_TITLE = 'Corrections data submitted by atom editor users' 
    3132    DIF_ENTRY_TITLE = 'DIF Record' 
    3233     
     
    111112        self.createAtomFeed(dc.DIF_COLLECTION_PATH, 
    112113                            self.TOPLEVEL_DIF_FEED_TITLE) 
     114 
     115        self.createAtomFeed(dc.CORRECTIONS_COLLECTION_PATH, 
     116                            self.CORRECTIONS_FEED_TITLE) 
    113117 
    114118 
     
    191195        self.__postEditAtomFeed(collection, entryXML) 
    192196        logging.info("Successfully added new feed entry") 
    193  
    194  
    195     def getRESTfulData(self, docPath, suppressPrefix = False): 
    196         ''' 
    197         Retrieve data using the REST interface 
    198         @param docPath: path to the data to retrieve - NB, this should equal 
    199         the DB path to the document in question 
    200         @keyword suppressPrefix: if True, the base, REST url, is not added to  
    201         the specified docPath  
    202         @return document, if found, None, otherwise 
    203         ''' 
    204         logging.info("Retrieving document at, %s, using RESTful interface" %docPath) 
    205         connection = httplib.HTTPConnection(self.hostAndPort) 
    206         url = docPath 
    207         if not suppressPrefix: 
    208             url = self.REST_BASE_URL + docPath 
    209  
    210         connection.request("GET", '%s' %(url)) 
    211         response = connection.getresponse() 
    212          
    213         if response.status == 200: 
    214             logging.info("Document successfully retrieved - returning this now") 
    215             return response.read() 
    216          
    217         logging.info("- no document found at path, '%s'" %docPath) 
    218         return None 
    219          
     197         
     198 
     199    def createCorrectionsFeedEntry(self, title, summary): 
     200        ''' 
     201        Add an entry to the corrections collection (which should already have a 
     202        feed set up on it) - with details of the corrections data submitted by 
     203        users of the atom editor 
     204        @param title: title to give the feed entry 
     205        @param body: content to add to the summary element 
     206        ''' 
     207        entryXML = '<?xml version="1.0" ?>\ 
     208<entry xmlns="http://www.w3.org/2005/Atom">\ 
     209<title>%s</title>\ 
     210<content>%s</content>\ 
     211</entry>' %(title, summary) 
     212        logging.info("Adding corrections data to atom feed") 
     213        self.__postEditAtomFeed(dc.CORRECTIONS_COLLECTION_PATH, entryXML) 
     214        logging.info("Successfully added new feed entry") 
Note: See TracChangeset for help on using the changeset viewer.