<html><body><div style="color:#000; background-color:#fff; font-family:arial, helvetica, sans-serif;font-size:12pt"><div><span>No idea what you talking about . No idea how to access bpy.context.scene while the addon loads.</span></div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: arial,helvetica,sans-serif; background-color: transparent; font-style: normal;"><br><span></span></div><div class="yui_3_7_2_20_1356003884620_48" style="color: rgb(0, 0, 0); font-size: 16px; font-family: arial,helvetica,sans-serif; background-color: transparent; font-style: normal;"><span>my access to bpy.context.scene happens here -> </span><br><a href="https://github.com/kilon/Gyes/blob/master/gyes/random_material_generator.py#L67">https://github.com/kilon/Gyes/blob/master/gyes/random_material_generator.py#L67</a></div><div class="yui_3_7_2_20_1356003884620_48" style="color: rgb(0, 0, 0); font-size: 16px; font-family: arial,helvetica,sans-serif;
 background-color: transparent; font-style: normal;"><br></div><div class="yui_3_7_2_20_1356003884620_48" style="color: rgb(0, 0, 0); font-size: 16px; font-family: arial,helvetica,sans-serif; background-color: transparent; font-style: normal;">and here -> <a href="https://github.com/kilon/Gyes/blob/master/gyes/random_material_generator.py#L622">https://github.com/kilon/Gyes/blob/master/gyes/random_material_generator.py#L622</a></div><div class="yui_3_7_2_20_1356003884620_48" style="color: rgb(0, 0, 0); font-size: 16px; font-family: arial,helvetica,sans-serif; background-color: transparent; font-style: normal;"><br></div><div class="yui_3_7_2_20_1356003884620_48" style="color: rgb(0, 0, 0); font-size: 16px; font-family: arial,helvetica,sans-serif; background-color: transparent; font-style: normal;"><br></div><div class="yui_3_7_2_20_1356003884620_48" style="color: rgb(0, 0, 0); font-size: 16px; font-family: arial,helvetica,sans-serif; background-color:
 transparent; font-style: normal;">in first case I check whether there is a historybak prop in scene , so there is no assumptions here <br></div><div class="yui_3_7_2_20_1356003884620_48" style="color: rgb(0, 0, 0); font-size: 16px; font-family: arial,helvetica,sans-serif; background-color: transparent; font-style: normal;">and blender has no reason to crash. Because I check if it exists in the first place.</div><div class="yui_3_7_2_20_1356003884620_48" style="color: rgb(0, 0, 0); font-size: 16px; font-family: arial,helvetica,sans-serif; background-color: transparent; font-style: normal;">If the prop does not exists it gets created in the process. <br></div><div class="yui_3_7_2_20_1356003884620_48" style="color: rgb(0, 0, 0); font-size: 16px; font-family: arial,helvetica,sans-serif; background-color: transparent; font-style: normal;"><br></div><div class="yui_3_7_2_20_1356003884620_48" style="color: rgb(0, 0, 0); font-size: 16px; font-family:
 arial,helvetica,sans-serif; background-color: transparent; font-style: normal;">in second case the history is restored when the user clicks the button.</div><div class="yui_3_7_2_20_1356003884620_48" style="color: rgb(0, 0, 0); font-size: 16px; font-family: arial,helvetica,sans-serif; background-color: transparent; font-style: normal;"><br></div><div class="yui_3_7_2_20_1356003884620_48" style="color: rgb(0, 0, 0); font-size: 16px; font-family: arial,helvetica,sans-serif; background-color: transparent; font-style: normal;">In any cases there is no chance that the addon would access non existant properties</div><div class="yui_3_7_2_20_1356003884620_48" style="color: rgb(0, 0, 0); font-size: 16px; font-family: arial,helvetica,sans-serif; background-color: transparent; font-style: normal;">because I like to leave nothing to chance ;)<br></div><div class="yui_3_7_2_20_1356003884620_48" style="color: rgb(0, 0, 0); font-size: 16px; font-family:
 arial,helvetica,sans-serif; background-color: transparent; font-style: normal;"><br></div><div class="yui_3_7_2_20_1356003884620_48" style="color: rgb(0, 0, 0); font-size: 16px; font-family: arial,helvetica,sans-serif; background-color: transparent; font-style: normal;">unless you try to tell me something else here that I dont understand</div><div style="color: rgb(0, 0, 0); font-size: 16px; font-family: arial,helvetica,sans-serif; background-color: transparent; font-style: normal;">or I missed a possible scenario . I am all ears :)<br></div><div><br></div>  <div style="font-family: arial, helvetica, sans-serif; font-size: 12pt;"> <div style="font-family: times new roman, new york, times, serif; font-size: 12pt;"> <div dir="ltr"> <font face="Arial" size="2"> <hr size="1">  <b><span style="font-weight:bold;">From:</span></b> Campbell Barton <ideasman42@gmail.com><br> <b><span style="font-weight: bold;">To:</span></b> dimitris chloupis
 <thekilon@yahoo.co.uk>; Blender Foundation Python list <bf-python@blender.org> <br> <b><span style="font-weight: bold;">Sent:</span></b> Thursday, 20 December 2012, 14:33<br> <b><span style="font-weight: bold;">Subject:</span></b> Re: [Bf-python] Addon's can no longer access context on activation.<br> </font> </div> <br>On Thu, Dec 20, 2012 at 12:09 PM, dimitris chloupis<br><<a ymailto="mailto:thekilon@yahoo.co.uk" 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 ymailto="mailto:ideasman42@gmail.com" href="mailto:ideasman42@gmail.com">ideasman42@gmail.com</a>><br>> To: Blender Foundation Python list <<a ymailto="mailto:bf-python@blender.org" href="mailto:bf-python@blender.org">bf-python@blender.org</a>>; bf-blender<br>> developers <<a ymailto="mailto:bf-committers@blender.org"
 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>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><br>-- <br>- Campbell<br><br><br> </div> </div>  </div></body></html>