Changeset 4758


Ignore:
Timestamp:
06/01/09 16:30:22 (11 years ago)
Author:
cbyrom
Message:

Create new class, eXistDBFeedClient, to allow use of the eXist atom
feed interface - to set up feeds, add entries and retrieve content.
Add code to the normal existDBClient to set up basic feed and to
add references to any new/updated atom to this feed. NB, feed uses
the RESTful interface to the eXist DB - and methods to access this are
also included in the new client.
Add new testcases to exercise the new code.

Location:
exist/trunk/python
Files:
2 added
1 edited

Legend:

Unmodified
Added
Removed
  • exist/trunk/python/ndgUtils/lib/existdbclient.py

    r4720 r4758  
    1010from ndgUtils.ndgXqueries import ndgXqueries 
    1111from ndgUtils import DocumentRetrieve as DR 
     12from existdbfeedclient import eXistDBFeedClient as feedClient 
    1213 
    1314try: 
     
    5051     
    5152    def __init__(self, configFile = None, eXistDBHostname = None, \ 
     53                 eXistPortNo = '8080', \ 
    5254                 loadCollectionData=False, setUpDB = False): 
    5355        ''' 
     
    5658        @keyword existDBHostname: name of eXist DB to use - if not specified, the first 
    5759        host in the config file is used 
     60        @keyword eXistPortNo: Port number that the eXist DB is exposed by - defaults 
     61        to '8080' if not set  
    5862        @keyword loadCollectionData: preload info on all the eXist collections, if True (default False) 
    5963        @keyword setUpDB: if True, create the basic collection structure and ingest the 
     
    6266        logging.info("Initialising connection to eXist DB") 
    6367        self.eXistDBHostname = eXistDBHostname 
    64         logging.debug("- connecting to DB, '%s', with config file, '%s'" \ 
    65                       %(eXistDBHostname or 'Default', configFile or 'Default')) 
     68        self.eXistPortNo = eXistPortNo 
     69        logging.debug("- connecting to DB, '%s:%s', with config file, '%s'" \ 
     70                      %(eXistDBHostname or 'Default', self.eXistPortNo, \ 
     71                        configFile or 'Default')) 
     72         
    6673        inputs = {} 
    6774         
     
    8390        logging.debug(inputs) 
    8491        self.xmldb = DR(self.eXistDBHostname, **inputs) 
     92 
     93        # set up feed client, too - NB, info should be added to the feed as it is added 
     94        # to the eXist collections, so the standard dbclient and the feed client 
     95        # are intrinsicly linked 
     96        self.feedClient = feedClient(self.xmldb.auth,  
     97                                     eXistDBHostname = self.eXistDBHostname,  
     98                                     eXistPortNo = self.eXistPortNo) 
    8599         
    86100        if setUpDB: 
     
    90104            # add the schema required for atom validation 
    91105            self.__addAtomSchema() 
     106             
     107            # set up the required atom feeds 
     108            self.feedClient.createAtomFeed(ec.BASE_COLLECTION_PATH,  
     109                                           self.feedClient.ATOM_FEED_TITLE) 
    92110         
    93111        self.collections = None 
     
    120138            self.xmldb.createCollection(col) 
    121139        logging.info("All collections set up") 
    122  
     140         
    123141 
    124142    def getAtom(self, id): 
     
    146164        this indicates successful validation 
    147165        ''' 
    148         logging.info("Validating atom, '%s' against schemae in eXist" %atomPath) 
     166        logging.info("Validating atom, '%s' against schemata in eXist" %atomPath) 
    149167        try: 
    150168            if atom: 
     
    580598             
    581599        self.createEXistFile(atom.toPrettyXML(), eXistCollection, atom.atomName) 
     600         
    582601        logging.info("Atom created in eXist") 
     602         
     603        # lastly, update the feed to include an entry pointing to the atom 
     604        self.feedClient.createAtomFeedEntry(ec.BASE_COLLECTION_PATH, atom) 
    583605        return atom 
    584606     
Note: See TracChangeset for help on using the changeset viewer.