Changes between Version 49 and Version 50 of DeveloperGuidelines/GIS


Ignore:
Timestamp:
09/18/13 12:10:34 (11 years ago)
Author:
Fran Boon
Comment:

Some updates to the 'Add New Layer Type' tutorial

Legend:

Unmodified
Added
Removed
Modified
  • DeveloperGuidelines/GIS

    v49 v50  
    88== Guidelines for Developers wishing to make use of Mapping within their Module ==
    99The easiest approach is to call the Mapping API.
     10
    1011=== Controller ===
    1112{{{
     
    1314return dict(map=map)
    1415}}}
     16
    1517=== View ===
    1618{{{
    1719{{=XML(map)}}
    1820}}}
     21
    1922=== Examples ===
    2023Check the following functions in {{{controllers/gis.py}}}:
     
    154157Assuming that !OpenLayers supports the layertype:
    155158==== Model ====
    156 {{{models/03_gis.py}}}
     159{{{modules/s3db/gis.py}}}
    157160{{{
    158161_gis_layer_types = ["newlayertype", "..."]
    159 table = db.define_table("gis_layer_newlayertype",
    160                             name_field(),
    161                             Field("description", label=T("Description")),
    162                             Field("enabled", "boolean", default=True, label=T("Available in Viewer?")),
    163                             Field("visible", "boolean", default=True,
    164                                   label=T("On by default? (only applicable to Overlays)")),
    165                             Field("url", label=T("Location"), requires = IS_NOT_EMPTY(),
    166                                   comment=DIV( _class="tooltip",
    167                                                _title="%s|%s" % (T("Location"),
    168                                                                  T("The URL to access the service.")))),
    169                             Field("version", length=32,
    170                                   label=T("Version"), default="1.1.1",
    171                                   requires=IS_IN_SET(["1.1.1", "1.3.0"], zero=None)),
    172                             Field("base", "boolean", default=False,
    173                                   label=T("Base Layer?")),
    174                             Field("transparent", "boolean", default=True,
    175                                   label=T("Transparent?")),
    176                             gis_opacity(),
    177                             role_required(),       # Single Role
    178                             #roles_permitted(),    # Multiple Roles (needs implementing in modules/s3gis.py)
    179                             *s3_timestamp())
     162table = self.define_table("gis_layer_newlayertype",
     163                          name_field(),
     164                          Field("description", label=T("Description")),
     165                          Field("enabled", "boolean", default=True, label=T("Available in Viewer?")),
     166                          Field("visible", "boolean", default=True,
     167                                label=T("On by default? (only applicable to Overlays)")),
     168                          Field("url", label=T("Location"), requires = IS_NOT_EMPTY(),
     169                                comment=DIV(_class="tooltip",
     170                                            _title="%s|%s" % (T("Location"),
     171                                                              T("The URL to access the service.")))),
     172                          Field("version", length=32,
     173                                label=T("Version"), default="1.1.1",
     174                                requires=IS_IN_SET(["1.1.1", "1.3.0"], zero=None)),
     175                          Field("base", "boolean", default=False,
     176                                label=T("Base Layer?")),
     177                          Field("transparent", "boolean", default=True,
     178                                label=T("Transparent?")),
     179                          gis_opacity(),
     180                          role_required(),       # Single Role
     181                          #roles_permitted(),    # Multiple Roles (needs implementing in modules/s3gis.py)
     182                          *s3_timestamp())
    180183}}}
    181184
     
    185188def layer_newlayertype():
    186189    """ RESTful CRUD controller """
    187     if deployment_settings.get_security_map() and not shn_has_role("MapAdmin"):
     190    if settings.get_security_map() and not s3_has_role("MapAdmin"):
    188191        unauthorised()
    189192
    190193    resourcename = request.function
    191194    tablename = "%s_%s" % (module, resourcename)
    192     table = db[tablename]
     195    table = s3db[tablename]
    193196
    194197    # Model options
     
    219222
    220223    # Post-processor
    221     def user_postp(jr, output):
    222         shn_action_buttons(jr)
     224    def postp(r, output):
     225        s3_action_buttons(r)
    223226        return output
    224     response.s3.postp = user_postp
    225 
    226     output = s3_rest_controller(module, resourcename)
     227    response.s3.postp = postp
     228
     229    output = s3_rest_controller()
    227230
    228231    if not "gis" in response.view:
     
    237240<li><a href='{{=URL(f="layer_newlayertype")}}'>New Layer Type</a> - Description</li>
    238241}}}
     242
    239243==== Module ====
    240244Classes need adding: