Changeset 4914


Ignore:
Timestamp:
10/02/09 14:07:21 (11 years ago)
Author:
spascoe
Message:

Made a global CSMLConnector instance with a list function. Configuring the CSML backend has moved to util.py. Calling this module will now be the responsibility of the Pylons app.

Location:
cows/trunk/cows
Files:
2 edited
1 moved

Legend:

Unmodified
Added
Removed
  • cows/trunk/cows/pylons/ows_controller.py

    r4912 r4914  
    2727from cows.qs_util import parse_qsl 
    2828from cows.model import * 
    29 from cows.pylons.util import configCSML 
    3029 
    3130from genshi.template import TemplateLoader 
     
    4847# Configure 
    4948EXCEPTION_TYPE = config.get('cows.exception_type', 'ogc') 
    50 configCSML() 
    5149 
    5250class OWSControllerBase(WSGIController): 
  • cows/trunk/cows/service/imps/csmlbackend/csmlcommon.py

    r4912 r4914  
    6868    def __init__(self): 
    6969        self.layermapcache={} 
    70         self.connector=CSMLConnector() 
     70        self.connector = globalCSMLConnector 
    7171     
    7272    #!TODO: Should be _getInfo() as proposed in wms_csmllayer.  Should move to wfs_csmllayer as 
     
    8787        return title, abstract 
    8888 
    89 #!TODO: What's the point of this class?  It's just a container for a function. 
    9089class CSMLConnector(object): 
    9190    """ Contains common methods for CSML backend used across all WXS services """     
    9291     
    9392    def __init__(self): 
    94         pass 
     93        self.csml_dir = config.get('csmlstore') 
    9594     
    9695    def getCsmlDoc(self, fileoruri): 
    9796        """ 
    98         Gets a csml document from file or exist when passed a file name or uri          
    99                 
    100         Note, access control is not implemented on file access, only on exist access. 
     97        Gets a csml document from file or exist when passed a file name or uri 
     98 
     99        Note, access control is not implemented on file access, only on exist 
     100        access. 
    101101         
    102102        """ 
     
    104104            #it's a local file not an identifier, read from local csmlstore 
    105105            file=fileoruri 
    106             csml_dir = config['csmlstore'] 
    107             path = os.path.join(csml_dir, file) 
     106            path = os.path.join(self.csml_dir, file) 
    108107            if os.path.exists(path+'.csml'): 
    109108                f = path+'.csml' 
     
    128127        return d 
    129128     
     129    def list(self): 
     130        """ 
     131        Generator that lists available CSML documents. 
     132 
     133        @note: not implemented for eXist.  I'm not sure if this is possible 
     134            or desireable. 
     135 
     136        """ 
     137        if self.csml_dir is None: 
     138            log.warning('Trying to list CSMLConnector with no filestore.  ' 
     139                        'Maybe using eXist?') 
     140            return 
     141         
     142        for dirpath, dirnames, filenames in os.walk(self.csml_dir): 
     143            for filename in filenames: 
     144                file_id, ext = os.path.splitext(filename) 
     145                if ext in ('.xml', '.csml'): 
     146                    # Remove common path bit 
     147                    relpath = dirpath[len(self.csml_dir):] 
     148                    yield os.path.join(relpath, file_id) 
     149 
     150# 
     151# Global CSML connector instance 
     152# 
     153globalCSMLConnector = CSMLConnector() 
Note: See TracChangeset for help on using the changeset viewer.