Skip to content

Latest commit

 

History

History
78 lines (53 loc) · 1.88 KB

sample7.md

File metadata and controls

78 lines (53 loc) · 1.88 KB

Web App Server

User config file

Create __init__.py :

#
# An web server module
#

import json
from appmodule import AppModule

app = AppModule()

def getApp():
    return app

@app.route("/")
@app.view("index.tpl")
def _():
    """
        Default view
    """
    title = "Index of {}".format(app.module_name)
    return dict(title = title, json = json)

Create index.tpl inside of view folder:

% include("header.tpl")

<h1>{{title}}</h1>

<p>userid = {{userid}}</p>
<p>module name = {{module_name}}</p>

<p>module config</p>
<pre>
{{json.dumps(module_config, indent=4, sort_keys=True)}} 
</pre>

<p>user config</p>
<pre>
{{json.dumps(user_config, indent=4, sort_keys=True)}} 
</pre>

% include("footer.tpl")

Create a JSON file named config.json in the module folder (where is __init__.py located) using the Application web config editor and template for Web Config Document.

Also create a JSON file named config_default_.json in the module folder using the Application web config editor and template for User Config Document.

If the server administrator did not enabled user config in module config you will see an empty user config and the editor for user config will not be available.

Edit config of module as administrator and enable user config, then edit config of user, made some changes and save it, then view module in browser.

When you open the user config editor, if there is no user config file, the template file config_default_.json will be copied as user config file.

You must be logged in to be able to edit user config file.

Because there is no security set on this sample application, anonymous users will be able to view index page, but user config will be empty and userid will be 0 (zero).