Lukasz Szybalski wrote:
>> Now as part of the paster create -t myapp , I would like to ask for
>> few vars like this:
>>
>> How can I ask for 1~10 urls of files.
>
> I was able to do it with a "def pre" function under the "class
> FrameworkTemplate"
> http://lucasmanual.com/mywiki/Paste#head-fb94caba6fe96594cfdbe779e69cd7f8514a6444
>
> So now I have a list of my urls that I need to process now.
>
> vars['myurl'] is a list of urls.
>
> 1. Where do I work with 'vars'? Do I still do it in __init__.py under
> "class FrameworkTemplate(templates.Template)" or?
Yes. You can modify them in pre as well.
> 2. How do I create custom files based on url? So if somebody passed in
> a .txt I create a txt file based on txt template. If somebody gave me
> a csv file I create a file based on csv template.
>
>
> For #2 I guess I will be using "create_template(template, output_dir,
> vars)", and my filenames will be called :
> +var_name+.txt_tmpl
> +var_name+.csv_tmpl
I'd put them all in, then do skip_template() for the ones you don't want
to render, e.g., if you are using tempita, in the csv file:
{{py:
if generate_file == 'txt':
raise SkipTemplate
}}
> 3. But where to put above files?
Put them where you want them to go, right?
> 4. Where to put the "create_template" statements, and how would they look?
Is there something in the layout that makes the default copydir setup
not work? Well... if there are a variable number of files, then you'll
need to do something yourself. You can use self.ensure_file(filename,
content), and calculate the content manually by loading and filling the
template.
> 5. How to create files based on if else statements (if txt create only
> txt file)?
The skip template stuff is the best way, otherwise you'd use pre or post.
--
Ian Bicking : [EMAIL PROTECTED] : http://blog.ianbicking.org
_______________________________________________
Paste-users mailing list
[email protected]
http://webwareforpython.org/cgi-bin/mailman/listinfo/paste-users