本文整理匯總了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})