Python 使用PasteDeploy管道的金字塔脚本不工作
你好,这是我的新麻烦。。。 我正在使用pyramid,我创建了一个脚本,用初始数据填充数据库 我有一个使用这种语法的PasteDeploy配置文件(比如development.ini)Python 使用PasteDeploy管道的金字塔脚本不工作,python,configuration,pyramid,paster,Python,Configuration,Pyramid,Paster,你好,这是我的新麻烦。。。 我正在使用pyramid,我创建了一个脚本,用初始数据填充数据库 我有一个使用这种语法的PasteDeploy配置文件(比如development.ini) ### # app configuration # http://docs.pylonsproject.org/projects/pyramid/en/latest/narr/environment.html ### [app:shop_eshop] use = egg:shop_eshop pyramid.
###
# app configuration
# http://docs.pylonsproject.org/projects/pyramid/en/latest/narr/environment.html
###
[app:shop_eshop]
use = egg:shop_eshop
pyramid.reload_templates = true
pyramid.debug_authorization = false
pyramid.debug_notfound = false
pyramid.debug_routematch = false
pyramid.default_locale_name = en
pyramid.includes =
pyramid_debugtoolbar
pyramid_tm
sqlalchemy.url = postgresql://eshop_db_user:testtest@localhost:5432/eshop_db
jinja2.directories = eshop:templates
ziggurat_foundations.model_locations.User = auth.models:User
# SESSION_BEAKER
session.type = file
session.data_dir = %(here)s/data/sessions/data
session.lock_dir = %(here)s/data/sessions/lock
session.key = s_key
session.secret = ...FBIRootAccessPW...
session.cookie_on_exception = true
[filter:fanstatic]
use = egg:fanstatic#fanstatic
recompute_hashes = false
versioning = true
bottom = True
publisher_signature = assets
compile = true
#in development
debug = true
[pipeline:main]
pipeline = fanstatic eshop
[server:main]
use = egg:waitress#main
host = 0.0.0.0
port = 6543
###
# logging configuration
# http://docs.pylonsproject.org/projects/pyramid/en/latest/narr/logging.html
###
[loggers]
keys = root, shop_eshop, sqlalchemy
[handlers]
keys = console
[formatters]
keys = generic
[logger_root]
level = INFO
handlers = console
[logger_shop_eshop]
level = DEBUG
handlers =
qualname = shop_eshop
[logger_sqlalchemy]
level = INFO
handlers =
qualname = sqlalchemy.engine
[handler_console]
class = StreamHandler
args = (sys.stderr,)
level = NOTSET
formatter = generic
[formatter_generic]
format = %(asctime)s %(levelname)-5.5s [%(name)s][%(threadName)s] %(message)s
我的脚本包含生成错误的这段代码
def main(argv=sys.argv):
if len(argv) < 2:
usage(argv)
config_uri = argv[1]
options = parse_vars(argv[2:])
setup_logging(config_uri)
settings = get_appsettings(config_uri, options=options)
engine = engine_from_config(settings, 'sqlalchemy.')
DBSession.configure(bind=engine)
with transaction.manager:
create_groups()
create_users()
如果我移除了管道,一切正常,我就找不到读取管道的方法
这是我的错误
Traceback (most recent call last):
File "/srv/michael/e_shop/env/bin/fill_e_shop_db", line 9, in <module>
load_entry_point('e_shop==0.0', 'console_scripts', 'fill_e_shop_db')()
File "/srv/michael/e_shop/e_shop/e_shop/scripts/filldb.py", line 98, in main
engine = engine_from_config(settings, 'sqlalchemy.')
File "build/bdist.linux-x86_64/egg/sqlalchemy/engine/__init__.py", line 350, in engine_from_config
KeyError: 'url'
回溯(最近一次呼叫最后一次):
文件“/srv/michael/e_shop/env/bin/fill_e_shop_db”,第9行,在
加载入口点('e_shop==0.0','console_scripts','fill_e_shop_db')()
文件“/srv/michael/e_shop/e_shop/e_shop/scripts/filldb.py”,第98行,主文件
engine=engine\u从配置(设置“sqlalchemy.”)
文件“build/bdist.linux-x86\u 64/egg/sqlalchemy/engine/\uuuuu init\uuuuuuuu.py”,第350行,位于来自\u config的引擎\u中
KeyError:“url”
有什么建议吗?谢谢大家! get\u appsettings()
正在加载ini文件的main
部分的设置,除非另有规定。该部分中显然没有设置。如果要加载特定部分的设置,只需使用
指定即可。例如,您应该能够立即运行您的程序并获得您想要的结果:
myprog development.ini#shop_eshop
get\u appsettings()
正在加载ini文件的main
部分的设置,除非另有规定。该部分中显然没有设置。如果要加载特定部分的设置,只需使用
指定即可。例如,您应该能够立即运行您的程序并获得您想要的结果:
myprog development.ini#shop_eshop
你能把你得到的错误包括在内吗?是的。。我忘了提那个错误。。抱歉..看起来最简单的修复方法是将sqlalchemy.url放在ini的全局部分,但问题是变量设置可能不是您所期望的。打印设置并查看其中的内容。是否可以包括您收到的错误?是。。我忘了提那个错误。。抱歉..看起来最简单的修复方法是将sqlalchemy.url放在ini的全局部分,但问题是变量设置可能不是您所期望的。打印设置并查看其中的内容。