I want to write a scene property from a menu item

I have a menu class that draws some operators, however I want to write to a scene property as well.

For example:

This is the code

import bpy

bpy.types.Scene.test = bpy.props.StringProperty()

class BasicMenu(bpy.types.Menu):
    bl_idname = "OBJECT_MT_select_test"
    bl_label = "Select"

    def draw(self, context):
    	# I want to write here to the property
        layout = self.layout
        layout.operator("object.select_random", text="Random")

you’ll have to create your own operator, which sets scene.test = “…” and calls object.select_random(), then add this instead to the panel.

That means that the context of a Menu is not allowed to access other contexts, right?

not sure what you mean by context?

It’s allowed to do:

props = layout.operator("wm.context_set_string")
props.data_path = "scene.test"
props.value = "foobar"