src/pyams_gis/site.py
changeset 0 c73bb834ccbe
child 30 05b4512b2821
equal deleted inserted replaced
-1:000000000000 0:c73bb834ccbe
       
     1 #
       
     2 # Copyright (c) 2008-2015 Thierry Florac <tflorac AT ulthar.net>
       
     3 # All Rights Reserved.
       
     4 #
       
     5 # This software is subject to the provisions of the Zope Public License,
       
     6 # Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
       
     7 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
       
     8 # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
       
     9 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
       
    10 # FOR A PARTICULAR PURPOSE.
       
    11 #
       
    12 
       
    13 __docformat__ = 'restructuredtext'
       
    14 
       
    15 
       
    16 # import standard library
       
    17 
       
    18 # import interfaces
       
    19 from pyams_gis.interfaces.utility import IMapManager
       
    20 from pyams_utils.interfaces.site import ISiteGenerations
       
    21 from zope.site.interfaces import INewLocalSite
       
    22 
       
    23 # import packages
       
    24 from pyams_gis.utility import MapManager
       
    25 from pyams_utils.registry import utility_config
       
    26 from pyams_utils.site import check_required_utilities
       
    27 from pyramid.events import subscriber
       
    28 
       
    29 
       
    30 REQUIRED_UTILITIES = ((IMapManager, '', MapManager, 'Maps manager'), )
       
    31 
       
    32 
       
    33 @subscriber(INewLocalSite)
       
    34 def handle_new_local_site(event):
       
    35     """Create a new map manager when a site is created"""
       
    36     site = event.manager.__parent__
       
    37     check_required_utilities(site, REQUIRED_UTILITIES)
       
    38 
       
    39 
       
    40 @utility_config(name='PyAMS GIS', provides=ISiteGenerations)
       
    41 class MapGenerationsChecker(object):
       
    42     """Maps generations checker"""
       
    43 
       
    44     generation = 1
       
    45 
       
    46     def evolve(self, site, current=None):
       
    47         """Check for required utilities"""
       
    48         check_required_utilities(site, REQUIRED_UTILITIES)