Lukasz Szybalski wrote:
> On Wed, Jul 9, 2008 at 6:36 PM, Ian Bicking <[EMAIL PROTECTED]> wrote:
>> Lukasz Szybalski wrote:
>>> One more question on +var_name+:
>>> - Do I actually call the file "+var_name+.txt_tmpl" ? Which variable
>>> is it going to use? (there were license, description, myurl.....many
>>> more)?
>> Yes, +var_name+.txt_tmpl will name the file whatever the value of the
>> variable "var_name" is.  It's like $var_name, except easier to put in
>> filenames.
>>
>>> - Or do I call it +myurl+.txt_tmpl . If this is the case since
>>> "var[myurl] is a list how is it going to loop through the
>>> vars['myurl'] ?
>> If you have a list then this won't work -- you'll have to do something like
>> (in a post method):
>>
>> for filename in vars['myurl']:
>>    # or whatever you have to do to instantiate this, I'm not sure:
>>    content = Template(filename=source_filename).substitute(**vars)
> 
> What would be the "source_filename" here?
> Would it be the "+var_name+.txt_tmpl"? or "+package+/+var_name+.txt_tmpl"

You'll have to calculate it yourself.  Maybe like:

source_filename = os.path.join(os.path.dirname(__file__), 
'urlfile'+os.path.splitext(filename)[1])

> for filename in vars['myurl']:
>   if filename=='txt':
>     source_filename="+package+/+package+/+var_name+.txt_tmpl" ???
>     content = Template(filename=source_filename).substitute(**vars)
>     self.ensure_file(filename, content)
>   elif filename=='csv':
>     source_filename="+package+/+var_name+.csv_tmpl" ???
>     content = Template(filename=source_filename).substitute(**vars)
>     self.ensure_file(filename, content)
> 
> If 'txt' was provided only, how will paste know not to fill and copy
> rest of the templates, which I think is a default behavior if all of
> them are under +package+?
> myapp
> |-- __init__.py
> |-- __init__.pyc
> |-- myapp
> |   |-- __init__.py
> |   |-- __init__.pyc
> |   `-- templates
> |       |-- +package+
> |       |   `-- +var_name+.txt_tmpl
> |       |   `-- +var_name+.csv_tmpl
> |       |   `-- +var_name+.tsv_tmpl
> |       |   `-- +var_name+.sh_tmpl

You should put those files outside the templates/ directory.

-- 
Ian Bicking : [EMAIL PROTECTED] : http://blog.ianbicking.org

_______________________________________________
Paste-users mailing list
[email protected]
http://webwareforpython.org/cgi-bin/mailman/listinfo/paste-users

Reply via email to