简体   繁体   English

无法在Google App Engine中为python应用程序创建配置文件

[英]Impossible to create a configuration file for an python application inside Google App Engine

I try to create a configuration file, where I can store constants. 我尝试创建一个配置文件,可以在其中存储常量。

Whenever I try with ConfigParser, I get an error 每当我尝试使用ConfigParser时,都会出现错误

Traceback (most recent call last):
  File "/home/baun/google_appengine/google/appengine/ext/webapp        /__init__.py", line 511, in __call__
    handler.get(*groups)
  File "/home/baun/workspace/octopuscloud/s3/S3.py", line 138, in get
    test = parser.get('bucket', 'bucketname')
  File "/usr/lib/python2.5/ConfigParser.py", line 511, in get
    raise NoSectionError(section)
NoSectionError: No section: 'bucket'

simple.cfg: simple.cfg:

[bucket]
bucketname: 'octopus_storage'

s3.py: s3.py:

...
from ConfigParser import SafeConfigParser

parser = SafeConfigParser()
parser.read('simple.cfg')

...

# Get values from the config file
test = parser.get('bucket', 'bucketname')
...

How can I fix this? 我怎样才能解决这个问题?

=============================== ===============================

The problem is fixed. 问题是固定的。 The code was correct, but simple.cfg was in the wrong directory. 代码是正确的,但simple.cfg在错误的目录中。

[bucket]
bucketname= octopus_storage

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM