コード例 #1
0
def main():

	from class_macro import Macros
	from widget_plugins import WidgetPlugins
	from widget_macro import WidgetMacros
	from class_plugins import Plugins

	plugin_id = request.shared_variables["plugin_id"]
	plugin = Plugins.get_by_id(plugin_id)

	macros = Macros()
	macros.name 		= "config"
	macros.class_name	= ""
	macros.timer_guid 	= ""
	macros.is_button_macros = "1"
	macros.on_board 	= "1"
	macros.description 	= "config macro"
	macros.plugin_guid = plugin.guid
	macros.save()

	plugin = Plugins.get_by_id(plugin_id)
	macros = plugin.get_macros()

	widget_macros = WidgetMacros()
	widget_macros.set_data(macros)
	widget_macros.render(self.datatable_macros)

	self.button_create_config.visible = "0"
	self.button_config.visible = "1"
コード例 #2
0
    if "formbutton_import" in request.arguments:
        if request.arguments.get("uploader", "", castto=Attachment):
            file = request.arguments.get("uploader", "", castto=Attachment)
            xml_data = file.handler.read()
            dom = parseString(xml_data)
            node = XMLMacros(dom)

            for child in node.childs:
                child = XMLMacros(child)
                if child.name and child.source:
                    macros = Macros()
                    macros.name = child.name
                    macros.code = child.source
                    macros.class_name = child.class_name
                    macros.is_button_macros = child.is_button
                    macros.on_board = child.on_board

                    picture_name = ""
                    macros.macros_picture = ""
                    if child.macros_picture:
                        macros.macros_picture = picture_name = str(uuid4())
                        application.storage.write(
                            picture_name,
                            base64.b64decode(child.macros_picture))

                    macros.save()
                else:
                    self.growl.title = lang["error"]
                    self.growl.text = lang["xml_not_correctr_error"]
                    self.growl.visible = "1"