本文整理汇总了Python中importer.Importer.get方法的典型用法代码示例。如果您正苦于以下问题:Python Importer.get方法的具体用法?Python Importer.get怎么用?Python Importer.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类importer.Importer
的用法示例。
在下文中一共展示了Importer.get方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: dispatch
# 需要导入模块: from importer import Importer [as 别名]
# 或者: from importer.Importer import get [as 别名]
def dispatch(request, *args, **kw):
"""
Perform somes checks, call the importer, and returns.
Arguments of the method MUST be passed as pickle in POST data.
This method is not meant to be called directly with a web browser.
"""
base = kw.pop('base')
modules = kw.pop('modules')
# Create Importer() if not already present in session.
imp = Importer()
full_path = base.replace('/', '.') + '.' + modules.replace('/', '.')
mod, met = full_path.rsplit('.', 1)
module = __import__(mod, {}, {}, [''])
callee = getattr(module, met)
if not hasattr(callee, '__exportable__'):
logger.debug("Exporter: method not exportable: " + full_path)
return (200, Exception("Method not exportable"))
# GET request ?
# Only method call without args or attributes. (from a webbrowser)
if request.method == 'GET':
try:
return (200, imp.get(mod, met))
except ImporterError, e:
logger.debug("Exporter: Catched: " + e.traceback)
return (500, {'msg': e.msg, 'traceback': e.traceback})