html in cherrypy code

14 views
Skip to first unread message

James

unread,
Jun 24, 2008, 7:58:23 PM6/24/08
to cherryp...@googlegroups.com
All,

I'm wondering if anyone knows of any good tutorials on the web that
describes how to properly integrate HTML in CherryPy code. As I write
my web application I obviously need to create a header and a 'body'
with HTML code. I haven't found any good documents online that
describes how to go about doing this.

Also, does anyone have any recommendations on a good 'beginner' book
for CherryPy? I'm very familiar with Python but am ramping up (slowly)
with CherryPy and could use a good read. The documentation / tutorial
on the CherryPy page was lacking a bit.

Thanks!
- james

Eric Abrahamsen

unread,
Jun 24, 2008, 10:31:42 PM6/24/08
to cherryp...@googlegroups.com
There are a lot of python-based tricks you can use for outputting
HTML, such as string formatting, or base classes that define headers
and footers and are extended by other classes that define content, etc
etc. But I've found that after two or three pages of this sort of
stuff it's far easier just to learn one of the many python templating
packages and use that. I use Jinja, because I'm accustomed to django's
templates, but Cheetah, Genshi, Mako and Myghty and Evoque are all
popular options. It's just a major pain to do it yourself, and the
more you work on a nice re-usable system for outputting html, the
closer you come to re-inventing one of the aforementioned templating
packages :)

So far as I know, CherryPy Essentials (http://www.cherrypyessentials.com/
) is the only book out there...

Yours,
Eric

Jason Earl

unread,
Jun 24, 2008, 10:32:25 PM6/24/08
to cherryp...@googlegroups.com
James <j...@nc.rr.com> writes:

I thought that Sylvain Hellegouarch's _CherryPy Essentials_ was quite
good.

http://www.packtpub.com/CherryPy/book

I especially like the chapters on web services and AJAX. I'd worked on
projects that did some of this stuff before, but his examples showed me
lots of things that I could have done better. If you are interested in
building websites with CherryPy and you aren't sure where to start, you
should start with _CherryPy Essentials_.

Jason

jonathansamuel

unread,
Jun 24, 2008, 11:59:06 PM6/24/08
to cherrypy-users
I agree that Sylvain Hellegouarch's book on CherryPy is good. His
example in the book uses the Kid templating engine.

arjuna

unread,
Jun 25, 2008, 2:21:05 AM6/25/08
to cherryp...@googlegroups.com
I use Mako templates and it is quite easy to integrate html with python using cherrry py. Initially there is a bit of a learning curve, however once you get it going, it flows along nicely...If you have any specific questions do post as I went through this learning curve as a complete newbie myself...\
Arjuna

 

Jason Earl

unread,
Jun 25, 2008, 1:07:48 PM6/25/08
to cherryp...@googlegroups.com
jonathansamuel <jonatha...@yahoo.com> writes:

> I agree that Sylvain Hellegouarch's book on CherryPy is good. His
> example in the book uses the Kid templating engine.

The nice thing about Sylvain's book is that he shows you how easy it is
to mix and match components in CherryPy. For example, I have quite a
bit of experience with Zope Page Templates, and I didn't really want to
learn the ins and outs of another templating language just because I got
tired of trying to fit Zope into my head. After reading Sylvain's Kid
examples I was able to integrate SimpleTAL in a similar manner.

In fact, choosing which templating language to use is much more
difficult than integrating your choice into CherryPy. I swear someone
creates a new templating language for Python every 14 minutes.

Jason

Robert Brewer

unread,
Jun 25, 2008, 3:58:23 PM6/25/08
to cherryp...@googlegroups.com
Jason Earl wrote:
> jonathansamuel <jonatha...@yahoo.com> writes:
>
> > I agree that Sylvain Hellegouarch's book on CherryPy is good. His
> > example in the book uses the Kid templating engine.
>
> The nice thing about Sylvain's book is that he shows you how easy it
is
> to mix and match components in CherryPy. For example, I have quite a
> bit of experience with Zope Page Templates, and I didn't really want
to
> learn the ins and outs of another templating language just because I
> got tired of trying to fit Zope into my head. After reading Sylvain's
> Kid examples I was able to integrate SimpleTAL in a similar manner.

Feel free to write that up on http://tools.cherrypy.org/wiki. :)

> In fact, choosing which templating language to use is much more
> difficult than integrating your choice into CherryPy. I swear someone
> creates a new templating language for Python every 14 minutes.

Amen. And ugh.


Robert Brewer
fuma...@aminus.org

James

unread,
Jun 25, 2008, 4:16:27 PM6/25/08
to cherryp...@googlegroups.com
Thanks for the replies, everyone.

Is there a "best" templating system? Or is it a simple balance of
complexity vs flexibility and power?

Thanks!

--
"Do not meddle in the affairs of wizards, for they are subtle and
quick to anger."
-Tolkien

Lukasz Michalski

unread,
Jun 25, 2008, 6:47:18 PM6/25/08
to cherryp...@googlegroups.com
On Wednesday 25 June 2008, James wrote:
> Thanks for the replies, everyone.
>
> Is there a "best" templating system? Or is it a simple balance of
> complexity vs flexibility and power?
>

