AppConfig and % interpolation

瀏覽次數:39 次
跳到第一則未讀訊息

Ivan

未讀,
2016年9月27日 上午9:43:242016/9/27
收件者:web2py-users
If the .ini file contains an option with a % (eg a password), the AppConfig class raise an InterpolationSyntaxError exception.

Niphlod

未讀,
2016年9月27日 上午9:52:402016/9/27
收件者:web2py-users
and it's correct that it does, as it can work with json with doesn't have any interpolation facilities. if you want to interpolate, for the moment, use your app's code.

Ivan

未讀,
2016年9月27日 上午10:15:452016/9/27
收件者:web2py-users
I don't want to interpolate.
I have an option with a % inside and the AppConfig raises an exception.

Niphlod

未讀,
2016年9月27日 上午11:30:212016/9/27
收件者:web2py-users
hum. did you try excaping the % with % , which means basically having %% instead of % ?

Ivan

未讀,
2016年9月27日 中午12:56:102016/9/27
收件者:web2py-users
escaping % with % solves the problem
however I think it would be better to not force the user to escape each % in a .ini file

the exception comes from the ConfigParser python module (more precisely SafeConfigParser) used in AppConfig
maybe a better solution is to use RawConfigParser that doesn't interpolate at all

Niphlod

未讀,
2016年9月27日 下午3:10:162016/9/27
收件者:web2py-users
yep, ATM I'd go for rawconfigparser but someone asked for interpolation .... so we have two distinct "paths" . Just need to rule out one ^_^
回覆所有人
回覆作者
轉寄
0 則新訊息