How to get cursor position in 2.8 So I'm trying to convert the following script in 2.8
I have replaced scene with depsgraph.
But I'm getting an erroneous on last line:
Scene object has no attribute 'cursor.location'

import bpy
from mathutils import Vector

#A class that takes into account a context and one of its attributes value
#If the value changes a callback is fired
class EventWatcher:

    #Set of watchers
    eventWatchers = set()

    @staticmethod
    def AddWatcher( watcher ):
        EventWatcher.eventWatchers.add( watcher )    

    @staticmethod
    def RemoveWatcher( watcher ):
        EventWatcher.eventWatchers.remove( watcher )

    @staticmethod
    def RemoveAllWatchers():
        EventWatcher.eventWatchers.clear()

    #From 'context', 'path' needs to exist
    #'comparer' is to compare the previous value of context.path to its new value
    #'callback' is the cb called if the value if changed
    #'copyValue' indicates if the value needs to be copied (that can be needed as if not old and new value may point onto the same object)
    def __init__( self, context, path, comparer, callback, copyValue ):
        self.context = context
        self.path = path
        self.comparer = comparer
        self.callback = callback
        self.copyValue = copyValue
        self.currentValue = self.GetValue()

    def GetValue( self ):
        value = getattr( self.context, self.path )
        if self.copyValue:
            value = value.copy()
        return value

    def Fire( self ):
        newValue = self.GetValue()
        if self.comparer( self.currentValue, newValue ) == False:
            self.callback( self, newValue )
            self.currentValue = newValue

#Global loop on the watchers. This callback responds to scene_update_post global handler
def cb_scene_update(context):
    for ew in EventWatcher.eventWatchers:
        ew.Fire()

#To stop the calls at the scene_update_post event level
class StopCallback(bpy.types.Operator):
    bl_idname = &quot;scene.stop_callback&quot;
    bl_label = &quot;Stop Callback&quot;

    @classmethod
    def poll(cls, context):
        return cb_scene_update in bpy.app.handlers.depsgraph_update_post

    def execute(self, context):
        bpy.app.handlers.scene_depsgraph_post.remove(cb_scene_update)
        return {'FINISHED'}

#To start the calls at the scene_update_post event level
class StartCallback(bpy.types.Operator):
    bl_idname = &quot;scene.start_callback&quot;
    bl_label = &quot;Start Callback&quot;

    @classmethod
    def poll(cls, context):
        return cb_scene_update not in bpy.app.handlers.depsgraph_update_post

    def execute(self, context):
        bpy.app.handlers.depsgraph_update_post.append(cb_scene_update)
        return {'FINISHED'}

#The panel is located in the scene properties
class SceneEventsPanel(bpy.types.Panel):
    bl_label = &quot;Scene events&quot;
    bl_idname = &quot;OBJECT_PT_scene_events&quot;
    bl_space_type = 'PROPERTIES'
    bl_region_type = 'WINDOW'
    bl_context = &quot;scene&quot;

    def draw(self, context):
        layout = self.layout
        row = layout.row()
        row.operator(&quot;scene.start_callback&quot;)
        row = layout.row()
        row.operator(&quot;scene.stop_callback&quot;)


def register():
    bpy.utils.register_class(SceneEventsPanel)
    bpy.utils.register_class(StartCallback)
    bpy.utils.register_class(StopCallback)

def unregister():
    bpy.utils.unregister_class(SceneEventsPanel)
    bpy.utils.unregister_class(StartCallback)
    bpy.utils.unregister_class(StopCallback)


if __name__ == '__main__':
    register()


print( '--------' )

#Example:

#The comparaison (for cursor location, it is a vector comparison)
def CompareLocation( l1, l2 ):
    return l1 == l2

#The callback to execute when the cursor's location changes    
def CompareLocationCallback( watcher, newValue ):
    print( 'New value', newValue )

#Install the watcher which will run the callback
EventWatcher.AddWatcher( EventWatcher( bpy.data.scenes[0], &quot;cursor.location&quot;, CompareLocation, CompareLocationCallback, True ) )
Actually it is not the last line that is causing the error but the GetValue method.
In order to access the location attribute of the cursor attribute of the scene, you must execute scene.cursor.location. Meaning you must first get access to the cursor, then to its location. What you can do is replace your GetValuemethod with :
def GetValue( self ):
    split_path = self.path.split(&quot;.&quot;)
    attr_path = split_path[0]
    if not hasattr(self.context, attr_path):
        print(f&quot;Error : {self.context} does not have any attribute named {attr_path}&quot;)
        return None
    value = getattr(self.context, split_path[0])  # Access 1st member of the property path
    for depth in range(len(split_path[1::])):  # Iteratively access the other members
        attr_path = split_path[depth + 1]
        if not hasattr(value, attr_path):                
            print(f&quot;Error : {value} does not have any attribute named {attr_path}&quot;)
            break
        value = getattr(value, attr_path)
    if self.copyValue and hasattr(value, &quot;copy&quot;):
        value = value.copy()
    return value

Meaning, if you want to access the X coordinate of the cursor location, you can change the last line to :
EventWatcher.AddWatcher(EventWatcher(bpy.data.scenes[0], &quot;cursor.location.x&quot;, CompareLocation, CompareLocationCallback, True))

Result :

By the way, I suggest looking at the guidelines for python naming and such in Blender.