PageRenderTime 81ms CodeModel.GetById 40ms app.highlight 1ms RepoModel.GetById 39ms app.codeStats 0ms

/docs/deploymentconfig.txt

https://bitbucket.org/ianb/silverlining/
Plain Text | 84 lines | 58 code | 26 blank | 0 comment | 0 complexity | e922db8667da97c173d5c371f6e4f520 MD5 | raw file
 1Deployment Configuration
 2========================
 3
 4Sometimes applications require deployment-specific configuration.
 5Silver Lining has a few settings/tools to help with this.
 6
 7An application's configuration is just a directory that contains any
 8configuration file or files that are appropriate.  To deploy an
 9application with particular configuration, use::
10
11    $ silver update app-path/ --config config-path/
12
13This uploads ``config-path/`` and on the server
14``environ['SILVER_APP_CONFIG']`` will be set to this directory.  You
15can also use ``--config`` with ``silver serve`` to try out a
16configuration locally.
17
18If you upload configuration on a server it will stay on a server until
19you update again with ``--config``.
20
21app.ini configuration
22---------------------
23
24If you want to require configuration, you can place this in your
25``app.ini``::
26
27    config.required = true
28
29Also if you want to check the configuration before deploying an
30application, you can use::
31
32    config.checker = myapp.somemodule:checker
33
34Then ``myapp.somemodule`` will be imported, and
35``checker(config_dir)`` will be called.  It should raise an exception
36if there is an error with the configuration.
37
38You can also give a default configuration.  This is particularly
39useful during development.
40
41::
42
43    config.default = src/myapp/default-config/
44
45Config Templates
46----------------
47
48Lastly you can help people create configuration for your application
49using a config template.  To enable a template, use the setting::
50
51    config.template = src/myapp/config-template/
52
53This is a directory that will be copied when you run::
54
55    $ silver create-config app-path/ new-config-path/
56
57If you want to ask some questions, you can add a file in
58``src/myapp/config-template/template.ini`` and in it::
59
60    [variables]
61    title = The Title Of The Application
62    author = Your Name
63
64Each variable is a variable the user will be asked about, and the
65value is the description of the variable.  In the future probably
66other options for variables will be allowed, but this is all there is
67now.
68
69Then you need to make some files templates by adding the extension
70``.tmpl``, these will be `Tempita <http://pythonpaste.org/tempita/>`_
71templates.  So you can do something like create ``config.ini.tmpl``
72and put in::
73
74    [blog]
75    title = {{title}}
76    author = {{author}}
77
78Interactively Configured Applications
79-------------------------------------
80
81If you want to make a nice interactive configuration (similar to how
82WordPress works, for instance) then you don't want to use any of
83this.  Simply use ``service.files`` and put your configuration
84someplace like ``os.path.join(os.environ['CONFIG_FILES'], 'config')``