1) create a file web2py/applications/myapp/app.conf
2) and in the file put something like:
dict(
name = 'myapp',
version = 1,
built_date = datetime.date(2012,4,8),
comments = '',
)
3( than make a controller:
def edit():
import os
filename = os.path.join(request.folder,'app.conf')
form = SQLFORM.smartdictform(session,'config',filename)
return dict(form=form)
the controller will create a form to edit the file, will guess the types of vars from current values, will cache the dict in session. The idea is that it could be used to configure apps. If a filename is not specified, it will only change the vars in the session['config'] dictionary.
what do you think?
Massimo
Interesting. I'm imagining the same thing stored as a field in auth_user.
--
mail from:GoogleGroups "web2py-developers" mailing list
make speech: web2py-d...@googlegroups.com
unsubscribe: web2py-develop...@googlegroups.com
details : http://groups.google.com/group/web2py-developers
the project: http://code.google.com/p/web2py/
official : http://www.web2py.com/
One case could be when you install a new app. The administrator could use this function to edit the configuration file (if any, via admin or via appadmin). How the application uses the file is not discussed in the example.
Another case is when an app need a edit interface for a dict. The dict can be stored on file but does not have to. It can be stored in a session variable but does not have to.
One case could be when you install a new app. The administrator could use this function to edit the configuration file (if any, via admin or via appadmin). How the application uses the file is not discussed in the example.But how would the app then use the configuration file? I assume we wouldn't want to read it on every request. Do you read it once and cache in ram? Is that better than just using a module file? Would it be better to include more complete app configuration functionality?
Another case is when an app need a edit interface for a dict. The dict can be stored on file but does not have to. It can be stored in a session variable but does not have to.What are some use cases for this?
Anthony
Looks like a good idea.
For a small pet project of mine I could use something as follows:
-> generate form + set default values from an existing .ini file
-> save the modified form under a unique name, which then is associated
to the currently logged in user
* Will the smartdictform modify the file on the server?
Or just cache the resuting dict ?
* Could smartdictform be used with a dict not coming from a file?
Best regards,
Stefaan.
if not session.config: session.config=eval(open('app.conf').read()) # assume the data is stored as a dict.