8. Some final remarks

To close this manual, I would like to give a few words of advice on how I think Draco should be used. Draco has intentionally been kept flexible, because I realize that no single programming paradigm can be right for all situations. However, this does not propagate software anarchy in the spirit of PERL's ``There's more than one way to do it''. In this respect, Draco's motto is closer to Python's ``There should be one - and preferably only one - obvious way to do it.''

Below are some rules of thumb that I have found useful. This is by no means authorative or anything, just some well-intentioned sharing of ideas.

  1. Use files and directories to structure your application:

  2. Put as little code as possible in the templates. Ideally, templates only contain code to format end results. All processing should be done in a handler.

  3. Make liberal use of the session and other namespaces. Use the methods update() and clear() to transfer and clear entire namespaces with a single function.

  4. Use Draco's Form class to parse form input. When an error occurs, put the unprocessed variables in the session using a single update() call. Use an http redirect to go back to the form and there, register a FormRewriter instance to plug back the variables in the form.

  5. Put files that are related to your web application but should not be public under the document root in a __private__ directory. This way you keep your application nicely in a single place.

  6. Use the builtin task scheduler to perform expiry tasks. If exact timing is important, use cron to fire it up.

  7. Use the childStart() event to register global variables that you are going to use in your web application. Use requestStart() and configChanged() to keep these variables up to date.