simple add-on not working this is a simple add on just to select a loop so i can make the mean crease value 1

I do this alot and the constant moving mouse right is starting to hurt my had for models then will be subdivided.

I just want to press on a edge, (use the assigned shortcut key to active the add on) it will then select the loop and set the value of mean crease to 1.

This only works with the scripting editor, I can't get the add on to work after saving as test.py any help please.

I get the following errors :

addon_utils.disable: edge crease not disabled
Modules Installed (edge crease) from 'C:\\Users\\RTJ\\Documents\\edge crease.py' into 'C:\\Users\\RTJ\\AppData\\Roaming\\Blender Foundation\\Blender\\2.80\\scripts\\addons'
Traceback (most recent call last):
  File "C:\Program Files\Blender Foundation\Blender\2.80\scripts\modules\addon_utils.py", line 351, in enable
    mod = __import__(module_name)
  File "C:\Users\RTJ\AppData\Roaming\Blender Foundation\Blender\2.80\scripts\addons\edge crease.py", line 35, in &lt;module&gt;
    class EdgeCrease(bpy.types.Operator):
  File "C:\Users\RTJ\AppData\Roaming\Blender Foundation\Blender\2.80\scripts\addons\edge crease.py", line 42, in EdgeCrease
    bpy.ops.mesh.loop_multi_select(ring=False)
  File "C:\Program Files\Blender Foundation\Blender\2.80\scripts\modules\bpy\ops.py", line 195, in __call__
    BPyOpsSubModOp._view_layer_update(context)
  File "C:\Program Files\Blender Foundation\Blender\2.80\scripts\modules\bpy\ops.py", line 157, in _view_layer_update
    view_layer = context.view_layer
AttributeError: '_RestrictContext' object has no attribute 'view_layer' "


the script:

bl_info = {
    "name": "Edge Crease  ",
    "author": "RTJ3DCosplay",
    "version": (1, 0),
    "blender": (2, 80, 0),
    "location": "",
    "description": "delete in context",
    "warning": "experimental, not stable, at your own risk",
    "wiki_url": "https://your web or web of the maintainer",
    "category": "category where the addon is located"
}

import bpy        
import bmesh
import mathutils
import collections
import math

from bpy_extras import view3d_utils
from bpy.types import (
        Operator,
        Menu,
        Panel,
        PropertyGroup,
        AddonPreferences,
        )
from bpy.props import (
        BoolProperty,
        EnumProperty,
        FloatProperty,
        IntProperty,
        PointerProperty,
        StringProperty,
        )

class EdgeCrease(bpy.types.Operator):
    """Edge Crease"""
    bl_idname = "object.edge_crease"
    bl_label = "Edge Crease"
    bl_options = {'REGISTER', 'UNDO'}

 # this is all i'm trying to do,
 # i select on edge then active this to loop select and set value to 1
 # id be happy just to set to 1 each time

    bpy.ops.mesh.loop_multi_select(ring=False) 
    bpy.ops.transform.edge_crease(value=1)



def register():
    bpy.utils.register_class(EdgeCrease)



def unregister():
    bpy.utils.unregister_class(EdgeCrease)


if __name__ == "__main__":
    register()
You need to put your functionality of the operator in the execute function. Otherwise the issue described in this answer will occur.

def execute(self, context):
    bpy.ops.mesh.loop_multi_select(ring=False) 
    bpy.ops.transform.edge_crease(value=1)

    return {'FINISHED'}