appconfig local vs api provide by another web2py app

30 views
Skip to first unread message

黄祥

unread,
Apr 17, 2018, 11:04:01 PM4/17/18
to web2py-users
just curious, is there any performance difference while storing appconfig in local (private/appconfig.ini) or by using json api that provide by another web2py app?
objective
to create central configuration webapp between web2py app

e.g. for json api that provide by another web2py app
applications/appconfig
applications/a0
applications/b0

so models/db.py in applications a0 and b0 must have something like
models/db.py
app_id = 1 #different between app a0 and b0
import requests
from requests.auth import HTTPBasicAuth 
auth = HTTPBasicAuth('admin', 'password')
r = requests.get("http://127.0.0.1:8000/appconfig/api/args_rows_as_json/%s" % (app_id), auth = auth).json()
db = DAL(r[0]['db_uri'], pool_size = r[0]['pool_size'], migrate = r[0]['migrate'] )

any idea, or comments ?

best regards,
stifan

Anthony

unread,
Apr 18, 2018, 10:12:22 AM4/18/18
to web2py-users
Why not:

myconf = AppConfig(configFile=os.path.join(request.folder, '..', 'appconfig', 'private', 'app0.json'))

Making an HTTP request will add some overhead, though it shouldn't matter as long as you leave the default reload=False -- that way, it will only load the config data from the source once and keep it cached for subsequent requests.

Anthony

黄祥

unread,
Apr 18, 2018, 5:42:40 PM4/18/18
to web2py-users
On Wednesday, April 18, 2018 at 9:12:22 PM UTC+7, Anthony wrote:
Why not:

myconf = AppConfig(configFile=os.path.join(request.folder, '..', 'appconfig', 'private', 'app0.json'))

Making an HTTP request will add some overhead, though it shouldn't matter as long as you leave the default reload=False -- that way, it will only load the config data from the source once and keep it cached for subsequent requests.

good point, thanks anthony, like i expect before about http request.
from your example it's base on json, is it same or different with *.ini file like the web2py scaffolding welcome app, i mean in terms of speed or performance ?
reason why plan to use json, because want to store configuration in database and make api that produce json file to another web2py app

any advise?

thx and best regards,
stifan

Anthony

unread,
Apr 18, 2018, 8:02:21 PM4/18/18
to web2py-users
good point, thanks anthony, like i expect before about http request. 
from your example it's base on json, is it same or different with *.ini file like the web2py scaffolding welcome app, i mean in terms of speed or performance ?
reason why plan to use json, because want to store configuration in database and make api that produce json file to another web2py app

Sorry, I misunderstood -- I thought you wanted to use AppConfig, but just store the configuration files in a central place. If you want to store the configuration in the database, you can either keep what you've got or just directly create a DAL instance in each app to connect to the database that stores the configuration data. Either way, though, you should cache the configuration data within each app and only make the HTTP request or DAL connection on the initial request in order to populate the cache.

Anthony
Reply all
Reply to author
Forward
0 new messages