Re: [Paste] paster quickstart?

Top Page
Author: Ian Bicking
Date:  
To: Lukasz Szybalski
CC: paste-users
Subject: Re: [Paste] paster quickstart?
Lukasz Szybalski wrote:
> Hello.
> I am trying to tell my program to ask user for input filenames and
> based on that it will need to create 2 .py files for each filename. I
> need to substitute the names of few fields in the .py files and add
> some things depending on extension. Right now I just want to create
> folder and single file in it, nothing fancy until I get an idea of how
> this whole thing is structured.
>
> So I guess I want to create a program similar to paster create myapp,
> but it would be called from a command line: myapp create somename ????
> or paster -t myapp? or?
>
> "paster create myapp" command created a structure of my program that
> will be creating my custom files.
>
> I read over here
> (http://pythonpaste.org/script/developer.html#templates) that I can
> use
>
> [paste.paster_create_template]
> framework = framework.templates:FrameworkTemplate
>
> 1. What will above do, and how can I call it later from a command line?
> paster create -t framework ???


Correct.

> 2. I add that I don't see it as being listed as template.? Where is a
> line that tells me I work on myapp vs I work on what will "myapp"
> create?
> paster create --list-templates


Everytime you update setup.py, you need to run python setup.py develop
or python setup.py install. Probably you haven't reinstalled?

> 3. I need some help on what should be set where and how to get it
> working so at least one file is created.
>
> My current structure is:
> tree MyAPP/
>
> MyAPP/
> |-- __init__.py
> |-- myapp
> | `-- __init__.py
> |-- myapp.egg-info
> | |-- PKG-INFO
> | |-- SOURCES.txt
> | |-- dependency_links.txt
> | |-- entry_points.txt
> | |-- not-zip-safe
> | |-- paster_plugins.txt
> | `-- top_level.txt
> |-- setup.cfg
> `-- setup.py
>
>
> I start here : http://pythonpaste.org/script/developer.html
> So I want to start with template and later go into commands.
>
> I've been told I can create a templates with cheetah.


Tempita (http://pythonpaste.org/tempita/) is the preferred language now,
  as it is easier to install than Cheetah.

> templates/
> somefile.py_tmpl
>
> My final finish project would be something like this? I think:
>
> some command to get it started?
> ...ask for Name....etc...
>
> which will give
>
> somename/
> | --somefile.py
> | -- setup.py...
>
> 4. Do I need a templates folder or can I just put my somefile.py_tmpl
> into myapp folder (the structure above)?


You need a folder, as it works by copying the entire tree. You probably
need a tree like;

template/
   setup.py_tmpl
   +package+.py

> 5. What else I need to add?
>
> I think I need to add below to setup.py file?!
> setup(...
> entry_points="""
> [paste.paster_create_template]
> framework = framework.templates:FrameworkTemplate
> """)


That's right.

> 6. What does framework do in above. Does it mean I can call it as
> myapp -t framework?


paster create -t framework Something

> And below I need to put into __init__.py?!
> |-- myapp
> | `-- __init__.py
>
> "
> from paste.script import templates
> class FrameworkTemplate(templates.Template):
>
> egg_plugins = ['Framework']
> summary = 'Template for creating a basic Framework package'
> required_templates = ['basic_package']
> _template_dir = 'template'
> use_cheetah = True


Yes, that's right. Note that using 'basic_package' will fill in a bunch
of files, like create a +package+ directory with an __init__.py. If
that's the structure you want to start with then it's helpful. If you
want to control the entire structure yourself you might not want
required_templates.

> 7. egg_plugins = ['Framework'], in my case this should be egg_plugins
> = ['MyAPP']
> _template_dir = 'template', in my case this should be _template_dir =
> 'myapp' ???
> Anything else I should change?


_template_dir is the location, relative to the class file, where the
source files are located. So 'template' means it's in framework/template/

-- 
Ian Bicking : ianb@??? : http://blog.ianbicking.org

_______________________________________________
Paste-users mailing list
Paste-users@???
http://webwareforpython.org/cgi-bin/mailman/listinfo/paste-users