I am new to cherrypy and python in general and after a little research I
decided to use genshi. I think that the biggest impact on my decision was
that there is excellent tutorial abount cherrypy and genshi.

Regards,
Łukasz

Tim Roberts

unread,
Jun 25, 2008, 5:16:27 PM6/25/08
to cherryp...@googlegroups.com
James wrote:
Is there a "best" templating system? Or is it a simple balance of
complexity vs flexibility and power?
  

In my not very humble opinion, the choice of a templating system is much more a matter of personal preference than it is about performance or complexity.  Seriously, unless you write a site that gets 500 hits a minute (and darned few of us will every do that), you don't need to think about performance.  Instead, you should try a simple project with a bunch of them, then use the one that makes the most sense to you.

I know a lot of people like the Zope TAL scheme.  I don't.  To me, it has always seemed excessively wordy and non-intuitive.  Now, I know that the TAL fans would disagree with my assessment (no need to write me), and that's just fine.  That's why there are so many choices.

For me, the Cheetah scheme has always seemed incredibly sensible.  Simple, quick, flexible, with a great blend of Python and HTML.  It lets me concentrate on making my pages look the way I want, without getting in the way.  Again, I know that many people think that Cheetah breaks the "separation of presentation and computation" rule too much, and that's fine.  I will keep getting my work done with Cheetah, while they get their work done with TAL.
-- 
Tim Roberts, ti...@probo.com
Providenza & Boekelheide, Inc.

Gerold Penz

unread,
Jun 25, 2008, 7:20:15 PM6/25/08
to cherryp...@googlegroups.com
Tim Roberts schrieb:

> For me, the Cheetah scheme has always seemed incredibly sensible.
> Simple, quick, flexible, with a great blend of Python and HTML.

Hello!

I think, Cheetah is a very good choice! Because, it's simple to use for
simple tasks. And it's mighty enough to do powerful tasks. And your
template don´t look like a brace-storm. ;-)

(german) http://halvar.at/python/cherrypy_cheetah/

Regards,
Gerold
:-)

--
________________________________________________________________________
Gerold Penz - bcom - Programmierung
http://halvar.at | http://sw3.at | http://bcom.at
Wissen hat eine wunderbare Eigenschaft:
Es verdoppelt sich, wenn man es teilt.

Jason Earl

unread,
Jun 25, 2008, 9:00:49 PM6/25/08
to cherryp...@googlegroups.com
"Robert Brewer" <fuma...@aminus.org> writes:

> Jason Earl wrote:
>> jonathansamuel <jonatha...@yahoo.com> writes:
>>
>> > I agree that Sylvain Hellegouarch's book on CherryPy is good. His
>> > example in the book uses the Kid templating engine.
>>
>> The nice thing about Sylvain's book is that he shows you how easy it
> is
>> to mix and match components in CherryPy. For example, I have quite a
>> bit of experience with Zope Page Templates, and I didn't really want
> to
>> learn the ins and outs of another templating language just because I
>> got tired of trying to fit Zope into my head. After reading Sylvain's
>> Kid examples I was able to integrate SimpleTAL in a similar manner.
>
> Feel free to write that up on http://tools.cherrypy.org/wiki. :)

I actually have a rough draft started. I just need to finish it. Part
of the problem is that while what I have got now is good enough for me.
It's not quite to the point where it is good enough for the rest of
y'all.

When I get to the point where my solution is as comprehensive as the
Jinja example, then I'll share :).

Jason

James

unread,
Jul 5, 2008, 9:44:17 PM7/5/08
to cherryp...@googlegroups.com
Is there a good tutorial on integrating CherryPy + Cheetah? I haven't
found too much information, but maybe I'm simply dumb and need some
hand holding. ;)

- j

--

James

unread,
Jul 5, 2008, 9:44:58 PM7/5/08
to cherryp...@googlegroups.com
Sorry, I guess I should have indicated that English is my preferred
language. :o)

bernard.chhun

unread,
Jul 20, 2008, 9:59:51 AM7/20/08
to cherrypy-users
here's a sample: http://rafb.net/p/TXuhBV22.html

you should be able to understand with that one snippet. Then head over
to the Cheetah Docs and read away.

On Jul 5, 9:44 pm, James <j...@nc.rr.com> wrote:
> Is there a good tutorial on integrating CherryPy + Cheetah? I haven't
> found too much information, but maybe I'm simply dumb and need some
> hand holding. ;)
>
> - j
>
>
>
> On Wed, Jun 25, 2008 at 7:20 PM, Gerold Penz <gerold.p...@aon.at> wrote:
>
> > Tim Roberts schrieb:
> >> For me, the Cheetah scheme has always seemed incredibly sensible.
> >> Simple, quick, flexible, with a great blend of Python and HTML.
>
> > Hello!
>
> > I think, Cheetah is a very good choice! Because, it's simple to use for
> > simple tasks. And it's mighty enough to do powerful tasks. And your
> > template don´t look like a brace-storm. ;-)
>
> > (german)http://halvar.at/python/cherrypy_cheetah/
Reply all
Reply to author
Forward
0 new messages