PageRenderTime 37ms CodeModel.GetById 23ms RepoModel.GetById 1ms app.codeStats 0ms

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