On Tue, Jul 8, 2008 at 11:44 PM, Ian Bicking <[EMAIL PROTECTED]> wrote:
> 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,
Ok. So you say I should have "template/+package+/files/" plus the 2
files in it( +var_name+.txt_tmpl , +var_name+.csv_tmpl )
> 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
> }}
>
What would be the code for cheetah?
{{
if not 'txt' in vars['myurl']:
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?
If I create 10 templates based on file extensions and user enters only
one url "txt" then I just want to create that one file.
> 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.
Thanks,
Lucas
_______________________________________________
Paste-users mailing list
[email protected]
http://webwareforpython.org/cgi-bin/mailman/listinfo/paste-users