在我的keystone中间件中,我尝试按名称调用赋值函数getproject。在
我试图通过使用依赖注入来实现这一点,但是在调试日志中看到以下错误:
AttributeError: 'ProjectsByDemand' object has no attribute 'assignment_api'
参见以下代码:
from keystone.openstack.common import log as logging
from keystone.common import dependency
from keystone import config
from keystone import exception
from keystone.common import cache
from keystone.common import wsgi
@dependency.requires('assignment_api')
class ProjectsByDemand(wsgi.Middleware):
def __init__(self, app, conf):
self.conf = conf
self.app = app
self.internal_l = ['admin','neutron','glance','cinder','nova']
self.log = logging.getLogger(__name__)
.
.
.
def process_request(self, environ, start_response):
auth = self.get_username(environ)
if auth is not None:
if auth[0] is not self.internal_l:
self.log.debug('middleware-debug: Authenticating with: %s' % (auth[0]) )
project_ref = self.assignment_api.get_project_by_name(username, "default")
self.log.debug("middleware-debug: Project ref is: %s", project_ref)
return self.app(environ, start_response)
知道少了什么吗?在
您混合了制表符和空格,还弄错了缩进请尝试用
python -tt
运行脚本来检查。在相关问题 更多 >
编程相关推荐