1
# ##### BEGIN GPL LICENSE BLOCK #####
3
# This program is free software; you can redistribute it and/or
4
# modify it under the terms of the GNU General Public License
5
# as published by the Free Software Foundation; either version 2
6
# of the License, or (at your option) any later version.
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
# GNU General Public License for more details.
13
# You should have received a copy of the GNU General Public License
14
# along with this program; if not, write to the Free Software Foundation,
15
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
# ##### END GPL LICENSE BLOCK #####
22
This module contains RestrictBlend context manager.
32
class _RestrictContext():
34
_real_data = _bpy.data
35
# safe, the pointer never changes
36
_real_pref = _bpy.context.user_preferences
39
def window_manager(self):
40
return self._real_data.window_managers[0]
43
def user_preferences(self):
44
return self._real_pref
47
class _RestrictData():
51
_context_restrict = _RestrictContext()
52
_data_restrict = _RestrictData()
55
class RestrictBlend():
56
__slots__ = ("context", "data")
60
self.context = _bpy.context
61
_bpy.data = _data_restrict
62
_bpy.context = _context_restrict
64
def __exit__(self, type, value, traceback):
66
_bpy.context = self.context