Changeset 1930


Ignore:
Timestamp:
02/01/07 11:38:36 (13 years ago)
Author:
lawrence
Message:

Minor bug fixes and improvements to wsgi browse

Location:
TI07-MOLES/trunk/PythonCode/wsgi
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • TI07-MOLES/trunk/PythonCode/wsgi/DC.py

    r1925 r1930  
    1717            name=stripNamespace(tag.tag) 
    1818            u=(name,tag.text) 
     19            if u[1] is None: u=(name,'') 
    1920            if name in self.keys(): 
    2021                if isinstance(self[name],list): 
     
    4142                    for i in self[key][1:]: k+=', %s'%i 
    4243                else: 
     44                    print key 
    4345                    k+=self[key] 
    4446                h+=span(k,'metaentry')+'<br/>' 
  • TI07-MOLES/trunk/PythonCode/wsgi/People.py

    r1905 r1930  
    3131               orgURL 
    3232                 ... for presentation we figure further org contacts can be found by following the link which ought to exist) ''' 
    33             self.data={'personName':'','personEmail':'','personPhone':'','orgURL':'','orgName':'','searchlink':''} 
     33            self.data={'personName':Name(None),'personEmail':'','personPhone':'','orgURL':'','orgName':'','searchlink':''} 
    3434        def toHTML(self,prefix=''): 
     35            print self.data 
    3536            if self.elem is None: return '' 
    3637            html=prefix #para start? 
    37             if self.data['personName']!='': 
     38            if self.data['personName'].name!='': 
    3839                if self.data['personEmail']!='': 
    39                     html+=hyperlink(self.data['personName'],self.data['personEmail']) 
    40                 if self.data['personPhone']!='': html+='<br/>Phone: %s'%self.data['personPhone'] 
     40                    html+=hyperlink(self.data['personName'].name,self.data['personEmail']) 
     41                else: 
     42                    html+=self.data['personName'].name 
    4143            br='' 
    4244            if html!='': br='<br/>' #only need a linebreak if there is already content ... or '<p> 
    4345            if self.data['orgName']!='': 
    4446                html+=br+hyperlink(self.data['orgName'],self.data['orgURL']) 
     47            if self.data['personPhone']!='': html+='<br/>Phone: %s'%self.data['personPhone'] 
    4548            if self.data['searchlink']!='': html+='<br/>'+self.data['searchlink'] 
    4649            html+='' # para end? 
     
    5962                self.data['personName']=Name(self.elem.find('dgRoleHolder/dgPerson/name')) 
    6063                if ctype=='organisation': 
    61                         base='dgRoleHolder/dgOrganisation/' 
     64                        base='dgRoleHolder/organisation/' 
    6265                else: 
    6366                        base='dgRoleHolder/dgPerson/' 
     
    7780            self.data['orgURL']=helper.getText(self.elem,'Data_Center_URL') 
    7881        else: 
    79             self.data['personName']='placeholder for DIF contact' 
     82            self.data['personName'].name='Placeholder' 
  • TI07-MOLES/trunk/PythonCode/wsgi/discovery.log

    r1927 r1930  
    1401402006-12-23 13:44:59,749 INFO Document Load [n=3] took [0.792335033417s] 
    1411412006-12-23 13:44:59,749 INFO Document Load [n=3] took [0.792335033417s] 
     1422007-01-02 09:16:00,794 INFO Search Request [test] took [0.180282831192s] 
     1432007-01-02 09:16:00,794 INFO Search Request [test] took [0.180282831192s] 
     1442007-01-02 09:16:00,794 INFO Search Request [test] took [0.180282831192s] 
     1452007-01-02 09:16:00,794 INFO Search Request [test] took [0.180282831192s] 
     1462007-01-02 09:16:00,794 INFO Search Request [test] took [0.180282831192s] 
     1472007-01-02 09:16:05,820 INFO Search Request [badc] took [0.106508970261s] 
     1482007-01-02 09:16:05,820 INFO Search Request [badc] took [0.106508970261s] 
     1492007-01-02 09:16:05,820 INFO Search Request [badc] took [0.106508970261s] 
     1502007-01-02 09:16:05,820 INFO Search Request [badc] took [0.106508970261s] 
     1512007-01-02 09:16:05,820 INFO Search Request [badc] took [0.106508970261s] 
     1522007-01-02 09:16:06,028 INFO Document Load [n=3] took [0.206455945969s] 
     1532007-01-02 09:16:06,028 INFO Document Load [n=3] took [0.206455945969s] 
     1542007-01-02 09:16:06,028 INFO Document Load [n=3] took [0.206455945969s] 
     1552007-01-02 09:16:06,028 INFO Document Load [n=3] took [0.206455945969s] 
     1562007-01-02 09:16:06,028 INFO Document Load [n=3] took [0.206455945969s] 
     1572007-01-02 10:16:40,026 INFO Search Request [badc] took [0.0878579616547s] 
     1582007-01-02 10:16:40,026 INFO Search Request [badc] took [0.0878579616547s] 
     1592007-01-02 10:16:40,026 INFO Search Request [badc] took [0.0878579616547s] 
     1602007-01-02 10:16:40,026 INFO Search Request [badc] took [0.0878579616547s] 
     1612007-01-02 10:16:40,026 INFO Search Request [badc] took [0.0878579616547s] 
     1622007-01-02 10:16:40,196 INFO Document Load [n=3] took [0.168569087982s] 
     1632007-01-02 10:16:40,196 INFO Document Load [n=3] took [0.168569087982s] 
     1642007-01-02 10:16:40,196 INFO Document Load [n=3] took [0.168569087982s] 
     1652007-01-02 10:16:40,196 INFO Document Load [n=3] took [0.168569087982s] 
     1662007-01-02 10:16:40,196 INFO Document Load [n=3] took [0.168569087982s] 
     1672007-01-02 10:36:35,138 INFO Search Request [badc] took [0.0909781455994s] 
     1682007-01-02 10:36:35,138 INFO Search Request [badc] took [0.0909781455994s] 
     1692007-01-02 10:36:35,138 INFO Search Request [badc] took [0.0909781455994s] 
     1702007-01-02 10:36:35,138 INFO Search Request [badc] took [0.0909781455994s] 
     1712007-01-02 10:36:35,138 INFO Search Request [badc] took [0.0909781455994s] 
     1722007-01-02 10:36:35,312 INFO Document Load [n=3] took [0.172890901566s] 
     1732007-01-02 10:36:35,312 INFO Document Load [n=3] took [0.172890901566s] 
     1742007-01-02 10:36:35,312 INFO Document Load [n=3] took [0.172890901566s] 
     1752007-01-02 10:36:35,312 INFO Document Load [n=3] took [0.172890901566s] 
     1762007-01-02 10:36:35,312 INFO Document Load [n=3] took [0.172890901566s] 
     1772007-01-02 10:38:49,687 INFO Search Request [badc] took [0.0478868484497s] 
     1782007-01-02 10:38:49,687 INFO Search Request [badc] took [0.0478868484497s] 
     1792007-01-02 10:38:49,687 INFO Search Request [badc] took [0.0478868484497s] 
     1802007-01-02 10:38:49,687 INFO Search Request [badc] took [0.0478868484497s] 
     1812007-01-02 10:38:49,687 INFO Search Request [badc] took [0.0478868484497s] 
     1822007-01-02 10:38:49,878 INFO Document Load [n=3] took [0.188925981522s] 
     1832007-01-02 10:38:49,878 INFO Document Load [n=3] took [0.188925981522s] 
     1842007-01-02 10:38:49,878 INFO Document Load [n=3] took [0.188925981522s] 
     1852007-01-02 10:38:49,878 INFO Document Load [n=3] took [0.188925981522s] 
     1862007-01-02 10:38:49,878 INFO Document Load [n=3] took [0.188925981522s] 
     1872007-01-02 10:41:16,621 INFO Search Request [badc] took [0.109711885452s] 
     1882007-01-02 10:41:16,621 INFO Search Request [badc] took [0.109711885452s] 
     1892007-01-02 10:41:16,621 INFO Search Request [badc] took [0.109711885452s] 
     1902007-01-02 10:41:16,621 INFO Search Request [badc] took [0.109711885452s] 
     1912007-01-02 10:41:16,621 INFO Search Request [badc] took [0.109711885452s] 
     1922007-01-02 10:41:16,894 INFO Document Load [n=3] took [0.270878076553s] 
     1932007-01-02 10:41:16,894 INFO Document Load [n=3] took [0.270878076553s] 
     1942007-01-02 10:41:16,894 INFO Document Load [n=3] took [0.270878076553s] 
     1952007-01-02 10:41:16,894 INFO Document Load [n=3] took [0.270878076553s] 
     1962007-01-02 10:41:16,894 INFO Document Load [n=3] took [0.270878076553s] 
     1972007-01-02 10:42:00,845 INFO Search Request [badc] took [0.0487370491028s] 
     1982007-01-02 10:42:00,845 INFO Search Request [badc] took [0.0487370491028s] 
     1992007-01-02 10:42:00,845 INFO Search Request [badc] took [0.0487370491028s] 
     2002007-01-02 10:42:00,845 INFO Search Request [badc] took [0.0487370491028s] 
     2012007-01-02 10:42:00,845 INFO Search Request [badc] took [0.0487370491028s] 
     2022007-01-02 10:42:01,015 INFO Document Load [n=3] took [0.168444156647s] 
     2032007-01-02 10:42:01,015 INFO Document Load [n=3] took [0.168444156647s] 
     2042007-01-02 10:42:01,015 INFO Document Load [n=3] took [0.168444156647s] 
     2052007-01-02 10:42:01,015 INFO Document Load [n=3] took [0.168444156647s] 
     2062007-01-02 10:42:01,015 INFO Document Load [n=3] took [0.168444156647s] 
  • TI07-MOLES/trunk/PythonCode/wsgi/geoUtilities.py

    r1905 r1930  
    11from Utilities import wrapGetText 
     2def geoString2float(x): 
     3    if x[-1:] in 'NE': 
     4        return float(x[:-1]) 
     5    elif x[-1:] in 'SW': 
     6        return -float(x[:-1]) 
     7    else: 
     8        return float(x) 
     9 
    210class Bounding: 
    311    ''' Separated out because this is NDG specific really ''' 
     
    1523                  'East':'Spatial_Coverage/Easternmost_Longitude'} 
    1624                } 
    17         North=wrapGetText(elem,match[entity]['North']) 
    18         South=wrapGetText(elem,match[entity]['South']) 
    19         West=wrapGetText(elem,match[entity]['West']) 
    20         East=wrapGetText(elem,match[entity]['East']) 
     25        try: 
     26            North=wrapGetText(elem,match[entity]['North']) 
     27            South=wrapGetText(elem,match[entity]['South']) 
     28            West=wrapGetText(elem,match[entity]['West']) 
     29            East=wrapGetText(elem,match[entity]['East']) 
     30            self.set([North,West,East,South]) 
     31        except: 
     32            self.box=None 
    2133 
    22         try: 
    23                 self.box=[float(i) for i in [North, West, East, South]] 
    24         except: 
    25                 self.box=None 
    26                  
     34    def set(self,box): 
     35        try:  
     36            self.box=[geoString2float(i) for i in box] 
     37        except: 
     38            self.box=None 
     39 
    2740    def toHTML(self): 
    28                 if self.box is not None: 
    29                         html='''<p> 
    30                                 Limit North: %s <br/> 
    31                                 Limit West: %s Limit East: %s <br/> 
    32                                 Limit South: %s <br/>    
    33                                 </p>'''%self.box 
    34                 else: 
    35                         html='No bounding box available' 
    36                 return html      
     41        return self.toHTMLbox() 
     42     
    3743    def toHTMLbox(self): 
    3844        if self.box is not None: 
    3945            html='''<table><tbody><tr><td colspan="2" align="center">%s</td></tr> 
    40                     <tr><td>%s</td><td>%s</td></tr> 
    41                     <tr><td colspan="2" align="center">%s</td></tr></tbody></table>'''%tuple(self.box) 
     46                      <tr><td>%s,</td><td>&nbsp;%s</td></tr> 
     47                      <tr><td colspan="2" align="center">%s</td></tr> 
     48                    </tbody></table>'''%tuple(self.box) 
    4249        else: 
    4350            html='' 
    4451        return html 
     52         
     53import unittest 
     54class TestCase(unittest.TestCase): 
     55     
     56    def testgeoString2float(self): 
     57        self.assertEqual(geoString2float('12S'),-12.0) 
     58         
     59    def testBounding(self): 
     60        bbox=Bounding('dummy') 
     61        bbox.set(['15N','12W','12E','15S']) 
     62        y=bbox.toHTML() 
     63     
     64if __name__=="__main__": 
     65    unittest.main() 
  • TI07-MOLES/trunk/PythonCode/wsgi/renderEntity.py

    r1927 r1930  
    6767                <span class="headingO">Links and Services</span></td></tr>''' 
    6868        xicon=hyperlink(image(self.config.get('layout','Xicon'),'[X]'),entity.binding.url+'&type=xml') 
    69         html+='<tr><td>%s</td><td> This record rendered in XML </td></tr>'%xicon 
     69        html+='<tr><td width="20%%">%s</td><td> This record rendered in XML </td></tr>'%xicon 
    7070        picon=hyperlink(image(self.config.get('layout','printer'),'[Print]'),entity.binding.url+'&type=print') 
    7171        html+='<tr><td>%s</td><td> Printable version of XML content</td></tr>'%picon 
     
    8787        html+=''' 
    8888        <table cellspacing="0" cellpadding="3" width="100%" border="0"> 
    89                 <tbody> 
    90                         <tr> 
    91                                 <td class="lineHead" width="40%"><b>Field</b></td> 
    92                                 <td class="lineHead" width="60%"><b>Description</b></td> 
    93                         </tr>''' 
    94                          
    95          
    96         try: 
     89                <tbody><tr><td class="lineHead" colspan="3"> 
     90                          <span class="headingO">Dataset Detail</span></td></tr>''' 
     91                 
     92        #try: 
    9793        #currently all entities are parsed for these ...  
    9894             
    99             if len(entity.parameters)==1:  
    100                 html+='''<tr><td class="line">%s</td><td>'''%span('Parameter','keywords') 
    101             else: 
    102                 html+='''<tr><td class="line">%s</td><td>'''%span('Parameters','keywords') 
    103             html+=entity.parameters[0] 
    104             for item in entity.parameters[1:]: 
    105                 i=item.replace(' ','&nbsp;') 
    106                 html+=',&nbsp;&nbsp; %s'%i 
    107             html+='</td></tr>' 
    108             html+=''' 
    109                 <tr><td class="line"><b>Spatial Coverage</b><br/></td> 
    110                         <td class="line">%s</td></tr>'''%entity.bbox.toHTML() 
     95        if len(entity.parameters)==1:  
     96            html+='''<tr><td class="line" width="20%%">%s</td><td>'''%'Parameter' 
     97        else: 
     98            html+='''<tr><td class="line" width="20%%">%s</td><td>'''%'Parameters' 
     99        html+=entity.parameters[0] 
     100        for item in entity.parameters[1:]: 
     101            i=item.replace(' ','&nbsp;') 
     102            html+=',&nbsp;&nbsp; %s'%i 
     103        html+='</td></tr>' 
     104        html+=''' 
     105            <tr><td class="line">Spatial Coverage<br/></td> 
     106                    <td>%s</td></tr>'''%entity.bbox.toHTML() 
     107     
     108        html+=''' 
     109            <tr><td class="line">Temporal Coverage<br/></td> 
     110                    <td>%s</td></tr>'''%entity.timeCoverage 
    111111         
    112             html+=''' 
    113                 <tr><td class="line"><b>Temporal Coverage</b><br/></td> 
    114                         <td class="line">%s</td></tr>'''%entity.timeCoverage 
    115          
    116         except: pass 
     112        #except: pass 
    117113         
    118114        html+=''' 
    119                 <tr><td class="line"><b>Data Curator</b><br/></td> 
    120                         <td class="line">%s</td></tr>'''%entity.curator.toHTML() 
     115                <tr><td class="line">Data Curator<br/></td> 
     116                        <td>%s</td></tr>'''%entity.curator.toHTML() 
    121117                 
    122118        for c in entity.creators: 
    123119                html+=''' 
    124                         <tr><td class="line"><b>Data Creator</b><br/></td> 
    125                         <td class="line">%s</td></tr>'''%c.toHTML() 
     120                        <tr><td class="line">Data Creator<br/></td> 
     121                        <td>%s</td></tr>'''%c.toHTML() 
    126122                         
    127123        html+='</tbody></table>' 
     
    142138                          <span class="headingO">Data Granules</span></td></tr> 
    143139                        <tr class="lineHiLite"> 
    144                           <td width="30%" colspan="2">Accessability</td><td>Link</td></tr>''' 
     140                          <td width="20%" colspan="2">Accessability</td><td>Link</td></tr>''' 
    145141                for g in entity.granules: 
    146142                        html+='<tr>' 
Note: See TracChangeset for help on using the changeset viewer.