title: Blender : AttributeError: '_RestrictContext' object has no attribute 'scene'
body: <p>When running my script, I get this error:</p>
  <blockquote>
  <p>AttributeError: '_RestrictContext' object has no attribute 'scene'</p>
  </blockquote>
  <p>I'm trying to create a script for optimization:</p>
  <pre><code>bl_info = {
      &quot;name&quot;: &quot;Empic Stone&quot;,
      &quot;author&quot;: &quot;Null&quot;,
      &quot;version&quot;: (0, 0, 1),
      &quot;blender&quot;: (2, 79, 0),
      &quot;location&quot;: &quot;VIEW3D &gt; ADD &gt; Mesh&quot;,
      &quot;description&quot;: &quot;Empic Stone&quot;,
      &quot;warning&quot;: &quot;&quot;,
      &quot;wiki_url&quot;: &quot;&quot;,
      &quot;tracker_url&quot;: &quot;&quot;,
      &quot;category&quot;: &quot;Add Mesh&quot;
  }
  
  # Imports
  import bpy
  
  # Mesh - Create Cubic
  bpy.ops.mesh.primitive_cube_add(location=(0.00, 0.00, 1.00))
  
  def draw_item(self, context):
       self.layout.operator_context = 'INVOKE_DEFAULT'
       self.layout.operator(EpicStone.bl_idname, text=&quot;Epic Stone&quot;, icon=&quot;PLUGIN&quot;)
  
  def register():
      bpy.utils.register_module(__name__)
      bpy.types.INFO_MT_mesh_add.append(draw_item)
  
  def unregister():
      bpy.utils.unregister_module(__name__)
      bpy.types.INFO_MT_mesh_add.remove(draw_item)
  
  if __name__ == '__main__':
       register()
  </code></pre>