human
Complete the below
def layer_entity():

    ''''RESTful CRUD controller'
    '''
assistant
#Here is the Python code you requested.
    if (settings.get_security_map() and (not s3_has_role(MAP_ADMIN))):
        auth.permission.fail()
    s3db.set_method(module, resourcename, method='disable', action=disable_layer)
    def prep(r):
        if r.interactive:
            if (r.component_name == 'config'):
                ltable = s3db.gis_layer_config
                type = r.record.instance_type
                if (type in ('gis_layer_coordinate', 'gis_layer_feature', 'gis_layer_geojson', 'gis_layer_georss', 'gis_layer_gpx', 'gis_layer_kml', 'gis_layer_mgrs', 'gis_layer_wfs')):
                    ltable.base.writable = ltable.base.readable = False
                elif (type in ('gis_layer_empty', 'gis_layer_bing', 'gis_layer_google', 'gis_layer_tms')):
                    ltable.visible.writable = ltable.visible.readable = False
                if (r.method == 'update'):
                    ltable.config_id.writable = False
                else:
                    table = s3db.gis_config
                    query = ((ltable.config_id == table.id) & (ltable.layer_id == r.id))
                    rows = db(query).select(table.id)
                    ltable.config_id.requires = IS_ONE_OF(db, 'gis_config.id', '%(name)s', not_filterby='id', not_filter_opts=[row.id for row in rows])
            elif (r.component_name == 'style'):
                type = r.record.instance_type
                if (type != 'gis_layer_feature'):
                    field = s3db.gis_style.gps_marker
                    field.writable = field.readable = False
        return True
    s3.prep = prep
    output = s3_rest_controller(rheader=s3db.gis_rheader)
    return output