35 | | Note: you must have an {{{__init__.py}}} in your template folder for this to work (it can be empty). |
36 | | |
| 35 | Notes: |
| 36 | * You must have an {{{__init__.py}}} in your template folder for this to work (it can be empty). |
| 37 | * Unlike normal controllers, the scope this function is run in will start empty, so import what you need |
| 38 | * If a custom View template is passed in from the Template folder then this will need to be provided as a File not a String to work in compiled mode: |
| 39 | {{{ |
| 40 | import os |
| 41 | from gluon import current |
| 42 | from gluon.http import HTTP |
| 43 | response = current.response |
| 44 | path = os.path.join(current.request.folder, "private", "templates", |
| 45 | response.s3.theme, "views", "index.html") |
| 46 | try: |
| 47 | # Pass view as file not str to work in compiled mode |
| 48 | response.view = open(path, "rb") |
| 49 | except IOError: |
| 50 | raise HTTP("404", "Unable to open Custom View: %s" % path) |
| 51 | }}} |