<div dir="ltr">Being able to store properties in user preferences for example, would be a great thing to have in this case (and others). I too have to store global settings in the scene, because unfortunately there's nowhere else to put it...</div>

<div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Dec 20, 2012 at 11:33 PM, Campbell Barton <span dir="ltr"><<a href="mailto:ideasman42@gmail.com" target="_blank">ideasman42@gmail.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On Thu, Dec 20, 2012 at 12:09 PM, dimitris chloupis<br>
<<a href="mailto:thekilon@yahoo.co.uk">thekilon@yahoo.co.uk</a>> wrote:<br>
> I am the developer of Gyes ( random material and texture generator). The<br>
> reason why Gyes<br>
> use bpy.context.scene is to store a property that store presets of<br>
> randomised materials / textures.<br>
> I wanted the data to be stored/saved with the blend file and be associated<br>
> with the scene curently loaded<br>
> as global scene presets and not specific presets to objects or any other 3d<br>
> asset.<br>
><br>
> I am not sure if removing bpy.context.scene is a good idea in the first<br>
> place, unless there is another way to save<br>
> , store scene presets together with the blend file. If so , then gladly I<br>
> will update my addon. But if not , it basically<br>
> cripples / makes useless my history tool -><br>
> <a href="http://wiki.blender.org/index.php/Extensions:2.6/Py/Scripts/System/Gyes/History-Tool" target="_blank">http://wiki.blender.org/index.php/Extensions:2.6/Py/Scripts/System/Gyes/History-Tool</a><br>
><br>
><br>
> ________________________________<br>
> From: Campbell Barton <<a href="mailto:ideasman42@gmail.com">ideasman42@gmail.com</a>><br>
> To: Blender Foundation Python list <<a href="mailto:bf-python@blender.org">bf-python@blender.org</a>>; bf-blender<br>
> developers <<a href="mailto:bf-committers@blender.org">bf-committers@blender.org</a>><br>
> Sent: Thursday, 20 December 2012, 4:38<br>
> Subject: [Bf-python] Addon's can no longer access context on activation.<br>
><br>
> Recently I've noticed addons using bpy.context.scene when being<br>
> imported or in the register() function.<br>
><br>
> This is really bad practice and will cause inconsistency if the addon<br>
> is enabled and a different blend file is loaded.<br>
> In the worst case accessing a removed datablock can crash which is<br>
> likely if a datablock is stored as a global variable on activation -<br>
> object_laplace_lightning.py does this.<br>
><br>
> I've changed addon loading so that they only get access to a<br>
> restricted context which only exposes 'window_manager' - needed for<br>
> adding keymaps.<br>
><br>
><br>
> Accessing other attributes now errors out with...<br>
><br>
>   AttributeError: '_RestrictedContext' object has no attribute 'scene'<br>
><br>
> The addons distributed with blender don't do this but some contrib<br>
> addons do, so they will need updating<br>
> (release/scripts/addons_contrib).<br>
><br>
> ----<br>
>     add_mesh_clusters<br>
>     gyes<br>
>     io_atomblend_utilities<br>
>     io_export_marmalade<br>
>     io_import_LRO_Lola_MGS_Mola_img<br>
>     io_import_lipSync_Importer<br>
>     mesh_edgetools<br>
>     mesh_fiber<br>
>     mesh_show_vgroup_weights<br>
>     node_categories<br>
>     object_laplace_lightning<br>
>     online_mat_lib<br>
>     sequencer_extra_actions<br>
>     space_view3d_quickPrefs<br>
><br>
> If any devs want some help updating their addons you can ask on<br>
> bf-python mailing list, though in all cases I've seen its quite<br>
> straightforward.<br>
><br>
> --<br>
> - Campbell<br>
<br>
</div></div>Access has only been removed on loading the addon.<br>
<br>
The solution is just not to access presets when the addon loads and<br>
register()'s,<br>
during execution you still have regular access to the context<br>
(operators, panels etc).<br>
<br>
Since the scene at load time may very well not be the same scene when<br>
the script executes (if the user loads a new file), whatever changes<br>
made at load time are likely lost.<br>
<div class="HOEnZb"><div class="h5"><br>
--<br>
- Campbell<br>
_______________________________________________<br>
Bf-python mailing list<br>
<a href="mailto:Bf-python@blender.org">Bf-python@blender.org</a><br>
<a href="http://lists.blender.org/mailman/listinfo/bf-python" target="_blank">http://lists.blender.org/mailman/listinfo/bf-python</a><br>
</div></div></blockquote></div><br></div>