[Bf-extensions-cvs] [3ccfa376] master: Castle: fix register, reload error with module

lijenstina noreply at git.blender.org
Wed Jun 14 06:54:34 CEST 2017


Commit: 3ccfa3769a6c978e166de98cb15fd86e5f0a6fc7
Author: lijenstina
Date:   Wed Jun 14 06:53:33 2017 +0200
Branches: master
https://developer.blender.org/rBAC3ccfa3769a6c978e166de98cb15fd86e5f0a6fc7

Castle: fix register, reload error with module

Bumped version to 0.0.4
Part of the T51547:
Solve the key registration / reload issues related to the
module definining no classes

===================================================================

M	add_mesh_castle/__init__.py

===================================================================

diff --git a/add_mesh_castle/__init__.py b/add_mesh_castle/__init__.py
index f7ddb4bd..13eaa461 100644
--- a/add_mesh_castle/__init__.py
+++ b/add_mesh_castle/__init__.py
@@ -1,4 +1,4 @@
-################################################################################
+# #########################################################################
 # ***** BEGIN GPL LICENSE BLOCK *****
 #
 # This is free software under the terms of the GNU General Public License
@@ -15,46 +15,61 @@ Create block wall "Castle" style with extended features.
 '''
 #
 # This collection of scripts has been contributed to by many authors,
-#  see documentation "Credits" for details.
+# see documentation "Credits" for details.
 #
-################################################################################
+# #########################################################################
 
 bl_info = {
     "name": "Castle",
-    "description": "Create a Castle.",
-    "author": "See documentation Credits.",
-    "version": (0, 0, 3),
+    "description": "Create a Castle",
+    "author": "See documentation Credits",
+    "version": (0, 0, 4),
     "blender": (2, 75, 0),
     "location": "View3D > Add > Mesh > Castle",
-    "warning": "WIP - Frequent changes for known issues and enhancements.",
-    "support": "TESTING",  # OFFICIAL, COMMUNITY, TESTING.
-    "wiki_url": "http://wiki.blender.org/index.php/Extensions:2.6/Py/Scripts/Add_Mesh/Castle",
+    "warning": "WIP - Frequent changes for known issues and enhancements",
+    "support": "TESTING",
+    "wiki_url": "https://wiki.blender.org/index.php/Extensions:2.6"
+                "/Py/Scripts/Add_Mesh/Castle",
     "tracker_url": "https://developer.blender.org/T45596",
     "category": "Add Mesh"
 }
 
 
-from . import Castle
+if "bpy" in locals():
+    import importlib
+    importlib.reload(Castle)
+else:
+    from . import Castle
 
 import bpy
-
-# Menu
+from .Castle import (
+        add_castle,
+        )
 
 
+# Menu
 def menu_func_castle(self, context):
-    self.layout.operator(Castle.add_castle.bl_idname,
-                         text="Castle",
+    self.layout.operator(add_castle.bl_idname, text="Castle",
                          icon="PLUGIN")
 
 
+# This is needed to prevent the module defines no classes error
+classes = (
+    add_castle,
+    )
+
+
 def register():
-    bpy.utils.register_module(__name__)
+    for cls in classes:
+        bpy.utils.register_class(cls)
     bpy.types.INFO_MT_mesh_add.append(menu_func_castle)
 
 
 def unregister():
-    bpy.utils.unregister_module(__name__)
+    for cls in classes:
+        bpy.utils.unregister_class(cls)
     bpy.types.INFO_MT_mesh_add.remove(menu_func_castle)
 
+
 if __name__ == "__main__":
     register()



More information about the Bf-extensions-cvs mailing list