Changeset 459

Show
Ignore:
Timestamp:
01/11/06 13:11:29 (5 years ago)
Author:
dokai
Message:

Use the portal_maprenderer tool (ticket:80). This requires ZCO r457 in order
to work.

Location:
PrimaGIS/trunk
Files:
9 modified

Legend:

Unmodified
Added
Removed
  • PrimaGIS/trunk/CHANGES.txt

    r447 r459  
    1212 
    1313Features 
    14  
     14 * Ticket: #80: Use the ZCO MapRendererTool (portal_maprenderer). 
    1515 
    16160.5.0 (21.12.2005) 
  • PrimaGIS/trunk/Extensions/Install.py

    r449 r459  
    260260               "%s != %s" % (src.getProperty(prop_id), dest.getProperty(prop_id)) 
    261261 
     262def install_zco(self, out): 
     263    """ 
     264    Install the CMF aware parts of ZCO. 
     265    """ 
     266    try: 
     267        maprenderer = getToolByName(self, 'portal_maprenderer') 
     268        # Nothing to do 
     269    except AttributeError: 
     270        # Install ZCO 
     271        getToolByName(self, 'portal_quickinstaller').installProduct('ZCO') 
     272        # Allow the AttributeError to propagate if the installation failed. 
     273        maprenderer = getToolByName(self, 'portal_maprenderer') 
     274        print >> out, "Installed ZCO MapRendererTool at %s" % "/".join(maprenderer.getPhysicalPath()) 
     275     
     276 
    262277def install(self): 
    263278    out = StringIO() 
     
    269284    install_subskin(self, out, GLOBALS) 
    270285    install_folder_tabs(self, out) 
     286    install_zco(self, out) 
    271287    migrate_pre_0_5_0(self, out) 
    272288 
  • PrimaGIS/trunk/PrimaGISMap.py

    r453 r459  
    573573        Returns the ZCO Map Renderer object used for rendering this map. 
    574574        """ 
    575         return getattr(self.getZCOContainer(), MAP_RENDERER, None) 
     575        # Look for an overridden maprenderer in the acquisition context 
     576        maprenderer = getattr(self.getZCOContainer(), MAP_RENDERER, None) 
     577        if maprenderer is None: 
     578            # Use the MapRendererTool as a fallback 
     579            maprenderer = getToolByName(self, 'portal_maprenderer') 
     580        return maprenderer 
    576581 
    577582    security.declarePublic("getLayerContainer") 
  • PrimaGIS/trunk/skins/primagis/createPrimaGISDemo.py

    r455 r459  
    3131The demo instance assumes that you have installed the world_borders shapefile 
    3232(available from http://www.mappinghacks.com/data/world_borders.zip) and the 
    33 WORLD_BORDERS_OVF is configured accordingly. You can always change the 
    34 settings by modifying the properties of the 'mapper' (ZCO MapRenderer) object 
    35 through ZMI. 
     33WORLD_BORDERS_OVF is configured accordingly. 
    3634 
    3735Below is an example OGR Virtual File (.ovf) to be used with the world borders 
     
    5856# Location of the world_borders shapefile on the filesystem 
    5957WORLD_BORDERS_OVF = '/usr/local/mapdata/world/world_borders.ovf' 
    60 # Location of the fontset file 
    61 FONTSET_FILE = '/usr/local/mapdata/fontset.txt' 
    6258## End of user configurable section ## 
    6359 
     
    8581demo.zco.manage_addProduct['OFSP'].manage_addFolder('symbolizers', title="Map symbolizers") 
    8682 
    87 ## ZCO MapRenderer 
    88 demo.zco.manage_addProduct['ZCO'].manage_addMapRenderer('mapper') 
    89 demo.zco.mapper.manage_changeProperties(title='Map renderer') 
    90 for prop in [('engine', 'MAPSERVER', 'string'), 
    91              ('fsdataroot', '', 'string'), 
    92              ('fontset', FONTSET_FILE, 'string'), 
    93              ('incoming', TEMP_DIR, 'string')]: 
    94     demo.zco.mapper.manage_addProperty(*prop)      
    9583 
    9684## ZCO Datastores 
  • PrimaGIS/trunk/tests/__init__.py

    r5 r459  
     1# Fontset file used with the unit tests 
     2TEST_FONTSET = '/usr/local/mapdata/fontset.txt' 
     3 
     4# Incoming directory used with the unit tests 
     5TEST_INCOMING = '/tmp' 
  • PrimaGIS/trunk/tests/rununittests

    r362 r459  
    11#!/bin/sh 
    22 
    3 export SOFTWARE_HOME=/usr/local/zope/lib/python 
    43/usr/bin/python runalltests.py 
    54 
  • PrimaGIS/trunk/tests/testPrimaGISDataLayer.py

    r395 r459  
    88from Testing import ZopeTestCase 
    99from AccessControl.SecurityManagement import newSecurityManager 
     10from Products.CMFCore.utils import getToolByName 
    1011from Products.Archetypes.tests import ArchetypesTestCase 
    1112from Products.PrimaGIS.GeoArchetypesProxy import GeoArchetypesProxy 
    1213from Products.PrimaGIS.interfaces import IPrimaGISDataLayer 
     14from Products.PrimaGIS.tests import TEST_FONTSET, TEST_INCOMING 
    1315from Products.ZCO.interfaces import IFeatureStoreProxy, IDataStoreProxy, ILayerProxy 
    1416from cartography import data, mapping 
     
    4648        self.portal.portal_quickinstaller.installProduct('PrimaGIS') 
    4749        self.portal.portal_quickinstaller.installProduct('DummyContent') 
     50         
     51        maprenderer = getToolByName(self.portal, 'portal_maprenderer') 
     52        maprenderer.manage_changeProperties({'fontset' : TEST_FONTSET, 
     53                                             'incoming' : TEST_INCOMING}) 
    4854 
    4955    def test_interface_IFeatureStoreProxy(self): 
  • PrimaGIS/trunk/tests/testPrimaGISLayer.py

    r370 r459  
    88from Testing import ZopeTestCase 
    99from AccessControl.SecurityManagement import newSecurityManager 
     10from Products.CMFCore.utils import getToolByName 
    1011from Products.Archetypes.tests import ArchetypesTestCase 
    1112from Products.PrimaGIS.interfaces import IPrimaGISLayer 
     13from Products.PrimaGIS.tests import TEST_FONTSET, TEST_INCOMING 
    1214import os.path 
    1315 
     
    4244        self.portal.portal_quickinstaller.installProduct('PrimaGIS') 
    4345        self.portal.portal_quickinstaller.installProduct('DummyContent') 
     46         
     47        maprenderer = getToolByName(self.portal, 'portal_maprenderer') 
     48        maprenderer.manage_changeProperties({'fontset' : TEST_FONTSET, 
     49                                             'incoming' : TEST_INCOMING}) 
    4450 
    4551    def test_interface_IPrimaGISLayer(self): 
     
    8995        self.createDemo() 
    9096        # Render the WMS Layer 
     97        self.portal.demo.zco.layers.landsat_mosaic.manage_changeProperties({'bbox':'-50 -50 50 50'}) 
    9198        f = open('testPrimaGISLayer_WMS_Landsat_300x300.png', 'w') 
    9299        f.write(self.portal.demo.primagis.wms_landsat.view()) 
  • PrimaGIS/trunk/tests/testPrimaGISMap.py

    r397 r459  
    88from Testing import ZopeTestCase 
    99from AccessControl.SecurityManagement import newSecurityManager 
     10from Products.CMFCore.utils import getToolByName 
    1011from Products.Archetypes.tests import ArchetypesTestCase 
    1112from Products.PrimaGIS import config 
    1213from Products.PrimaGIS.interfaces import IPrimaGISMap 
     14from Products.PrimaGIS.tests import TEST_FONTSET, TEST_INCOMING 
    1315from cartography.spatial import Point, BoundingBox 
    1416import os.path 
     
    6466        # Install the products 
    6567        self.portal.portal_quickinstaller.installProduct('PrimaGIS') 
     68        # Configure the MapRendererTool 
     69        maprenderer = getToolByName(self.portal, 'portal_maprenderer') 
     70        maprenderer.manage_changeProperties({'fontset' : TEST_FONTSET, 
     71                                             'incoming' : TEST_INCOMING}) 
    6672        # We need DummyContent to create the demo hierarchy. If you're running 
    6773        # Plone 2.1, you can also use 'Document' here. 
     
    120126    def test_getMapRenderer(self): 
    121127        self.createDemo() 
    122         self.assertEquals(self.portal.demo.zco.mapper, 
     128        self.assertEquals(getToolByName(self.portal, 'portal_maprenderer'), 
    123129                          self.portal.demo.primagis.getMapRenderer()) 
    124130