human
Complete this python program:
def layer_shapefile():
assistant
#Here is the Python code you requested.

    """RESTful CRUD controller
    """
    tablename = ('%s_%s' % (module, resourcename))
    table = s3db[tablename]
    type = 'Shapefile'
    LAYERS = T((TYPE_LAYERS_FMT % type))
    ADD_NEW_LAYER = T((ADD_NEW_TYPE_LAYER_FMT % type))
    EDIT_LAYER = T((EDIT_TYPE_LAYER_FMT % type))
    LIST_LAYERS = T((LIST_TYPE_LAYERS_FMT % type))
    NO_LAYERS = T((NO_TYPE_LAYERS_FMT % type))
    s3.crud_strings[tablename] = Storage(label_create=ADD_LAYER, title_display=LAYER_DETAILS, title_list=LAYERS, title_update=EDIT_LAYER, label_list_button=LIST_LAYERS, label_delete_button=DELETE_LAYER, msg_record_created=LAYER_ADDED, msg_record_modified=LAYER_UPDATED, msg_record_deleted=LAYER_DELETED, msg_list_empty=NO_LAYERS)
    s3db.set_method(module, resourcename, method='enable', action=enable_layer)
    args = request.args
    if (len(args) > 1):
        test = args[1]
        if (test[:4] == 'data'):
            id = args[0]
            _tablename = ('gis_layer_shapefile_%s' % id)
            Fields = [Field('lat', 'float'), Field('lon', 'float'), Field('wkt', 'text'), Field('layer_id', table)]
            append = Fields.append
            row = db((table.id == id)).select(table.data, limitby=(0, 1)).first()
            if (row and row.data):
                fields = json.loads(row.data)
                for field in fields:
                    append(Field(str(field[0]), field[1]))
                if settings.get_gis_spatialdb():
                    append(Field('the_geom', 'geometry()'))
                s3db.define_table(_tablename, *Fields)
                new_arg = _tablename[4:]
                extension = test[4:]
                if extension:
                    new_arg = ('%s%s' % (new_arg, extension))
                args[1] = new_arg
                s3db.add_components('gis_layer_shapefile', **{_tablename: 'layer_id'})
            else:
                raise ValueError
    def prep(r):
        if r.interactive:
            if (r.component_name == 'config'):
                ltable = s3db.gis_layer_config
                ltable.base.writable =...