| | 1 | = Custom Tables = |
| | 2 | |
| | 3 | Templates can define their own custom nodels without needing to touch the core code. tablename should be "custom_%s" % resourcename |
| | 4 | |
| | 5 | Add a dict (or !OrderedDict if want to manage dependency order), like: |
| | 6 | {{{ |
| | 7 | settings.models = {tablename: function} |
| | 8 | }}} |
| | 9 | |
| | 10 | The called function would look something like: |
| | 11 | {{{ |
| | 12 | def define_custom_test(db, tablename): |
| | 13 | |
| | 14 | from gluon import Field |
| | 15 | |
| | 16 | table = db.define_table(tablename, |
| | 17 | Field("test"), |
| | 18 | ) |
| | 19 | |
| | 20 | return table |
| | 21 | }}} |
| | 22 | |
| | 23 | If wanting to have a REST controller for them, then also add "custom" to settings.modules and add an entry to the rest_controllers: |
| | 24 | {{{ |
| | 25 | settings.base.rest_controllers = {("custom", resourcename): ("custom", resourcename)} |
| | 26 | }}} |
| | 27 | |