Changeset 1905 for TI07-MOLES/trunk


Ignore:
Timestamp:
21/12/06 10:20:11 (13 years ago)
Author:
lawrence
Message:

Working discovery within paste-deploy context ...

Location:
TI07-MOLES/trunk/PythonCode/wsgi
Files:
18 added
5 edited
1 moved

Legend:

Unmodified
Added
Removed
  • TI07-MOLES/trunk/PythonCode/wsgi/00deploy.sh

    r1903 r1905  
    11paster serve ndg.ini 
     2# need to modifiy to have shell magic number, and get environmentand 
     3# add to python path 
  • TI07-MOLES/trunk/PythonCode/wsgi/Utilities.py

    r1903 r1905  
    5050   def getLog(self): 
    5151       return self.logger 
    52  
    53 class Request: 
    54     ''' Holds the request URL etc ''' 
    55     def __init__(self,env,cgi,wsgi=0): 
    56         ''' Instantiates attributes: 
    57             env: the environment 
    58             URL: a url to recreate the request SANS any security info and selection arguments 
    59             variables: any arguments to the request ... ''' 
    60         self.env=env 
    61         self.URL='http://%s:%s%s'%(env.get('SERVER_NAME'),env.get('SERVER_PORT'), 
    62                                    env.get('SCRIPT_NAME')) 
    63         self.baseURL=self.URL 
    64         try:     
    65              if wsgi: 
    66                  # in this case we've got it externally 
    67                  self.variables=getURLdict(cgi) 
    68              else: 
    69                  self.variables=getURLdict(cgi.FieldStorage()) 
    70         except Exception,e: 
    71             self.variables={'Error':'<p> Error in Request, parseing url [%s]</p>'%self.URL} 
    72             return 
    73         self.URL=self.__rebuildURL() 
    74  
    75     def __rebuildURL(self): 
    76         ''' builds  a url from the cgi variables that are loaded ''' 
    77         url=self.baseURL 
    78         try:  
    79             #reconstruct the url carefully, to avoid the selector and any 
    80             #ndg security info if present ... 
    81             tmp={} 
    82             reject=['select','NDG-ID1','NDG-ID2'] 
    83             for i in self.variables: 
    84                 if i not in reject: tmp[i]=self.variables[i] 
    85             if tmp!={}: url+='?%s'%urllib.urlencode(tmp) 
    86         except Exception,e: 
    87             #raise e 
    88             self.variables={'Error':'<p> Error rebuilding URL from [%s] </p>'%url} 
    89         return url 
    90              
    91     def modify(self,variables): 
    92         ''' Used to take a GET request url, and modify some of the variables and provide  
    93         a new modified GET ''' 
    94         for var in variables: 
    95             self.variables[var]=variables[var] 
    96         return self.__rebuildURL() 
    97 class Response: 
    98         ''' Holds all the parts of the response to an HTML get or post ''' 
    99         def __init__(self,content='text/html'): 
    100                 self.headers=[] 
    101                 self.cookie=None 
    102                 self.contentType=content 
    103                 self.content='' 
    104         def write(self,out): 
    105                 for name,value in self.headers: 
    106                         out.write("%s: %s\n"( name,value)) 
    107                 if self.cookie: 
    108                         out.write("%s\n"%self.cookie) 
    109                 out.write("Content-type: %s\n"%self.contentType) 
    110                 out.write("\n") 
    111                 self.content=self.content.encode('utf-8') 
    112                 out.write(self.content) 
    11352 
    11453class RingBuffer(deque): 
  • TI07-MOLES/trunk/PythonCode/wsgi/discovery.log

    r1903 r1905  
     12006-12-21 09:58:52,062 INFO Search Request [badc] took [0.184871912003s] 
     22006-12-21 09:58:52,062 INFO Search Request [badc] took [0.184871912003s] 
     32006-12-21 09:58:52,062 INFO Search Request [badc] took [0.184871912003s] 
     42006-12-21 10:01:30,531 INFO Search Request [badc] took [0.0554831027985s] 
     52006-12-21 10:01:30,531 INFO Search Request [badc] took [0.0554831027985s] 
     62006-12-21 10:01:30,531 INFO Search Request [badc] took [0.0554831027985s] 
     72006-12-21 10:01:30,724 INFO Document Load [n=3] took [0.191787958145s] 
     82006-12-21 10:01:30,724 INFO Document Load [n=3] took [0.191787958145s] 
     92006-12-21 10:01:30,724 INFO Document Load [n=3] took [0.191787958145s] 
     102006-12-21 10:08:25,026 INFO Search Request [badc] took [0.0956389904022s] 
     112006-12-21 10:08:25,026 INFO Search Request [badc] took [0.0956389904022s] 
     122006-12-21 10:08:25,026 INFO Search Request [badc] took [0.0956389904022s] 
     132006-12-21 10:08:25,211 INFO Document Load [n=3] took [0.184653043747s] 
     142006-12-21 10:08:25,211 INFO Document Load [n=3] took [0.184653043747s] 
     152006-12-21 10:08:25,211 INFO Document Load [n=3] took [0.184653043747s] 
     162006-12-21 10:14:25,284 INFO Search Request [badc] took [0.0539050102234s] 
     172006-12-21 10:14:25,284 INFO Search Request [badc] took [0.0539050102234s] 
     182006-12-21 10:14:25,284 INFO Search Request [badc] took [0.0539050102234s] 
     192006-12-21 10:14:25,470 INFO Document Load [n=3] took [0.185823917389s] 
     202006-12-21 10:14:25,470 INFO Document Load [n=3] took [0.185823917389s] 
     212006-12-21 10:14:25,470 INFO Document Load [n=3] took [0.185823917389s] 
     222006-12-21 10:15:08,301 INFO Search Request [badc] took [0.110265016556s] 
     232006-12-21 10:15:08,301 INFO Search Request [badc] took [0.110265016556s] 
     242006-12-21 10:15:08,301 INFO Search Request [badc] took [0.110265016556s] 
     252006-12-21 10:15:08,472 INFO Document Load [n=3] took [0.171009063721s] 
     262006-12-21 10:15:08,472 INFO Document Load [n=3] took [0.171009063721s] 
     272006-12-21 10:15:08,472 INFO Document Load [n=3] took [0.171009063721s] 
     282006-12-21 10:15:32,358 INFO Search Request [badc] took [0.0470740795135s] 
     292006-12-21 10:15:32,358 INFO Search Request [badc] took [0.0470740795135s] 
     302006-12-21 10:15:32,358 INFO Search Request [badc] took [0.0470740795135s] 
     312006-12-21 10:15:32,525 INFO Document Load [n=3] took [0.166059970856s] 
     322006-12-21 10:15:32,525 INFO Document Load [n=3] took [0.166059970856s] 
     332006-12-21 10:15:32,525 INFO Document Load [n=3] took [0.166059970856s] 
     342006-12-21 10:17:22,205 INFO Search Request [badc] took [0.0579249858856s] 
     352006-12-21 10:17:22,205 INFO Search Request [badc] took [0.0579249858856s] 
     362006-12-21 10:17:22,205 INFO Search Request [badc] took [0.0579249858856s] 
     372006-12-21 10:17:22,408 INFO Document Load [n=3] took [0.201308965683s] 
     382006-12-21 10:17:22,408 INFO Document Load [n=3] took [0.201308965683s] 
     392006-12-21 10:17:22,408 INFO Document Load [n=3] took [0.201308965683s] 
     402006-12-21 10:18:41,161 INFO Search Request [temperature] took [0.0985028743744s] 
     412006-12-21 10:18:41,161 INFO Search Request [temperature] took [0.0985028743744s] 
     422006-12-21 10:18:41,161 INFO Search Request [temperature] took [0.0985028743744s] 
     432006-12-21 10:18:42,040 INFO Document Load [n=1] took [0.87822508812s] 
     442006-12-21 10:18:42,040 INFO Document Load [n=1] took [0.87822508812s] 
     452006-12-21 10:18:42,040 INFO Document Load [n=1] took [0.87822508812s] 
  • TI07-MOLES/trunk/PythonCode/wsgi/ndg.ini

    r1903 r1905  
    44# BNL December 2006 
    55# 
    6 # 
    7  
    8 #[server:main] 
    9 #command=serve 
    106 
    117[server:main] 
     
    1915[composite:main] 
    2016use=egg:paste#urlmap 
    21 /discovery=ndgDiscovery 
     17/discovery=ndgWrapDiscovery 
    2218/browse=ndgBrowse 
    2319/cookie=cookieEG 
     20/layout=layout 
     21 
     22[app:layout] 
     23use=egg:Paste#static 
     24document_root=%(configDir)s/layout/ 
     25 
     26[filter-app:ndgWrapDiscovery] 
     27use = DiscoveryFrame 
     28next = ndgDiscovery 
     29 
     30[filter:DiscoveryFrame] 
     31paste.filter_factory = ndgPageLayout:DiscoveryFrameFactory 
    2432 
    2533[app:ndgDiscovery] 
  • TI07-MOLES/trunk/PythonCode/wsgi/ndgDiscovery.config

    r1903 r1905  
    44# will be  
    55#    - the server address 
     6#    - it might be necessary to customise the location of the layout directory  
    67#    - the localLink, localImage and localAlt in the [layout] section 
    7 #    - it might be necessary to customise the location of the layout directory itself 
    88# 
    9 [DEFAULTS] 
    10 server:              http://localhost.localdomain/ 
     9[DEFAULT] 
     10server:         http://localhost.localdomain:8001/ 
     11layoutdir:      /home/bnl/sandboxes/ndg/TI07-MOLES/trunk/PythonCode/browse/portal/cgi/layout/ 
     12layout:         /layout/ 
    1113 
    1214[SEARCH] 
    13  
    1415advancedURL:        %(server)sdiscovery?advanced=1 
    15 discoveryURL:       %(server)sdiscovery/ 
     16discoveryURL:       %(server)sdiscovery 
    1617helpURL:            %(server)sdiscovery?help=1 
    1718 
     
    2122[layout] 
    2223###### user customisable: 
    23 layout:         /layout/ 
    2424localLink:      http://ndg.nerc.ac.uk/ 
    2525localImage:     %(layout)sndg_logo.gif 
     
    3838 
    3939[HELP] 
    40 helpFile:       %(layout)shelp.html 
     40helpFile:       %(layoutdir)shelp.html 
    4141 
    4242[NDG_A_SERVICE] 
  • TI07-MOLES/trunk/PythonCode/wsgi/ndgDiscovery.py

    r1903 r1905  
    11from Utilities import myConfig 
     2from paste.request import parse_querystring 
     3from DiscoveryGUI import DiscoveryGUI 
    24 
    35def discoveryFactory(global_config,**local_conf): 
     
    2830        self.configDir=configDir 
    2931        self.config=myConfig(configDir+'ndgDiscovery.config') 
     32        self.logger=self.config.getLog() 
    3033     
    3134    def __call__(self,environ,start_response): 
    3235         
    33         ''' This is the function which implements the ndgDiscovery ''' 
     36        ''' This is the wsgi function which implements the ndgDiscovery ''' 
    3437         
    35         html='<p> Discovery Test code, with server [%s]</p>'%self.config.get('DEFAULTS','server') 
     38        inputs=dict(parse_querystring(environ)) 
    3639         
     40        d=DiscoveryGUI(inputs,self.config,self.logger) 
     41 
    3742        start_response('200 OK', [('Content-Type', 'text/html')]) 
     43        #h='<p>%s:%s</p>'%(str(inputs),self.config.get('SEARCH','advancedURL')) 
    3844         
    39         return [html] 
     45        return [d.html] 
Note: See TracChangeset for help on using the changeset viewer.