On 4/2/07, jerryji <[EMAIL PROTECTED]> wrote:
> Yes I read both pages a while ago, unfortunately I'm too green to
> Pylons as well as to Python
> to appreciate the terse message there.

I just made a Genshi template last week.  Yes, the docs need to be
filled out.  The Genshi plugin is changing as I understand.  Currently
you have to create a templates/__init__.py file, which may be empty.
You'll also need an __init__.py in any subdirectories you create.
Invoke your templates thus:

    render_response("mydir.mytemplate")
    # For templates/mydir/mytemplate.html

In the future you may be able to use "/mydir/mytemplate.html", but
this requires changes in the plugin code which is part of the Genshi
package, so not under the Pylons developers' control.  Perhaps Pylons
can distribute a temporary plugin until Genshi catches up (or if they
decide not to), but for now this doesn't exist.

You'll have to configure your middleware as described in the wiki:
http://pylonshq.com/project/pylonshq/wiki/GenshiWithPylons

> As another example, I am exercising translating the cheeseshop
> quickwiki tutorial to use Genshi,
> but couldn't get it right. my controllers/page.py snippet looks --
>
>     def index(self, title):
>         page = model.Page.get_by(title=title)
>         if page:
>             c.content = page.get_wiki_content()
>             loader = TemplateLoader(['templates'])
>             tmpl = loader.load('page.html')
>             stream = tmpl.generate(title='Hello, world!')
>             return stream.render('xhtml')
>         elif model.wikiwords.match(title):
>             return render_response('/new_page.html')
>         abort(404)

> Gives me a "Template "page.html" not found" error.

That's because of the missing template/__init__.py .  But you don't
need to create your own TemplateLoader; the plugin handles this for
you.

def index(self, title):
    page = model.Page.get_by(title=title)
    if page:
        c.content = page.get_wiki_content()
        c.title = "Hello, world!"
        return render_response("page")
    elif model.wikiwords.match(title):
        return render_response("new_page")
    abort(404)

By the way, I prefer to explicitly mention the template engine so
there's no confusion on the part of either Pylons or the programmer:

    render_response("genshi", "mydir.mytemplate")

-- 
Mike Orr <[EMAIL PROTECTED]>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to