2

我正在尝试将我正在编写的 Python 金字塔应用程序从一台服务器移动到另一台服务器。我从源代码管理中检查了代码并运行 apython setup.py develop来准备环境,但是当我尝试运行时,pserve development.ini我得到以下回溯:

2013-02-27 20:38:20,269 INFO  [pyramid_scss][MainThread] adding asset path /home/pgrace/repos/Asterisk-WebApps/Cedar-Root/opt/cedar/cedar/assets/scss
Traceback (most recent call last):
  File "/home/pgrace/venvs/pyramid/bin/pserve", line 8, in <module>
    load_entry_point('pyramid==1.4', 'console_scripts', 'pserve')()
  File "/home/pgrace/venvs/pyramid/lib/python2.6/site-packages/pyramid/scripts/pserve.py", line 50, in main
    return command.run()
  File "/home/pgrace/venvs/pyramid/lib/python2.6/site-packages/pyramid/scripts/pserve.py", line 304, in run
    global_conf=vars)
  File "/home/pgrace/venvs/pyramid/lib/python2.6/site-packages/pyramid/scripts/pserve.py", line 328, in loadapp
    return loadapp(app_spec, name=name, relative_to=relative_to, **kw)
  File "/home/pgrace/venvs/pyramid/lib/python2.6/site-packages/paste/deploy/loadwsgi.py", line 247, in loadapp
    return loadobj(APP, uri, name=name, **kw)
  File "/home/pgrace/venvs/pyramid/lib/python2.6/site-packages/paste/deploy/loadwsgi.py", line 272, in loadobj
    return context.create()
  File "/home/pgrace/venvs/pyramid/lib/python2.6/site-packages/paste/deploy/loadwsgi.py", line 710, in create
    return self.object_type.invoke(self)
  File "/home/pgrace/venvs/pyramid/lib/python2.6/site-packages/paste/deploy/loadwsgi.py", line 146, in invoke
    return fix_call(context.object, context.global_conf, **context.local_conf)
  File "/home/pgrace/venvs/pyramid/lib/python2.6/site-packages/paste/deploy/util.py", line 56, in fix_call
    val = callable(*args, **kw)
  File "/home/pgrace/repos/Asterisk-WebApps/Cedar-Root/opt/cedar/cedar/__init__.py", line 18, in main
    config.include("pyramid_scss")
  File "/home/pgrace/venvs/pyramid/lib/python2.6/site-packages/pyramid/config/__init__.py", line 773, in include
    c(configurator)
  File "/home/pgrace/venvs/pyramid/lib/python2.6/site-packages/pyramid_scss/__init__.py", line 88, in includeme
    scss.LOAD_PATHS = ','.join([scss.LOAD_PATHS, ','.join(load_paths)])
AttributeError: 'module' object has no attribute 'LOAD_PATHS'

现在,我可以说问题出在 pyramid_scss,但据我所知,它引用的代码很好,就好像module该类不包含 LOAD_PATHS 指令一样。我试图弄清楚它指的是哪个模块,以便我可以追踪我是否缺少依赖项或其他东西。有谁知道我将如何确定module参考指向的位置,以便我可以检查该代码?

编辑:错误出现在includeme定义中,每当一个特定于金字塔的包被实例化时,它就会自动包含在我读过的内容中?也许?无论如何,它说 scss.LOAD_PATHS 不存在,是的,但是在任何一个pyramid_scsspyScss包中都没有 scss 类,这让我想知道是否还有其他一些正在后期绑定的类。

def includeme(config):
    load_paths, static_path = _get_import_paths(config.registry.settings)
    scss.LOAD_PATHS = ','.join([scss.LOAD_PATHS, ','.join(load_paths)])
    scss.STATIC_ROOT = static_path
    config.add_renderer('scss', renderer_factory)

pyScss 中的Scss类确实包含一个 LOAD_PATHS 指令,但我看不到对象 scss 绑定到 Scss 类定义的位置。我想知道def includeme上面是否缺少一些可能是答案的一部分,但随后它引出了一个问题——这在另一台机器上工作正常,为什么现在中断?还有一些东西我只是没有接受。

4

2 回答 2

3

通过检查scss包的代码,看起来LOAD_PATHS全局变量可能已从__init__.py移至config.py.

因此,如果您想尝试修复pyramid_scss应用程序,可以将第 88 行更改pyramid_scss/__init__.py为:

scss.config.LOAD_PATHS = ','.join([scss.config.LOAD_PATHS, ','.join(load_paths)])
于 2013-02-27T20:56:40.010 回答
2

最后一行告诉您哪个模块受到影响:

    scss.LOAD_PATHS = ','.join([scss.LOAD_PATHS, ','.join(load_paths)])
AttributeError: 'module' object has no attribute 'LOAD_PATHS'

所以scss模块没有LOAD_PATHS属性。

于 2013-02-27T20:48:05.623 回答