Using Python to create a popup that changes an object based on the input
Use an update method on a property.

Give that whole "athing" thing away. You CANNOT use draw methods to run code to update objects. (The you cannot modify blenddata in this state error) 

You can define a button to click that calls an operator, or a property that when changed runs an update. .. which I believe is what you want update method on properties Example below, on changing my_bool if True will call the athing(self, context) method. self will be a reference tot the operator.

import bpy
class DialogOperator(bpy.types.Operator):
    bl_idname = "object.dialog_operator"
    bl_label = "Simple Dialog Operator"

    def athing(self, context):
        if self.my_bool:
            bpy.ops.object.mode_set(mode = 'EDIT')  
            bpy.ops.mesh.select_all(action='SELECT')
            bpy.ops.mesh.subdivide(smoothness=0)
        return None

    my_float = bpy.props.FloatProperty(name="Some Floating Point")
    my_bool = bpy.props.BoolProperty(name="Toggle Option", update=athing)
    my_string = bpy.props.StringProperty(name="String Value")

    def execute(self, context):
        message = "Popup Values: %f, %d, '%s'" % \
            (self.my_float, self.my_bool, self.my_string)
        self.report({'INFO'}, message)
        return {'FINISHED'}

    def check(self, context):
        return True

    def draw(self, context):
        layout = self.layout
        layout.prop(self, "my_bool")


    def invoke(self, context, event):
        wm = context.window_manager
        return wm.invoke_props_dialog(self)

bpy.utils.register_class(DialogOperator)
# test call
bpy.ops.object.dialog_operator('INVOKE_DEFAULT')