On 4/2/07, jerryji <[EMAIL PROTECTED]> wrote:
>
> Hi Ron,
>
> 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. E.g., something like "so you
> will also need to create
> a __init__.py file inside appname/templates" didn't help me at all as
> I don't even know what is
> to be placed in the __init__.py file there.
I am the guilty party that made that terse addition to the wiki page.
I have since tweeked it to say "create an empty __init__.py"
> That's why I am dying for
> a _working_ Pylons+Genshi
> example project.
>
> As another example, I am exercising translating the cheeseshop
> quickwiki tutorial to use Genshi,
I've done the same thing and got it going. I'm new to Pylons to but I should
look at the paste utils and package it up for you.
> 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)
Looks like too much work. I have::
class PageController(BaseController):
def index(self, title):
page = model.Page.get_by(title=title)
if page:
c.content = page.get_wiki_content()
return render_response('page')
elif model.wikiwords.match(title):
return render_response('new_page')
abort(404)
> and the corresponding templates/page.html --
>
> <html xmlns="http://www.w3.org/1999/xhtml"
> xmlns:py="http://genshi.edgewall.org/"
> lang="en">
> <h1 class="main">${c.title}</h1>
> ${c.content}
>
> <py:if test="c.message">
> <p><div id="message">${c.message}></div></p>
> </py:if>
>
Not sure that is meant to be complete. (closing </html> and such)
A couple of other notes:
My Page.get_wiki_content is modified to fix a bunch of annoyances but
in the page template I had to wrap docutils processed stuff in XML() as::
<h1 class="main">${c.title}</h1>
${XML(c.content)}
<div id="message" py:content="c.message"> </div>
> Gives me a "Template "page.html" not found" error.
I have my Genshi templates in a seperate genshitemplates
directory. Then in middleware.py I have::
# Setup Genshi Template Engine
#myghty = config.template_engines.pop()
config.template_engines = []
config.add_template_engine('genshi', 'notsoquickwiki.genshitemplates', {})
#config.template_engines.append(myghty)
(change for your appname and templates subdir)
> Obviously the TemplateLoader
> statement is in error, but how should it be? How should the other
> stuff be? I don't
> know without a guide, how long it will take me just to reach the point
> of knowing
> what I am doing...
>
My version of quickwiki (i called it notsoquickwiki) is up and running
with genshi, postgres, sqalchemy and I'm wanting to get a turbogears
like identity system before I post it. If you want me to package what I have
you may have to suffer my newbie status with paste deployment tools.
You can email me directly at philip dot cooper at openvest dot com if you
dare. Otherwise..cheers.
--
Phil
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---