OK, I will answer my own question first...
In your controller:
import os
def index():
context=dict(first_name='Bob is',last_name='your uncle')
template = test_template_path =
os.path.join(current_app,'static','template_test')
test_content = response.render(template,context)
destination =
os.path.join(current_app,'static','template_test_target')
with open(destination, 'w') as f:
f.write(test_content)
exit_message = f.closed
return dict(message=exit_message)
Template contents:
(called template_test in the above example)
{{=first_name}}
{{=last_name}}
Controller output
(Indicates the exit status of your write)
True # hopefully
Output file content:
(the called template_test_target in this example)
Bob is
Your Uncle
On May 6, 8:04 am, Christopher Steel <[email protected]> wrote:
> How would I go about creating a new file using the Web2py template
> system? Would something like this be a practical way to use it?
>
> Example:
>
> template_source_path = ./static/my_readme_template
> template_target_path = ./static/README
>
> Template Example:
>
> contents of static/my_readme_template
>
> # {{=plugin_name}}
> static/{{plugin_name}}/README
> This file was created from a template /static/my_readme_template
>
> # Requirements
> {{=plugin_name}] no longer requires mako!
>
> # General Notes
> In the plugin_plugin's static directory you will find the templates
> used to create new plugins. At this writing templates have been
> created to make skeletal plugin menu, controller and about text.
> Others will probably be added over time.
>
> What would the controller function contain to get a user variable and
> then do the file creation? I want to eliminate the usage of mako for
> templating in this applicaiton if it is practical and makes sense, it
> would be nice to have no dependencies if possible.
>
> http://code.google.com/p/uc-plugin-dev/
>
> Thank You,