close
Warning:
Can't synchronize with repository "(default)" (Unsupported version control system "svn": No module named svn). Look in the Trac log for more information.
- Timestamp:
-
Jul 15, 2008, 7:45:54 PM (16 years ago)
- Author:
-
cmlenz
- Comment:
-
Document package data conventions
Legend:
- Unmodified
- Added
- Removed
- Modified
-
v6
|
v7
|
|
51 | 51 | See ConfigOptions for information on the configuration options that are available by default, although you can of course always add your own. |
52 | 52 | |
| 53 | == Package Data Conventions == |
| 54 | |
| 55 | An application can easily avoid explicit configuration of things like the template and locale directories or URL routing by sticking to a directory layout convention that puts these resources in standard paths inside the application package. |
| 56 | |
| 57 | The prerequisite for this to work is to specify a class variable called `package` on the `Application` subclass, which must be the package name as string. For example: |
| 58 | |
| 59 | {{{ |
| 60 | #!pycon |
| 61 | >>> from diva.core import Application |
| 62 | >>> |
| 63 | >>> class MyApp(Application): |
| 64 | ... package = 'mypkg' |
| 65 | }}} |
| 66 | |
| 67 | With that class variable set, templates, PO/MO translation catalogs, and the routing configuration file are expected in the following directories: |
| 68 | |
| 69 | * `mypkg/conf/routing.cfg` |
| 70 | * `mypkg/locale` (with subdirectories of the form `[locale]/LC_MESSAGES`) |
| 71 | * `mypkg/templates` |
| 72 | |
| 73 | Of course these defaults can be overridden by setting the equivalent attributes on the `Application` class, or by specifying them via the constructor. |
| 74 | |
53 | 75 | == Application Context Variables == |
54 | 76 | |