本文整理汇总了Python中mforms.Utilities.show_warning方法的典型用法代码示例。如果您正苦于以下问题:Python Utilities.show_warning方法的具体用法?Python Utilities.show_warning怎么用?Python Utilities.show_warning使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mforms.Utilities
的用法示例。
在下文中一共展示了Utilities.show_warning方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: validate_setting
# 需要导入模块: from mforms import Utilities [as 别名]
# 或者: from mforms.Utilities import show_warning [as 别名]
def validate_setting(settings, option, norm_cb, msg):
if settings.has_key(option):
if norm_cb is not None:
norm_cb(settings, option)
else:
if msg is not None:
Utilities.show_warning("WB Administrator", msg, "OK", "", "")
norm_cb(settings, option)
示例2: GenerateDrupalSchema
# 需要导入模块: from mforms import Utilities [as 别名]
# 或者: from mforms.Utilities import show_warning [as 别名]
def GenerateDrupalSchema(catalog):
output = ''
# Add all schema.
for schema in catalog.schemata :
hook_created = False
comment_replace = {}
# Collect the comment replacement strings.
for table in schema.tables :
comment_replace[(' %s table ' % table.name)] = ' {%s} table ' % table.name
comment_replace[(' %s table.' % table.name)] = ' {%s} table.' % table.name
for column in table.columns :
comment_replace[(' %s.%s ' % (table.name, column.name))] = ' {%s}.%s ' % (table.name, column.name)
comment_replace[(' %s.%s.' % (table.name, column.name))] = ' {%s}.%s.' % (table.name, column.name)
# Add all tables.
for table in schema.tables :
if len(table.columns) > 0 :
if not hook_created :
''' Create the hook '''
if len(output) > 0 :
output += "\n\n"
output += "/**\n"
output += " * Implements hook_schema().\n"
output += " */\n"
output += "function %s_schema() {\n" % re.sub(r'([^a-z0-9_]+|^[^a-z]+)', '', schema.name.lower().replace(' ', '_'))
output += " $schema = array();\n\n"
hook_created = True
''' Add the table '''
output += generateTableDefinition(table, comment_replace)
output += "\n"
if hook_created :
''' Close the hook '''
output += " return $schema;\n"
output += '}'
if len(output) > 0 :
# Should the output be copied to the clipboard?
answer = Utilities.show_message('Copy to clipboard?', "Would you like to copy the schema to your clipboard?\nIt can also be viewed in the output window.", 'Yes', 'No', '')
if answer == mforms.ResultOk :
grt.modules.Workbench.copyToClipboard(output)
# MySQL specific fields warning.
if "'mysql_type' => '" in output :
Utilities.show_message('MySQL specific fields used', 'Note that the schema definition contains MySQL specific fields!', 'OK', '', '')
print output
else :
Utilities.show_warning('No valid tables found', 'The schema was not generated because no valid tables were found.', 'OK', '', '')
return 0
示例3: get_db_connection
# 需要导入模块: from mforms import Utilities [as 别名]
# 或者: from mforms.Utilities import show_warning [as 别名]
def get_db_connection(server_instance_settings):
if server_instance_settings.connection:
db_connection = MySQLConnection(server_instance_settings.connection)
ignore_error = False
error_location = None
the_error = None
try:
db_connection.connect()
except MySQLError, exc:
# errors that probably just mean the server is down can be ignored (ex 2013)
# errors from incorrect connect parameters should raise an exception
# ex 1045: bad password
if exc.code in (1045,):
raise exc
elif exc.code in (2013,):
ignore_error = True
error_location = exc.location
the_error = str(exc)
if not ignore_error:
if Utilities.show_warning("Could not connect to MySQL Server at %s" % error_location,
"%s\nYou can continue but some functionality may be unavailable." % the_error,
"Continue Anyway", "Cancel", "") != mforms.ResultOk:
raise MySQLError("", 0, "")
return db_connection
示例4: in
# 需要导入模块: from mforms import Utilities [as 别名]
# 或者: from mforms.Utilities import show_warning [as 别名]
# ex 1045: bad password
if exc.code in (1045,):
raise exc
elif exc.code in (2013,):
ignore_error = True
error_location = exc.location
the_error = str(exc)
if not ignore_error:
if Utilities.show_warning("Could not connect to MySQL Server at %s" % error_location,
"%s\nYou can continue but some functionality may be unavailable." % the_error,
"Continue Anyway", "Cancel", "") != mforms.ResultOk:
raise MySQLError("", 0, "")
return db_connection
else:
Utilities.show_warning("WB Admin", "Server instance has no database connection specified.\nSome functionality will not be available.", "OK", "", "")
return None
def weakcb(object, cbname):
"""Create a callback that holds a weak reference to the object. When passing a callback
for mforms, use this to create a ref to it and prevent circular references that are never freed.
"""
def call(ref, cbname):
callback = getattr(ref(), cbname, None)
if callback is None:
print "Object has no callback %s"%cbname