fix for various python bugs and remove unused var.
[blender.git] / release / scripts / templates / operator_simple.py
index c62d3720d96ae261d4ab0b8f43924ad81f2d14a8..8348c7a95b13a17b0dd42210cc6d5de6e8e2e863 100644 (file)
@@ -1,21 +1,35 @@
+import bpy
+
 
 def main(context):
     for ob in context.scene.objects:
         print(ob)
 
+
 class SimpleOperator(bpy.types.Operator):
-    ''''''
+    '''Tooltip'''
     bl_idname = "object.simple_operator"
     bl_label = "Simple Object Operator"
 
-    def poll(self, context):
+    @classmethod
+    def poll(cls, context):
         return context.active_object != None
 
     def execute(self, context):
         main(context)
         return {'FINISHED'}
 
-bpy.types.register(SimpleOperator)
+
+def register():
+    bpy.utils.register_class(SimpleOperator)
+
+
+def unregister():
+    bpy.utils.unregister_class(SimpleOperator)
+
 
 if __name__ == "__main__":
+    register()
+
+    # test call
     bpy.ops.object.simple_operator()